Root Props
| Prop | Type | Default |
|---|---|---|
multiple | M | — |
Allows selecting several options. Determines the structure of value: an array when true. | ||
value | M extends true ? V[] : V | null | — |
The currently selected value (controlled). Without multiple, null clears the selection, while undefined makes the list uncontrolled. | ||
defaultValue | ListboxValue<V, M> | — |
| The default selected value (uncontrolled). | ||
onChangeValue | (value: ListboxValue<V, M>) => void | — |
| Callback fired when the selection changes. | ||
disabled | boolean | — |
| Prevents interaction and removes the list from the tab order. | ||
size | OptionSize | 'md' |
| Visual size of the options. | ||
typeahead | boolean | true |
| Enables moving to an option by typing the start of its label. | ||
ref | Ref<HTMLDivElement> | — |
| Ref forwarded to the listbox element. | ||
Also accepts all <div> attributes.
Child Parts
ListboxOption
value: the value passed toonChangeValuewhen 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
| Prop | Type | Default |
|---|---|---|
valuerequired | V | — |
| The value of this option, passed to the change callback when it is selected. | ||
label | string | — |
| Plain text of this option for typeahead, used instead of the text of its content. | ||
children | ReactNode | — |
| The content displayed for this option. Can include text, icons, or complex markup. | ||
size | OptionSize | — |
| Size of the option for visual styling. | ||
disabled | boolean | — |
| Disables the entire Option. | ||
ref | Ref<HTMLDivElement> | — |
| Ref forwarded to the root div of the option. | ||
Also accepts all <div> attributes.
ListboxGroup
| Prop | Type | Default |
|---|---|---|
ref | Ref<HTMLDivElement> | — |
| Ref forwarded to the group element. | ||
Also accepts all <div> attributes.
Types
ListboxProps<V, M>:Vis the type of the values,MistruewithmultipleListboxOptionProps<V>ListboxGroupPropsListboxValue<V, M>
State Model
- The list owns the selection, the active option, and typeahead.
- Without
multiplethe value is one option, and withmultipleit is an array.