Skip to main content

Select

Select component to select value from options.

When To Use#

  • A dropdown menu for displaying choices - an elegant alternative to the native <select> element.
  • Utilizing Radio is recommended when there are fewer total options (less than 5).

Examples#

import { Select } from 'tailor-ui/lab';

Basic#

Controlled

Uncontrolled

Searchable#

Async Search#

try to search react:

disabled#

With placeholder & clearable#

Virtual scroll#

Creatable#

Stack#

Multiple Select#

API#

PropertyDescriptionTypeDefault
idId of selectstring
nameName of selectstring
widthWidth of selectstring | number240
creatableCreate new option with input text if truebooleanfalse
clearableShow clear button.booleanfalse
disabledWhether disabled selectbooleanfalse
loadingIs the select in a state of loadingbooleanfalse
searchableWhether to enable search functionalitybooleanfalse
optionsThe options of selectOption[][]
valueCurrent selected optionOption
defaultValueInitial selected optionOption
placeholderPlaceholder of selectstring
onChangeCalled when select an option or input value change(option: Option \| Option[]) => void
onBlurCalled when blur(event: FocusEvent) => void
noOptionsMessageText to display when there are no options() => ReactNode
formatCreateLabelGets the label for the "create new option ..." option in the menu. Is given the current input value.(labelInfo: { value: string; active: boolean; hovered: boolean }) => ReactNodevalue => Create new option: ${value}
isValidNewOptionDetermines whether the "create new option ..." option should be displayed based on the current input value, select value and options array.(value: string) => booleanvalue => value.trim() !== ''
onCreateOptionIf provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created(value: string) => void