Select
The select and search controls allow the user to select an option or options.
Select menus in Base hover atop of a selection menu while providing a simple list of options. Proper spacing, color, and a check-mark are clear indicators of a selection. Each menu is scrollable, if applicable.
Examples
Things to note in the example source code:
- the
valueis always anArrayto provide a consistent interface - no matter if you use multi or single selects, - you have to call
setStatewith the entire object, not just theidvalue.
When type is 'search' a magnifying glass icon will be rendered to the input's left and a dropdown arrow will not be rendered to the right.
The creatable select enables users to create new options along with choosing existing options.
Use startOpen to mount the Select with an open dropdown.
Combine this with autoFocus if you want the input to be focused as well.
Note, the dropdown will close once an item is selected or if the escape key is pressed while the Select has focus.
If you want the dropdown to stay open you might be better off using Menu directly.
To override the Popover that's being used by the Dropdown subcomponent, you have to use a nested override.
Select exports
You can import this module like so:
import {Select} from 'baseui/select'
It exports the following components or utility functions:
- Select
- SingleSelect
- MultiSelect
- SingleValue
- MultiValue
- AutosizeInput
- SelectDropdown
- StatefulSelect
- StatefulSelectContainer
- StyledRoot
- StyledControlContainer
- StyledValueContainer
- StyledPlaceholder
- StyledSingleValue
- StyledInputContainer
- StyledInput
- StyledInputSizer
- StyledIconsContainer
- StyledSelectArrow
- StyledClearIcon
- StyledSearchIcon
- StyledDropdownContainer
- StyledDropdown
- StyledDropdownListItem
- StyledOptionContent
- filterOptions
- SIZE
- TYPE
- STATE_CHANGE_TYPE