Skip to content
v2.5.0
English
Русский
Documentation

Listbox

Listbox is an always visible list to choose one or several options from, like a native select with size.

Root Props

PropTypeDefault
multipleM—
Allows selecting several options. Determines the structure of value: an array when true.
valueM extends true ? V[] : V | null—
The currently selected value (controlled). Without multiple, null clears the selection, while undefined makes the list uncontrolled.
defaultValueListboxValue<V, M>—
The default selected value (uncontrolled).
onChangeValue(value: ListboxValue<V, M>) => void—
Callback fired when the selection changes.
disabledboolean—
Prevents interaction and removes the list from the tab order.
sizeOptionSize'md'
Visual size of the options.
typeaheadbooleantrue
Enables moving to an option by typing the start of its label.
refRef<HTMLDivElement>—
Ref forwarded to the listbox element.

Also accepts all <div> attributes.

Child Parts

ListboxOption

  • value: the value passed to onChangeValue when the option is selected. Required.
  • label: plain text for typeahead, used instead of the text of the content.
  • disabled: makes the option unavailable.
  • size: overrides the size of the list.

ListboxGroup

Groups related options like a native optgroup. Name it with aria-labelledby pointing to your heading, or with aria-label.

ListboxOption

PropTypeDefault
valuerequiredV—
The value of this option, passed to the change callback when it is selected.
labelstring—
Plain text of this option for typeahead, used instead of the text of its content.
childrenReactNode—
The content displayed for this option. Can include text, icons, or complex markup.
sizeOptionSize—
Size of the option for visual styling.
disabledboolean—
Disables the entire Option.
refRef<HTMLDivElement>—
Ref forwarded to the root div of the option.

Also accepts all <div> attributes.

ListboxGroup

PropTypeDefault
refRef<HTMLDivElement>—
Ref forwarded to the group element.

Also accepts all <div> attributes.

Types

  • ListboxProps<V, M>: V is the type of the values, M is true with multiple
  • ListboxOptionProps<V>
  • ListboxGroupProps
  • ListboxValue<V, M>

State Model

  • The list owns the selection, the active option, and typeahead.
  • Without multiple the value is one option, and with multiple it is an array.