Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
    • Checkbox
    • ChoiceGroup
    • CurrencyInput
    • DateInput
    • FileInputZone
    • Filters
    • Form
    • MaskedTextInput
    • PasswordInput
    • Pill
    • Pill
    • Radio
    • SearchInput
    • SegmentedSlider
    • Select
    • Switch
    • TextArea
    • TextInput
  • Layout & containers
  • Overlays
  • Feedback & status
  • Data display
  • Typography
  • Accessibility
  • Contrib
  • Deprecated
  • Forms & inputs
  • Select

Select

Picks one option from a list in a dropdown. Use when there are too many options to show as radios.

Health
Component health
Source
View on Github
Design
View Figma
Storybook
View in Storybook
Playground
No Example
Accessibility

partially-compliant

Platform
Universal
Accessibility issues
Options misses `aria-selected` true when selected
  • Overview
  • Props
  • Figma

Usage​

Controlled​

function Demo() {
const [value, setValue] = useState("");
return <Select options={options} value={value} onChange={(newValue) => setValue(newValue)} />;
}

Clearable​

Set clearable prop to display the clear button in the right section:

Searchable​

Set searchable prop to allow filtering options by user input:

Multiple​

Set multiple prop to allow selecting multiple values.

The multiple prop is compatible with clearable and searchable:

When using multiple, the value is array of strings (so is the defaultValue and onChange's argument):

function Demo() {
const [values, setValues] = useState<string[]>(["React"]);
return <Select options={options} value={values} onChange={(newValues) => setValues(newValues)} />;
}

Option formats​

The options prop accepts data of the following formats:

Array of strings:

<Select options={["React", "Angular"]} />

Array of object with value, label and optional disabled keys:

<Select
options={[
{ value: "react", label: "React" },
{ value: "ng", label: "Angular", disabled: true },
]}
/>

Disable options​

When option is disabled, it cannot be selected and is ignored in keyboard navigation.

Disabled​

Set disabled to disable the input. When disabled is set, user cannot interact with the input and Select will not show suggestions.

Error state​

Invalid name

Condensed theme​

For applications with condensed theme density, this component renders in a condensed style:

Usage in <Form>​

On web, Select can be used in <Form> component and be controleld by Formik:

React

Usage on mobile​

On mobile, you can use the nativeSheetTitle prop to set a custom title to the BottomSheet modal displaying the Select values. By default it will use the label.

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

Select props

NameTypeDefault ValueDescriptionUsage count
aria-describedbystringId of an element outside the input that also describes it, such as an error shared by several inputs
aria-labelstringAccessibility label, only necessary when not associated with a label
aria-requiredbooleanOverrides `aria-required` set by `required`, to mark the input as mandatory without the asterisk
autoFocusbooleanIf true, focuses the input on componentDidMount.The default value is false.
canSelectAllbooleanAdds a button below the options: selects the displayed, non-disabled options when nothing is selected, clears the selection otherwise.
clearablebooleanDetermines whether the clear button should be displayed in the right section when the component has value, false by default
cursorCursorEnforce a cursor type
defaultValuestringstring[]null
disabledbooleanDisable input
enterKeyHint"search""done""go""next""send"
errorReactNodeContents of `InputError` component, if not set, error is not rendered.
filter((value: string, item: Item) => boolean)Function based on which items in dropdown are filtered
focusedbooleanShow focus styles even when the input isn't focused, e.g. while a readonly input's picker is open
helpTextReactNodeContents of `InputHelp` component, if not set, description is not rendered.
idstring
labelReactNodeContents of `InputLabel` component, if not set, label is not rendered.
localeLocaleLanguage to use for Confirm Button
maxstringnumber
maxLengthnumberMaximum string length that the user can enter in UTF-16 code units
minstringnumber
minLengthnumberMaximum string length that the user can enter in UTF-16 code units
multiplebooleanDetermines whether several options can be selected, `false` by default
namestringHtml input name
nativeSheetTitlestringTitle of the BottomSheet on mobile
onChange
1 possibilities((value: string) => void) | ((value: string | null) => void) | ((value: string[]) => void)
onPress((event: GestureResponderEvent) => void)
options*Item[]Select data used to render items in dropdown
placeholderstring
prefixReactNodeContent section rendered on the left side of the input
prefixPointerEvents"none""auto""box-none""box-only"Sets pointer-events styles on the `prefix` element, `none` by default
readonlybooleanMake input readonly
renderPlaceholder(() => ReactNode)To render a custom placeholder view when the field is empty
requiredbooleanAdds required attribute to the input and a red asterisk on the right side of label, `false` by default
searchablebooleanDetermines whether the select should be searchable, `false` by default.
stepstringnumber
suffixReactNodeContent section rendered on the right side of the input
suffixPointerEvents"none""auto""box-none""box-only"Sets pointer-events styles on the `suffix` element, `none` by default
sxPositionPropsPositioning properties
titlestringHtml input title
typeHTMLInputTypeAttributeHTML input type
valuestringstring[]null

Undocumented props

NameTypeDefault ValueDescriptionUsage count
data-1p-ignoreany
data-bwignoreany
data-lpignoreany
onBlurany
refany
testIDany

Style API​

Use sx for one-off adjustments. It accepts these style keys:

alignSelfanimationaspectRatiobottomcursordisplayendflexflexBasisflexGrowflexShrinkheightinsetinsetInlineinsetInlineEndinsetInlineStartleftmarginmarginBottommarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginTopmarginVerticalmatrixmaxHeightmaxWidthminHeightminWidthopacityperspectivepositionrightrotaterotateXrotateYrotateZscalescaleXscaleYskewXskewYstarttoptransformtransformOriginwidthxyzIndex

Each can be overridden per breakpoint with:

$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$sm$vs$xl$xs$xxl
Edit this page
Previous
SegmentedSlider
Next
Switch
  • Usage
  • Controlled
  • Clearable
  • Searchable
  • Multiple
  • Option formats
  • Disable options
  • Disabled
  • Error state
  • Condensed theme
  • Usage in <Form>
  • Usage on mobile
  • Playground

React