Skip to contents

Listbox

An always-visible list for selecting one or more options.

Move to
Inbox
Archive
Drafts
Projects
Receipts
Travel
Work
Personal

Usage guidelines

  • Prefer Select for forms: Use Select instead of Listbox for selection in forms.
  • Multi-select support: Set multiple to allow selecting more than one item. The value is then an array.
  • Provide an accessible name: Prefer <Listbox.Label>, or provide an aria-label on <Listbox.List> when no visible label is rendered.

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Multiple selection

Add the multiple prop to let users select more than one item. The value is an array of the selected items.

Choose your favorite animals
Cat
Dog
Elephant
Giraffe
Koala
Lion
Otter
Penguin
Zebra

Opt-in multiple selection

Use multiple="opt-in" when users opt in to selecting more than one item by holding a modifier key. On touch devices, which have no modifier keys, a tap adds or removes an item, the same as multiple.

Playlist
Bohemian RhapsodyQueen
Billie JeanMichael Jackson
Hotel CaliforniaEagles
SuperstitionStevie Wonder
Dancing QueenABBA

Virtualized

Render large lists with a virtualization library such as @tanstack/react-virtual.

Items

API reference

Root

Groups all parts of the listbox. Doesn’t render its own HTML element.

defaultValueUnion—
Description

The uncontrolled value of the listbox when it’s initially rendered.

To render a controlled listbox, use the value prop instead.

Type
valueUnion—
Name
Description

The value of the listbox. Use when controlled.

Type
onValueChangefunction—
Description

Event handler called when the value of the listbox changes.

Type
highlightItemOnHoverbooleantrue
Description

Whether moving the pointer over an item highlights it. While focus is in the listbox, the item also receives focus. The pointer never takes focus from outside the listbox.

Type
Default
true
isItemEqualToValuefunction—
Description

Custom comparison logic used to determine if a listbox item value matches the current selected value. Defaults to Object.is comparison.

Type
itemToStringLabelfunction—
Description

When the item values are objects (<Listbox.Item value={object}>), this function converts the object value to a string representation for typeahead. If the shape of the object is { value, label }, the label will be used automatically without needing to specify this prop.

Type
itemsValue[]—
Name
Description

The items in the list, including those that aren’t rendered. Pass them when the list is virtualized, and use each item as its Listbox.Item value. Keyboard navigation, typeahead and selection can then reach items that aren’t rendered.

Type
multipleboolean | 'opt-in'false
Description

Whether multiple items can be selected, and how selecting an item affects the current selection.

  • false: only one item can be selected.
  • true: each item is toggled independently.
  • 'opt-in': selecting an item moves the current selection to it, and users hold a modifier key to select more than one item. On touch devices, where there are no modifier keys, it behaves like true.
Type
Default
false
onItemHighlightedfunction—
Description

Callback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or undefined if no item is highlighted) and event details with a reason property describing why the highlight changed. The reason can be:

  • 'keyboard': the highlight changed due to keyboard navigation or typeahead.
  • 'pointer': the highlight changed due to pointer hovering. The event may be a MouseEvent rather than a PointerEvent.
  • 'none': the highlight changed for another reason, such as an item receiving or losing focus.

With items, the highlighted item may not be rendered yet, so scroll it into view.

Type
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
orientation'vertical' | 'horizontal''vertical'
Description

The orientation of the listbox for keyboard navigation.

Type
Default
'vertical'
childrenReact.ReactNode—
Type

Listbox.Root.PropsHide

Re-Export of Root props as ListboxRootProps

Listbox.Root.StateHide

Listbox.Root.ChangeEventReasonHide

Listbox.Root.ChangeEventDetailsHide

Listbox.Root.HighlightEventReasonHide

Listbox.Root.HighlightEventDetailsHide

Label

An accessible label that is automatically associated with the listbox. Renders a <div> element.

classNamestring | function—
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 ReactElement or a function that returns the element to render.

Type

Listbox.Label.PropsHide

Re-Export of Label props as ListboxLabelProps

Listbox.Label.StateHide

List

A container for the listbox items. Renders a <div> element.

classNamestring | function—
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 ReactElement or 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.PropsHide

Re-Export of List props as ListboxListProps

Listbox.List.StateHide

Item

An individual option in the listbox. Renders a <div> element.

labelstring—
Name
Description

Overrides the text used for keyboard text navigation. Falls back to the rendered text when not provided.

Type
valueanynull
Name
Description

A unique value that identifies this listbox item.

Type
Default
null
nativeButtonbooleanfalse
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.

Type
Default
false
disabledbooleanfalse
Description

Whether the component should ignore user interaction.

Type
Default
false
childrenReact.ReactNode—
Type
classNamestring | function—
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 ReactElement or 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-disabled

Present when the listbox item is disabled.

Attribute
Description
data-selected

Present when the listbox item is selected.

data-highlighted

Present when the listbox item is highlighted.

data-disabled

Present when the listbox item is disabled.

Listbox.Item.PropsHide

Re-Export of Item props as ListboxItemProps

Listbox.Item.StateHide

ItemIndicator

Indicates whether the listbox item is selected. Renders a <span> element.

childrenReact.ReactNode—
Type
classNamestring | function—
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—
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 ReactElement or a function that returns the element to render.

Type

Listbox.ItemIndicator.PropsHide

Re-Export of ItemIndicator props as ListboxItemIndicatorProps

Listbox.ItemIndicator.StateHide

Group

Groups related listbox items with the corresponding label. Renders a <div> element.

classNamestring | function—
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 ReactElement or a function that returns the element to render.

Type

Listbox.Group.PropsHide

Re-Export of Group props as ListboxGroupProps

Listbox.Group.StateHide

GroupLabel

An accessible label that is automatically associated with its parent group. Renders a <div> element.

classNamestring | function—
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 ReactElement or a function that returns the element to render.

Type

Listbox.GroupLabel.PropsHide

Re-Export of GroupLabel props as ListboxGroupLabelProps

Listbox.GroupLabel.StateHide