Select
Select element input
import { CopySVG, EthSVG, FlagSVG, MoonSVG, Select } from '@ensdomains/thorin'
<Card><Selectautocompleteoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{value: '4',label: 'Four',prefix: <CopySVG />,disabled: true,},{ value: '5', label: 'Four', prefix: <CopySVG /> },]}placeholder="Select an option..."tabIndex="2"/></Card>
name | type | default | description |
---|---|---|---|
align | "left" | "right" | - | If the option list is wider than the select, which |
autocomplete | boolean | false | If the options list will filter options based on text input. |
createable | boolean | false | If it is possible to create an option if it does not exist in the options list. |
createablePrefix | string | Add | The string or component to prefix the value in the create value option. |
description | ReactNode | - | Description text or react component. |
direction | "up" | "down" | down | If the menu opens up top or bottom. |
disabled | boolean | - | If true, prevents user interaction with component. |
emptyListMessage | string | No results | Message displayed if there is no available options. |
id | string | - | The id attribute of div element. |
onChange | ChangeEventHandler<HTMLInputElement> | - | The handler for change events. |
error | ReactNode | - | Error text or a react component. |
hideLabel | boolean | - | If true, hides the label and secondary label. |
inline | boolean | - | If true, moves the label and status messages to the right of the content. |
inputSize | number | { max?: number | undefined; min?: number | undefined; } | - | The size attribute for input element. Useful for controlling input size in flexboxes. |
label* Required | ReactNode | - | Label text or react component |
labelSecondary | ReactNode | - | Secondary text or react component |
padding | any | - | Overide the padding setting of the element |
readOnly | boolean | false | If true, sets the select component into read only mode
If true, will set the Fields component to read only mode |
size | "small" | "medium" | medium | Preset size spacing settings |
tabIndex | number | -1 | The tabindex attribute for |
onFocus | FocusEventHandler<HTMLInputElement> | - | The handler for focus events. |
onBlur | FocusEventHandler<HTMLInputElement> | - | The handler for blur events. |
onCreate | (value: string) => void | - | A handler for when new values are created |
name | string | - | The name property of an input element. |
options* Required | SelectOptionProps[] | - | An arrary of objects conforming to OptionProps interface. |
ref | Ref<HTMLInputElement> | - | - |
required | boolean | - | Adds mark to label |
reverse | boolean | - | Have label appear on the left of the form element. |
rows | number | - | The approximate number of rows to display on menu. |
showBorder | boolean | - | If true, show a border around the select component * |
showDot | boolean | false | If true will show the indicator dot |
validated | boolean | - | If true and showDot is true, will show a green indicator |
value | string | - | The selected option's value. |
width | any | - | A tokens space key value setting the width of the parent element. |
name | type | default | description |
---|---|---|---|
color | Colors | - | The color of the option. |
disabled | boolean | - | If true, prevents user interaction with option. |
label | string | - | The human readable text for the option. |
node | ReactNode | - | A react node that acts as the label as an alternative to the label prop. |
prefix | ReactNode | - | The text or component inserted before the label. |
value* Required | string | - | The value of the option. |
<DeleteMe><Selectdescription="Select with placeholder"label="Placeholder"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}placeholder="Select option..."showDot/><Selectdescription="Select with placeholder"label="Validated"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}placeholder="Select option..."showDotvalidatedvalue="2"/><Selectdescription="Select with placeholder"error="Error message"label="Error"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}placeholder="Select option..."showDot/><Selectdescription="Select with placeholder"disabledlabel="Disabled"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}placeholder="Select option..."showDot/></DeleteMe>
<DeleteMe flexDirection="row" justifyContent="space-between"><div><Selectalign="left"label="Label text"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}/></div><div><Selectalign="right"label="Label text"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}/></div></DeleteMe>
<DeleteMe><Selectlabel="Small"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },]}size="small"/><Selectlabel="Medium"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },]}size="medium"/></DeleteMe>
<Card><Selectdisabledoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}selected={{ value: '1', label: 'One', prefix: <EthSVG /> }}/></Card>
<Card><Selectautocompleteoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG />, color: 'redPrimary' },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}selected={{ value: '1', label: 'One', prefix: <EthSVG /> }}/></Card>
<><Card><Selectcreateableoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{ value: '4', label: 'Four', prefix: <CopySVG />, disabled: true },]}/></Card></>
<Card><Selectautocompleteoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{value: '4',label: 'Four',prefix: <CopySVG />,disabled: true,},{ value: '5', label: 'Four', prefix: <CopySVG /> },]}rows={3}tabIndex="2"/></Card>
<DeleteMe><div style={{ height: '200px' }} /><Selectcreateabledirection="up"options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{value: '4',label: 'Four',prefix: <CopySVG />,disabled: true,},{ value: '5', label: 'Four', prefix: <CopySVG /> },]}tabIndex="2"/></DeleteMe>
<DeleteMe flexDirection="row" justifyContent="flex-start"><div><SelectcreateableinputSize={{min: 5,max: 20,}}options={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{value: '4',label: 'Four',prefix: <CopySVG />,disabled: true,},{ value: '5', label: 'Four', prefix: <CopySVG /> },]}rows={3}tabIndex="2"/></div></DeleteMe>
<DeleteMe><Selectcreateableoptions={[{ value: '0', label: 'Zero' },{ value: '1', label: 'One', prefix: <EthSVG /> },{ value: '2', label: 'Two', prefix: <WalletSVG /> },{ value: '3', label: 'Three', prefix: <MoonSVG /> },{value: '4',label: 'Four',prefix: <CopySVG />,disabled: true,},{ value: '5', label: 'Four', prefix: <CopySVG /> },]}readOnlytabIndex="2"value="1"/></DeleteMe>