Listbox
Used to display a list of options for selection.
Usage
import { Listbox } from "@chakra-ui/react"<Listbox.Root>
<Listbox.Label />
<Listbox.Content>
<Listbox.Item>
<Listbox.ItemText />
<Listbox.ItemIndicator />
</Listbox.Item>
</Listbox.Content>
</Listbox.Root>Examples
Controlled
Control the listbox value externally using the value and onValueChange props
for custom state management.
Selected: []With Store
An alternative way to control the listbox is to use the RootProvider component
and the useListbox store hook.
This way you can access the listbox state and methods from outside the listbox.
Use RootProvider + useListbox or Root, not both.
Selected: []Disabled Item
Disable specific items in the listbox to indicate unavailable options while keeping them visible for context.
Grouped
Use item groups to organize related options with clear section headers, making it easier for users to find specific categories of items.
Horizontal
Display listbox items in a horizontal layout with card-based presentation, perfect for media galleries or visual selection interfaces.
Euphoric Echoes
Luna Solstice
Neon Dreamscape
Electra Skyline
Cosmic Serenade
Orion's Symphony
Melancholy Melodies
Violet Mistral
Rhythmic Illusions
Mirage Beats
Multiple Selection
Enable users to select multiple items from the list, useful for scenarios like choosing tags, categories, or preferences.
Select All
Provide convenient "Select All" and "Select None" controls for multiple selection scenarios, with visual indicators showing selection state.
Extended Select
Use extended selection mode to allow users to select multiple items using keyboard shortcuts like Cmd/Ctrl for advanced selection patterns.
With Checkmark
Display custom checkmarks for multiple selection scenarios, providing clear visual feedback for selected items.
With Icon
Add icons to listbox items to provide visual context and improve recognition of different options.
With Description
Include additional descriptive text for each item to provide more context and help users make informed choices.
A JavaScript library for building user interfaces
The progressive JavaScript framework
Platform for building mobile and desktop web applications
Cybernetically enhanced web apps
The React framework for production
With Input
Combine a search input with the listbox to filter options dynamically, making it easy to find specific items in long lists.
With Popover
Use the listbox within a popover to create dropdown-like selection menus that overlay other content without taking up permanent screen space.
With Dialog
Present the listbox in a modal dialog for focused selection experiences, particularly useful for important choices that need user attention.
Virtualized
Handle large datasets efficiently with virtualization, rendering only visible items to maintain smooth scrolling performance even with thousands of items.
Image Explorer
Create an interactive gallery where the listbox acts as navigation for displaying different images or media content.
Mountain Landscape
Scenic mountain view
Transfer List
Create a dual-listbox interface for moving items between available and selected states, commonly used for permission management or item selection workflows.
Emoji Grid
Display emojis in a grid layout with filtering capability, perfect for emoji pickers or icon selection interfaces.
Props
Root
| Prop | Default | Type |
|---|---|---|
collection * | ListCollection<T>The collection of items | |
defaultValue | [] | string[]The initial default value of the listbox when rendered. Use when you don't need to control the value of the listbox. |
loopFocus | false | booleanWhether to loop the keyboard navigation through the options |
orientation | 'vertical' | 'horizontal' | 'vertical'The orientation of the listbox. |
selectionMode | 'single' | SelectionModeHow 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. |
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'The color palette of the component |
variant | subtle | 'subtle' | 'solid' | 'plain'The variant of the component |
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
unstyled | booleanWhether to remove the component's style. | |
defaultHighlightedValue | stringThe initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox. | |
deselectable | booleanWhether to disallow empty selection | |
disabled | booleanWhether the listbox is disabled | |
disallowSelectAll | booleanWhether to disallow selecting all items when `meta+a` is pressed | |
highlightedValue | stringThe controlled key of the highlighted item | |
id | stringThe unique identifier of the machine. | |
ids | Partial<{
root: string
content: string
label: string
item: (id: string | number) => string
itemGroup: (id: string | number) => string
itemGroupLabel: (id: string | number) => string
}>The ids of the elements in the listbox. Useful for composition. | |
onHighlightChange | (details: HighlightChangeDetails<T>) => voidThe callback fired when the highlighted item changes. | |
onSelect | (details: SelectionDetails) => voidFunction called when an item is selected | |
onValueChange | (details: ValueChangeDetails<T>) => voidThe callback fired when the selected item changes. | |
scrollToIndexFn | (details: ScrollToIndexDetails) => voidFunction to scroll to a specific index | |
selectOnHighlight | booleanWhether to select the item when it is highlighted | |
typeahead | booleanWhether to enable typeahead on the listbox | |
value | string[]The controlled keys of the selected items |
Label
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Content
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Item
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
highlightOnHover | booleanWhether to highlight the item on hover | |
item | anyThe item to render |
ItemText
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
ItemIndicator
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
ItemGroup
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
ItemGroupLabel
| Prop | Default | Type |
|---|---|---|
as | React.ElementTypeThe underlying element to render. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Explorer
Explore the Listbox component parts interactively. Click on parts in the
sidebar to highlight them in the preview.
Component Anatomy
Hover to highlight, click to select parts
label
input
item
itemText
itemIndicator
itemGroup
itemGroupLabel
content
root
valueText
empty