Listbox
An always-visible list for selecting one or more options.
Usage guidelines
- Always visible: Unlike Select, the Listbox is always open and does not use a popup or trigger. Use it when all options should be visible at once.
- Multi-select support: Set
selectionMode="multiple"or"explicit-multiple"to allow selecting more than one item. - Form controls must have an accessible name: Prefer
<Listbox.Label>, or provide anaria-labelon<Listbox.List>when no visible label is rendered. See the forms guide.
Anatomy
Import the component and assemble its parts:
Examples
Selection modes
The selectionMode prop controls how items are selected:
"single"(default) — clicking an item selects it and deselects any other."multiple"— every click toggles an item. Hold Shift and click to select a contiguous range."explicit-multiple"— clicking an item replaces the selection. Hold Ctrl/⌘ and click to toggle, or Shift and click to select a range.
Lazy loading
Use Listbox.LoadingTrigger as a sentinel at the end of the list. When it scrolls into view, the onLoadMore callback fires.
Drag and drop
Wrap reorderable content in Listbox.DragAndDropProvider and provide onItemsReorder on the provider.
Use the provider’s canDrag and canDrop predicates to control which items can be dragged or dropped, and use Listbox.ItemDragHandle to restrict drag initiation to a handle.
Items can also be reordered with the keyboard using Alt + Arrow keys.
Use canDrop to constrain reordering within a Listbox.Group or apply other custom drop rules.
In multiple or explicit-multiple mode, dragging a selected item moves all selected items together, preserving their relative order.
Drag within groups
Pass canDrop to Listbox.DragAndDropProvider to keep reordering inside the current Listbox.Group. This example only accepts drops when every dragged item belongs to the same group as the target item.
The same canDrop callback can also enforce other drop target rules, such as preventing drops around locked items or only allowing certain item types to be reordered next to each other. Because it receives the dragged items, the target item, and the drop edge, you can use it to express custom placement logic in one place.
Custom keyboard shortcuts
You can add custom keyboard shortcuts by handling onKeyDown on Listbox.List and updating the items array directly. This example uses ] and [ to move the focused item to the beginning or the end of the list.
API reference
Root
Groups all parts of the listbox. Doesn’t render its own HTML element.
namestring—
- Name
- Description
Identifies the field when a form is submitted.
- Type
defaultValueValue[]—
- Name
- Description
The uncontrolled value of the listbox when it’s initially rendered.
To render a controlled listbox, use the
valueprop instead.- Type
valueValue[]—
- Name
- Description
The value of the listbox. Use when controlled. Always an array.
- Type
onValueChangefunction—
- Name
- Description
Event handler called when the value of the listbox changes.
- Type
highlightItemOnHoverbooleantrue
- Description
Whether moving the pointer over items should highlight them.
- Type
- Default
true
actionsRefReact.Ref<Listbox.Root.Actions<Value>>—
- Name
- Description
A ref to imperative actions.
- Type
isItemEqualToValuefunction—
- Description
Custom comparison logic used to determine if a listbox item value matches the current selected value. Defaults to
Object.iscomparison.- Type
itemToStringLabelfunction—
- Description
Converts an object value to a string label for display.
- Type
itemToStringValuefunction—
- Description
Converts an object value to a string representation for form submission.
- Type
loadingbooleanfalse
- Name
- Description
Whether items are currently being loaded.
- Type
- Default
false
loopFocusbooleantrue
- Name
- Description
Whether keyboard navigation loops back to the first/last item.
- Type
- Default
true
onHighlightChangefunction—
- Description
Event handler called when the highlighted item changes. Receives the highlighted item’s value and DOM element, or
nullfor both when no item is highlighted.- Type
onLoadMorefunction—
- Name
- Description
Event handler called when more items should be loaded.
- Type
selectionModeSelectionMode'single'
- Name
- Description
Determines how user interactions affect the selection.
'single'— Only one item can be selected at a time.'multiple'— Clicking toggles items. Shift+Click selects a range.'explicit-multiple'— Like a file browser: plain click replaces the selection, Ctrl/Cmd+Click toggles, Shift+Click selects a range.
- Type
- Default
'single'
disabledbooleanfalse
- Name
- Description
Whether the component should ignore user interaction.
- Type
- Default
false
requiredbooleanfalse
- Name
- Description
Whether the user must choose a value before submitting a form.
- Type
- Default
false
orientation'vertical' | 'horizontal''vertical'
- Name
- Description
The orientation of the listbox for keyboard navigation.
- Type
- Default
'vertical'
inputRefReact.Ref<HTMLInputElement>—
- Name
- Description
A ref to access the hidden input element.
- Type
idstring—
- Name
- Description
The id of the Listbox.
- Type
childrenReact.ReactNode—
- Name
- Type
Listbox.Root.StateHide
Listbox.Root.ActionsHide
Listbox.Root.ChangeEventReasonHide
Listbox.Root.ChangeEventDetailsHide
Label
An accessible label that is automatically associated with the listbox.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.Label.StateHide
List
A container for the listbox items.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-orientation
Indicates the orientation of the listbox.
data-disabled
Present when the listbox is disabled.
Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the listbox. | |
data-disabled | Present when the listbox is disabled. | |
Listbox.List.StateHide
DragAndDropProvider
Enables drag-and-drop reordering when rendered inside Listbox.Root.
Renders no DOM element of its own.
canDragfunction—
- Name
- Description
Determines whether a given item can initiate drag-and-drop. Defaults to allowing all non-disabled items.
- Type
canDropfunction—
- Name
- Description
Determines whether the dragged items can be dropped relative to a target item. Defaults to allowing all drops.
- Type
onItemsReorderfunction—
- Name
- Description
Event handler called when items are reordered via drag-and-drop or keyboard.
itemscontains the moved item(s).referenceItemis the item that was dropped on or moved next to, andedgeindicates placement relative to it.- Type
childrenReact.ReactNode—
- Name
- Type
Listbox.DragAndDropProvider.PropsHide
Re-Export of DragAndDropProvider props as ListboxDragAndDropProviderProps
Listbox.DragAndDropProvider.StateHide
Item
An individual option in the listbox.
Renders a <div> element.
labelstring—
- Name
- Description
Specifies the text label to use when the item is matched during keyboard text navigation.
- Type
valueanynull
- Name
- Description
A unique value that identifies this listbox item.
- Type
- Default
null
nativeButtonbooleanfalse
- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set totrueif the rendered element is a native button.- Type
- Default
false
disabledbooleanfalse
- Name
- Description
Whether the component should ignore user interaction.
- Type
- Default
false
childrenReact.ReactNode—
- Name
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
data-selected
Present when the listbox item is selected.
data-highlighted
Present when the listbox item is highlighted.
data-dragging
Present when the listbox item is being dragged.
data-disabled
Present when the listbox item is disabled.
data-drop-target
Present when the listbox item is a drop target.
data-drop-target-edge
Indicates the closest edge when the item is a drop target.
The value is 'before' or 'after'.
Attribute | Description | |
|---|---|---|
data-selected | Present when the listbox item is selected. | |
data-highlighted | Present when the listbox item is highlighted. | |
data-dragging | Present when the listbox item is being dragged. | |
data-disabled | Present when the listbox item is disabled. | |
data-drop-target | Present when the listbox item is a drop target. | |
data-drop-target-edge | Indicates the closest edge when the item is a drop target.
The value is | |
Listbox.Item.StateHide
ItemText
A text label of the listbox item.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.ItemText.StateHide
ItemIndicator
Indicates whether the listbox item is selected.
Renders a <span> element.
childrenReact.ReactNode—
- Name
- Type
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
keepMountedboolean—
- Name
- Description
Whether to keep the HTML element in the DOM when the item is not selected.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.ItemIndicator.PropsHide
Re-Export of ItemIndicator props as ListboxItemIndicatorProps
Listbox.ItemIndicator.StateHide
ItemDragHandle
A drag handle within a listbox item for initiating drag-and-drop reordering.
Renders a <div> element.
When placed inside a Listbox.Item within Listbox.DragAndDropProvider,
the drag operation will be restricted to start only from this handle
whenever the provider allows dragging for that item.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.ItemDragHandle.PropsHide
Re-Export of ItemDragHandle props as ListboxItemDragHandleProps
Listbox.ItemDragHandle.StateHide
Group
Groups related listbox items with the corresponding label.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.Group.StateHide
GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.GroupLabel.PropsHide
Re-Export of GroupLabel props as ListboxGroupLabelProps
Listbox.GroupLabel.StateHide
LoadingTrigger
A sentinel element that triggers loading more items when scrolled into view.
Renders a <div> element.
Place at the end of the listbox items. When it becomes visible in the
scrollable list container, the onLoadMore callback on Listbox.Root is called.
classNamestring | function—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
styleReact.CSSProperties | function—
- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
keepMountedboolean—
- Name
- Description
Whether to keep the HTML element in the DOM when not loading.
- Type
renderReactElement | function—
- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
Listbox.LoadingTrigger.PropsHide
Re-Export of LoadingTrigger props as ListboxLoadingTriggerProps