Skip to Content
Documentation
Getting startedComponentsChartsTheming
Get Pro
Overview
Concepts

Listbox

Used to display a list of options for selection.

Recipe
Select framework
React.js
Vue.js
Angular
Svelte

Anatomy

import { Listbox } from '@chakra-ui/react'
<Listbox.Root>
  <Listbox.Label />
  <Listbox.Content>
    <Listbox.Item>
      <Listbox.ItemText />
      <Listbox.ItemIndicator />
    </Listbox.Item>
  </Listbox.Content>
</Listbox.Root>

To set up the listbox, use createListCollection to create a static collection, or the useListCollection hook when the list needs to be filtered or mutated at runtime.

Examples

Basic

Pass a collection to Listbox.Root and map over collection.items to render each option.

Select framework
React.js
Vue.js
Angular
Svelte

Controlled

Control the listbox value externally using the value and onValueChange props for custom state management.

Select framework
React.js
Vue.js
Angular
Svelte
Selected: []

Multiple Selection

Set the selectionMode prop to "multiple" to let users select more than one item, useful for scenarios like choosing tags, categories or preferences.

Select frameworks (multiple)
React.js
Vue.js
Angular
Svelte
Next.js
Nuxt.js

Grouped

Pass a groupBy function to the collection and render Listbox.ItemGroup to organize related options under clear section headers.

Select media
Naruto
One Piece
Dragon Ball
The Shawshank Redemption
The Godfather
The Dark Knight

With Icon

Add icons to listbox items to provide visual context and improve recognition of different options.

Select framework
React.js
Vue.js
Angular
Svelte

With Description

Include additional descriptive text for each item to provide more context and help users make informed choices.

Select framework
React.js

A JavaScript library for building user interfaces

Vue.js

The progressive JavaScript framework

Angular

Platform for building mobile and desktop web applications

Svelte

Cybernetically enhanced web apps

Next.js

The React framework for production

With Input

Render Listbox.Input and filter the collection as the user types to make it easy to find specific items in long lists. Use Listbox.Empty to render a fallback when nothing matches.

Select Framework
React.js
Vue.js
Angular
Svelte
Next.js
Nuxt.js
Remix
Gatsby
Ember.js
Preact

With Popover

Use the listbox within a popover to create dropdown-like selection menus that overlay other content without taking up permanent screen space.

Props

Root

PropDefaultType
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
boolean

Whether to loop the keyboard navigation through the options

orientation '\'vertical\''
'horizontal' | 'vertical'

The orientation of the listbox.

selectionMode '\'single\''
SelectionMode

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.

colorPalette 'gray'
'base' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'sidebar' | 'sidebar.accent' | 'interaction' | 'accent' | 'presence' | 'status' | 'slate'

The color palette of the component

variant 'subtle'
'subtle' | 'solid' | 'plain'

The variant of the component

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
defaultHighlightedValue
string

The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the listbox.

deselectable
boolean

Whether to disallow empty selection

disabled
boolean

Whether the listbox is disabled

disallowSelectAll
boolean

Whether to disallow selecting all items when `meta+a` is pressed

highlightedValue
string

The controlled key of the highlighted item

id
string

The 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>) => void

The callback fired when the highlighted item changes.

onSelect
(details: SelectionDetails) => void

Function called when an item is selected

onValueChange
(details: ValueChangeDetails<T>) => void

The callback fired when the selected item changes.

scrollToIndexFn
(details: ScrollToIndexDetails) => void

Function to scroll to a specific index

selectOnHighlight
boolean

Whether to select the item when it is highlighted

typeahead
boolean

Whether to enable typeahead on the listbox

value
string[]

The controlled keys of the selected items

Label

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Input

PropDefaultType
autoHighlight false
boolean

Whether to automatically highlight the item when typing

keyboardPriority '\'caret\''
'caret' | 'navigate'

Determines how keyboard conflicts in the input are resolved. - "caret": keep native text-editing behavior - "navigate": forward supported keys to listbox navigation

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Content

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Item

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
highlightOnHover
boolean

Whether to highlight the item on hover

item
any

The item to render

ItemText

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

ItemIndicator

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

ItemGroup

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

ItemGroupLabel

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.