Select

Display a dropdown list of items.

The Select contain an additional Hooks, see subsection useModal for details.

General

Basic usage.

Type

Differentiate states by color.

Variants

Use filled, light, ghost or subtle with a type to change the surface of the field.

Variants

Use filled, light, ghost or subtle with a type to change the surface of the field.

Disabled

Disable all options.

Disabled Option

disable specified options.

Without Icon

Hide icon on right.

Labels

show data as a group.

Divider

You can use the divider of the Select with the property divider.

Multiple

Select supports multiple values to be selected.

Multiple Without Clear

Select supports multiple values to be selected without the clear icon.

Compose

Use with other components.

Over Width

Option to show more text with adaptive width.

Set parent element

you can specify the container for drop-down box rendering.

Filter bar

Keep the chosen values in state and say what they produce. A Select per filter reads better than one long list.

APIs

Select.Props

AttributeDescriptionTypeAccepted valuesDefault
valueselected valuestring, string[]--
initialValueinitial valuestring, string[]--
placeholderplaceholder stringstring--
widthcss width value of selectstring-initial
typecurrent typeSelectTypesSelectTypesdefault
iconicon componentComponentType-SVG Component
pureremove icon componentboolean-false
multiplesupport multiple selectionboolean-false
clearableadd clear icon on multiple selection (ignored otherwise)boolean-true
disableddisable current radioboolean-false
errormark the field as invalidboolean-false
errorMessagemessage shown below the fieldstring--
roundedround the cornersboolean-false
filledfilled variantboolean-false
lightlight variantboolean-false
ghostoutline variantboolean-false
subtlesubtle variantboolean-false
roundedround the cornersboolean-false
filledfilled variantboolean-false
lightlight variantboolean-false
ghostoutline variantboolean-false
subtlesubtle variantboolean-false
onChangeselected value(val: string | string[]) => void --
dropdownClassNameclassName of dropdown menustring--
dropdownStylestyle of dropdown menuobject--
disableMatchWidthdisable Option from follow Select widthboolean-false
getPopupContainerdropdown render parent element, the default is body() => HTMLElement--
onDropdownVisibleChangedropdown change events(visible: boolean) => void--
refforwardRefSelectRefSelectRef-
...native propsHTMLAttributes'name', 'alt', ...-

Select.Option.Props

AttributeDescriptionTypeAccepted valuesDefault
value(required)unique ident valuestring--
disableddisable current optionboolean-false
dividerdisplay a lineboolean-false
labeldisplay a group titleboolean-false
...native propsHTMLAttributes'name', 'id', ...-

SelectRef

type SelectRef = {
  focus: () => void
  blur: () => void
  scrollTo?: (options?: ScrollToOptions) => void
}

SelectTypes

type SelectTypes =
  'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info'

Accessibility

  • • The field is a combobox with aria-haspopup="listbox" and aria-expanded, and the list is a listbox of option elements. Its placeholder is the name when you do not pass one.
  • • With the focus on the field, the arrows, Enter and Space open the list. Up and Down arrows move between the options and skip the disabled ones, Home and End go to the first and the last, Enter and Space choose the option, and Escape closes the list. Typing letters goes to the option that starts with them, and opens the list when it is closed. With multiple, Enter toggles the option and the list stays open.
  • • With multiple, each chosen value has a button named "Remove" followed by its text, such as "Remove Brazil".
  • • The option the keyboard is on is announced through aria-activedescendant, so the focus stays on the field.
  • • Without a visible label, pass aria-label or aria-labelledby.
Edit this page on GitHub