- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Groups
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Multiple
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Disabled
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Disabled Item
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Search
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
Direction
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
- Apple
- Banana
- Orange
- Carrot
- Broccoli
- Spinach
API Reference
Root
flex flex-col gap-2| Prop | Default | Type |
|---|---|---|
orientation | "vertical" | "horizontal" | "vertical" | undefined The orientation of the listbox. |
collection | — | ListCollection<any> | GridCollection<any> The item collection |
ids | — | Partial<{ root: string; content: string; label: string; item: (id: string | number) => string; itemGroup: (id: string | number) => string; itemGroupLabel: (id: string | number) => string; }> | undefined The ids of the elements in the listbox. Useful for composition. |
disabled | — | boolean | undefined Whether the listbox is disabled |
disallowSelectAll | — | boolean | undefined Whether to disallow selecting all items when `meta+a` is pressed |
onHighlightChange | — | ((details: HighlightChangeDetails<any>) => void) | undefined The callback fired when the highlighted item changes. |
onValueChange | — | ((details: ValueChangeDetails<any>) => void) | undefined The callback fired when the selected item changes. |
value | — | string[] | undefined The controlled keys of the selected items |
defaultValue | [] | string[] | undefined The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. |
highlightedValue | — | string | null | undefined The controlled key of the highlighted item |
defaultHighlightedValue | — | string | null | undefined The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. |
loopFocus | false | boolean | undefined Whether to loop the keyboard navigation through the options |
selectionMode | "single" | SelectionMode | undefined How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. |
scrollToIndexFn | — | ((details: ScrollToIndexDetails) => void) | undefined Function to scroll to a specific index |
selectOnHighlight | — | boolean | undefined Whether to select the item when it is highlighted |
deselectable | — | boolean | undefined Whether to disallow empty selection |
typeahead | — | boolean | undefined Whether to enable typeahead on the listbox |
onSelect | — | ((details: SelectionDetails) => void) | undefined Function called when an item is selected |
dir | "ltr" | "ltr" | "rtl" | undefined The document's text/writing direction. |
getRootNode | — | (() => ShadowRoot | Node | Document) | undefined A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Provider
| Prop | Default | Type |
|---|---|---|
value | — | ListboxApi<PropTypes, any> |
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Context
| Prop | Default | Type |
|---|---|---|
children | — | (listbox: ListboxApi<PropTypes, any>) => ReactNode |
Label
label-text| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"label">) => Element) | undefined Render the element yourself |
Input
input| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"input">) => Element) | undefined Render the element yourself |
Content
card bg-surface-50-950 border border-surface-200-800 p-2 flex flex-col gap-2| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"ul">) => Element) | undefined Render the element yourself |
ItemGroup
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
ItemGroupLabel
text-surface-600-400 text-xs px-2 py-1| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Item
flex justify-between items-center px-2 py-1 rounded cursor-pointer hover:preset-tonal data-selected:preset-filled data-highlighted:outline-2 data-highlighted:outline-offset-1 data-highlighted:outline-surface-950-50 data-highlighted:preset-tonal data-disabled:pointer-events-none data-disabled:opacity-50| Prop | Default | Type |
|---|---|---|
item | — | any The item to render |
highlightOnHover | — | boolean | undefined Whether to highlight the item on hover |
element | — | ((attributes: HTMLAttributes<"li">) => Element) | undefined Render the element yourself |
ItemText
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"span">) => Element) | undefined Render the element yourself |
ItemIndicator
| Prop | Default | Type |
|---|---|---|
element | — | ((attributes: HTMLAttributes<"span">) => Element) | undefined Render the element yourself |
Root
flex flex-col gap-2| Prop | Default | Type |
|---|---|---|
orientation | "vertical" | "horizontal" | "vertical" | undefined The orientation of the listbox. |
collection | — | ListCollection<any> | GridCollection<any> The item collection |
ids | — | Partial<{ root: string; content: string; label: string; item: (id: string | number) => string; itemGroup: (id: string | number) => string; itemGroupLabel: (id: string | number) => string; }> | undefined The ids of the elements in the listbox. Useful for composition. |
disabled | — | boolean | undefined Whether the listbox is disabled |
disallowSelectAll | — | boolean | undefined Whether to disallow selecting all items when `meta+a` is pressed |
onHighlightChange | — | ((details: HighlightChangeDetails<any>) => void) | undefined The callback fired when the highlighted item changes. |
onValueChange | — | ((details: ValueChangeDetails<any>) => void) | undefined The callback fired when the selected item changes. |
value | — | string[] | undefined The controlled keys of the selected items |
defaultValue | [] | string[] | undefined The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. |
highlightedValue | — | string | null | undefined The controlled key of the highlighted item |
defaultHighlightedValue | — | string | null | undefined The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. |
loopFocus | false | boolean | undefined Whether to loop the keyboard navigation through the options |
selectionMode | "single" | SelectionMode | undefined How multiple selection should behave in the listbox. - `single`: The user can select a single item. - `multiple`: The user can select multiple items without using modifier keys. - `extended`: The user can select multiple items by using modifier keys. |
scrollToIndexFn | — | ((details: ScrollToIndexDetails) => void) | undefined Function to scroll to a specific index |
selectOnHighlight | — | boolean | undefined Whether to select the item when it is highlighted |
deselectable | — | boolean | undefined Whether to disallow empty selection |
typeahead | — | boolean | undefined Whether to enable typeahead on the listbox |
onSelect | — | ((details: SelectionDetails) => void) | undefined Function called when an item is selected |
dir | "ltr" | "ltr" | "rtl" | undefined The document's text/writing direction. |
getRootNode | — | (() => ShadowRoot | Node | Document) | undefined A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Provider
| Prop | Default | Type |
|---|---|---|
value | — | () => ListboxApi<PropTypes, any> |
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Context
| Prop | Default | Type |
|---|---|---|
children | — | Snippet<[() => ListboxApi<PropTypes, any>]> |
Label
label-text| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"label">]> | undefined Render the element yourself |
Input
input| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"input">]> | undefined Render the element yourself |
Content
card bg-surface-50-950 border border-surface-200-800 p-2 flex flex-col gap-2| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"ul">]> | undefined Render the element yourself |
ItemGroup
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
ItemGroupLabel
text-surface-600-400 text-xs px-2 py-1| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Item
flex justify-between items-center px-2 py-1 rounded cursor-pointer hover:preset-tonal data-selected:preset-filled data-highlighted:outline-2 data-highlighted:outline-offset-1 data-highlighted:outline-surface-950-50 data-highlighted:preset-tonal data-disabled:pointer-events-none data-disabled:opacity-50| Prop | Default | Type |
|---|---|---|
item | — | any The item to render |
highlightOnHover | — | boolean | undefined Whether to highlight the item on hover |
element | — | Snippet<[HTMLAttributes<"li">]> | undefined Render the element yourself |
ItemText
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"span">]> | undefined Render the element yourself |
ItemIndicator
| Prop | Default | Type |
|---|---|---|
element | — | Snippet<[HTMLAttributes<"span">]> | undefined Render the element yourself |