Select
freeSelect lets users choose one option or several from a searchable list.
Installation
Add this component with the NateUI CLI.
Examples
Basic
Multiple
TypeScriptReact
Size
Searchable
Disabled
Grouped
Custom Options
Creatable
Async
Controlled
Selected: In progress
API
Select ships two controls from one import: Select for a single choice and
Select.Multi for several. Both take the same options shape — a flat array of
{ label, value } items, or an array of { label, options } groups — and share
the search, loading, sizing, and validation props. Select.ValueWithPrefix and
Select.OptionWithPrefix are helpers for the custom render props.
Select
| Prop | Description | Type | Default |
|---|---|---|---|
options | Selectable options: a flat list, or groups of options. | Options<T> | [] |
value | Selected option in controlled mode. | SingleOption<T> | null | - |
defaultValue | Initial selected option when uncontrolled. | SingleOption<T> | null | - |
onChange | Fires with the newly selected option. | (value: SingleOption<T>) => void | - |
placeholder | Text shown when nothing is selected. | string | - |
isSearchable | Show a filter input inside the menu. | boolean | false |
isCreatable | Let the filter text become a new option. | boolean | false |
isDisabled | Disable the whole control. | boolean | false |
isLoading | Show a spinner in the control. | boolean | false |
invalid | Apply the invalid style; also inherited from an invalid Form.Field. | boolean | false |
size | Control size; falls back to InputGroup, Form, then ConfigProvider. | ControlSize | 'md' |
placement | Menu placement relative to the control. | Placement | - |
customInputDisplay | Render the selected value in the control yourself. | (selectedItem: SingleOption<T> | null) => ReactNode | - |
customOption | Render each option row yourself. | CustomOption<T> | - |
formatGroupLabel | Render a group's header label. | (group: GroupOption<T>) => ReactNode | - |
filter | Replace the default option filtering. | FilterFunction<T> | - |
noOptionsMessage | Message shown when no options match. | string | ((ListElement) => ReactNode) | 'No options' |
onInputChange | Fires with the filter text as the user types. | (inputValue: string) => void | - |
onMenuOpen | Fires when the menu opens. | () => void | - |
searchInputProps | Extra props for the filter input. | Omit<ComponentProps<'input'>, 'onChange' | 'value' | 'onKeyDown' | 'ref'> | - |
inputId | id for the underlying input, for label association. | string | - |
className | Class names for the control element. | string | - |
...nativeProps | Native div props (except defaultValue and onChange). | Omit<ComponentPropsWithRef<'div'>, 'defaultValue' | 'onChange'> | - |
Select.Multi
Select.Multi shares every Select prop above except customInputDisplay, and
replaces the single-value props with array equivalents.
| Prop | Description | Type | Default |
|---|---|---|---|
value | Selected options in controlled mode. | SelectedOptions<T> | - |
defaultValue | Initial selected options when uncontrolled. | SelectedOptions<T> | - |
onChange | Fires with the full array of selected options. | (value: SelectedOptions<T>) => void | - |
customLabel | Render each selected tag's content yourself. | (selectedItem: SingleOption<T>) => ReactNode | - |
showClearAllButton | Show the per-tag remove buttons and the clear-all control. | boolean | true |
filter | Replace the default option filtering. | FilterFunctionMulti<T> | - |
Select.ValueWithPrefix
| Prop | Description | Type | Default |
|---|---|---|---|
label | The value's main content. | ReactNode | - |
prefix | Node rendered before the label, such as an avatar or icon. | ReactNode | - |
showPrefix | Whether to render the prefix. | boolean | true |
Select.OptionWithPrefix
| Prop | Description | Type | Default |
|---|---|---|---|
label | The option's main content. | ReactNode | - |
prefix | Node rendered before the label, such as an avatar or icon. | ReactNode | - |
selected | Whether this option is currently selected. | boolean | false |
checkIcon | Node shown on the right when selected; pass the CheckIcon from customOption. | ReactNode | - |