import * as React from "react"; import * as System from "~/components/system"; import * as Constants from "~/common/constants"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; import CodeBlock from "~/components/system/CodeBlock"; const SELECT_MENU_OPTIONS = [ { value: "1", name: "Capricorn" }, { value: "2", name: "Aquarius" }, { value: "3", name: "Pisces" }, { value: "4", name: "Aries" }, { value: "5", name: "Taurus" }, { value: "6", name: "Gemini" }, { value: "7", name: "Cancer" }, { value: "8", name: "Leo" }, { value: "9", name: "Virgo" }, { value: "10", name: "Libra" }, { value: "11", name: "Scorpio" }, { value: "12", name: "Sagittarus" }, ]; export default class SystemPageDropdowns extends React.Component { state = { exampleOne: "1", exampleTwo: "3", exampleThree: "United States of America", }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; render() { return ( Dropdowns

The Dropdown component is used to present the user a list of values where they can select a single option.


Imports

Import React and the SelectMenu{" "} and/or the SelectCountryMenu{" "} Components.

{`import * as React from "react"; import { SelectMenu, SelectCountryMenu } from "slate-react-system";`}

Dropdown






Define the dropdown menu options. Each entry must have a name and a value.
{`const SELECT_MENU_OPTIONS = [ { value: "1", name: "Capricorn" }, { value: "2", name: "Aquarius" }, { value: "3", name: "Pisces" }, { value: "4", name: "Aries" }, { value: "5", name: "Taurus" }, { value: "6", name: "Gemini" }, { value: "7", name: "Cancer" }, { value: "8", name: "Leo" }, { value: "9", name: "Virgo" }, { value: "10", name: "Libra" }, { value: "11", name: "Scorpio" }, { value: "12", name: "Sagittarus" }, ];`}

Declare the Dropdown component. Default values can be assigned using{" "} value.
{`class ExampleOne extends React.Component { state = { exampleOne: "1" }; _handleChange = (e) => this.setState({ [e.target.name]: e.target.value }); render() { return ( ); } } class ExampleTwo extends React.Component { state = { exampleTwo: "3" }; _handleChange = (e) => this.setState({ [e.target.name]: e.target.value }); render() { return ( ); } }`}


Country Picker Dropdown




Declare a dropdown to select from a list of countries.
{`class ExampleThree extends React.Component { state = { exampleThree: "United States of America" }; _handleChange = (e) => this.setState({ [e.target.name]: e.target.value }); render() { return ( ); } }`}


Accepted React Properties

options ), b: "Array", c: "[]", d: "Array of options to select from. Each object in the array should have a name and value", }, { id: 2, a: ( onChange ), b: "function", c: "null", d: "Function called upon an onChange event", }, { id: 3, a: ( value ), b: "string", c: "null", d: "The value that the dropdown takes. Can be used to assign default values as well.", }, { id: 4, a: "name", b: "string", c: "null", d: "Input name", }, { id: 5, a: "label", b: "string", c: "null", d: "Label text", }, { id: 6, a: "description", b: "string", c: "null", d: "Description text", }, { id: 7, a: "tooltip", b: "string", c: "null", d: "Tooltip text", }, { id: 8, a: "full", b: "boolean", c: "false", d: "Sets width to 100% if true", }, { id: 9, a: "category", b: "string", c: "null", d: "Category text", }, ], }} />
); } }