Combobox
An input combined with a list of predefined items to select.
View as MarkdownUsage guidelines
- Combobox is a filterable Select: Use Combobox when the input is restricted to a set of predefined selectable items, similar to Select but whose items are filterable using an input. Prefer using Combobox over Select when the number of items is sufficiently large to warrant filtering.
- Avoid for simple search widgets: Combobox does not allow free-form text input. For search widgets, consider using Autocomplete instead.
Anatomy
Import the components and place them together:
import { Combobox } from '@base-ui-components/react/combobox';
<Combobox.Root>
<Combobox.Input />
<Combobox.Trigger />
<Combobox.Icon />
<Combobox.Clear />
<Combobox.Value />
<Combobox.Chips>
<Combobox.Chip>
<Combobox.ChipRemove />
</Combobox.Chip>
</Combobox.Chips>
<Combobox.Portal>
<Combobox.Backdrop />
<Combobox.Positioner>
<Combobox.Popup>
<Combobox.Arrow />
<Combobox.Status />
<Combobox.Empty />
<Combobox.List>
<Combobox.Row>
<Combobox.Item>
<Combobox.ItemIndicator />
</Combobox.Item>
</Combobox.Row>
<Combobox.Separator />
<Combobox.Group>
<Combobox.GroupLabel />
</Combobox.Group>
<Combobox.Collection />
</Combobox.List>
</Combobox.Popup>
</Combobox.Positioner>
</Combobox.Portal>
</Combobox.Root>
API reference
Root
Groups all parts of the combobox. Doesn't render its own HTML element.
name
string
—
name
string
—
- Name
- Description
Identifies the field when a form is submitted.
- Type
string | undefined
defaultValue
Union
—
defaultValue
Union
—
- Name
- Description
The uncontrolled selected value of the combobox when it's initially rendered.
To render a controlled combobox, use the
value
prop instead.- Type
SelectedValue[] | SelectedValue | null | undefined
value
Union
—
value
Union
—
- Name
- Description
The selected value of the combobox. Use when controlled.
- Type
SelectedValue[] | SelectedValue | undefined
onValueChange
function
—
onValueChange
function
—
- Name
- Description
Callback fired when the selected value of the combobox changes.
- Type
| (( value: SelectedValue[] | SelectedValue, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
defaultOpen
boolean
false
defaultOpen
boolean
false
- Name
- Description
Whether the popup is initially open.
To render a controlled popup, use the
open
prop instead.- Type
boolean | undefined
- Default
false
open
boolean
—
open
boolean
—
- Name
- Description
Whether the popup is currently open. Use when controlled.
- Type
boolean | undefined
onOpenChange
function
—
onOpenChange
function
—
- Name
- Description
Event handler called when the popup is opened or closed.
- Type
| (( open: boolean, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
actionsRef
RefObject<Combobox.Root.Actions>
—
actionsRef
RefObject<Combobox.Root.Actions>
—
- Name
- Description
A ref to imperative actions.
unmount
: When specified, the combobox will not be unmounted when closed. Instead, theunmount
function must be called to unmount the combobox manually. Useful when the combobox's animation is controlled by an external library.
- Type
| React.RefObject<Combobox.Root.Actions> | undefined
autoHighlight
boolean
false
autoHighlight
boolean
false
- Name
- Description
Whether to automatically highlight the first item while filtering.
- Type
boolean | undefined
- Default
false
defaultInputValue
Union
—
defaultInputValue
Union
—
- Description
The uncontrolled input value when initially rendered.
To render a controlled input, use the
inputValue
prop instead.- Type
string | number | string[] | undefined
filter
Union
—
filter
Union
—
- Name
- Description
Filter function used to match items vs input query. The
itemToStringLabel
function is provided to help convert items to strings for comparison.- Type
| (( itemValue: any, query: string, itemToStringLabel: | ((itemValue: any) => string) | undefined, ) => boolean) | null | undefined
grid
boolean
false
grid
boolean
false
- Name
- Description
Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.
- Type
boolean | undefined
- Default
false
inputValue
Union
—
inputValue
Union
—
- Name
- Description
The input value of the combobox. Use when controlled.
- Type
string | number | string[] | undefined
isItemEqualToValue
Union
—
isItemEqualToValue
Union
—
- Description
Custom comparison logic used to determine if a combobox item value matches the current selected value. Useful when item values are objects without matching referentially. Defaults to
Object.is
comparison.- Type
| (( itemValue: SelectedValue, selectedValue: SelectedValue, ) => boolean) | (( itemValue: ItemValue, selectedValue: ItemValue, ) => boolean) | undefined
itemToStringLabel
Union
—
itemToStringLabel
Union
—
- Description
When the item values are objects (
<Combobox.Item value={object}>
), this function converts the object value to a string representation for display in the input. If the shape of the object is{ value, label }
, the label will be used automatically without needing to specify this prop.- Type
| ((itemValue: SelectedValue) => string) | ((itemValue: ItemValue) => string) | undefined
itemToStringValue
Union
—
itemToStringValue
Union
—
- Description
When the item values are objects (
<Combobox.Item value={object}>
), this function converts the object value to a string representation for form submission. If the shape of the object is{ value, label }
, the value will be used automatically without needing to specify this prop.- Type
| ((itemValue: SelectedValue) => string) | ((itemValue: ItemValue) => string) | undefined
items
Union
—
items
Union
—
- Name
- Description
The items to be displayed in the list. Can be either a flat array of items or an array of groups with items.
- Type
ItemValue[] | Group<ItemValue>[] | undefined
limit
number
-1
limit
number
-1
- Name
- Description
The maximum number of items to display in the list.
- Type
number | undefined
- Default
-1
locale
Intl.LocalesArgument
—
locale
Intl.LocalesArgument
—
- Name
- Description
The locale to use for string comparison. Defaults to the user's runtime locale.
- Type
Intl.LocalesArgument | undefined
modal
boolean
false
modal
boolean
false
- Name
- Description
Determines if the popup enters a modal state when open.
true
: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled.false
: user interaction with the rest of the document is allowed.
- Type
boolean | undefined
- Default
false
multiple
boolean | undefined
false
multiple
boolean | undefined
false
- Name
- Description
Whether multiple items can be selected.
- Type
boolean | undefined
- Default
false
onInputValueChange
function
—
onInputValueChange
function
—
- Description
Callback fired when the input value of the combobox changes.
- Type
| (( value: string, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
onItemHighlighted
function
—
onItemHighlighted
function
—
- Description
Callback fired when the user navigates the list and highlights an item. Receives the highlighted item value (or
undefined
when no highlight is present), and event details describing the navigation reason and highlighted index.- Type
| (( itemValue: any, eventDetails: Combobox.Root.HighlightEventDetails, ) => void) | undefined
onOpenChangeComplete
function
—
onOpenChangeComplete
function
—
- Description
Event handler called after any animations complete when the popup is opened or closed.
- Type
((open: boolean) => void) | undefined
openOnInputClick
boolean
true
openOnInputClick
boolean
true
- Name
- Description
Whether the popup opens when clicking the input.
- Type
boolean | undefined
- Default
true
virtualized
boolean
false
virtualized
boolean
false
- Name
- Description
Whether the items are being externally virtualized.
- Type
boolean | undefined
- Default
false
disabled
boolean
false
disabled
boolean
false
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined
- Default
false
readOnly
boolean
false
readOnly
boolean
false
- Name
- Description
Whether the user should be unable to choose a different option from the popup.
- Type
boolean | undefined
- Default
false
required
boolean
false
required
boolean
false
- Name
- Description
Whether the user must choose a value before submitting a form.
- Type
boolean | undefined
- Default
false
inputRef
Ref<HTMLInputElement>
—
inputRef
Ref<HTMLInputElement>
—
- Name
- Description
A ref to the hidden input element.
- Type
React.Ref<HTMLInputElement> | undefined
id
string
—
id
string
—
- Name
- Description
The id of the component.
- Type
string | undefined
children
ReactNode
—
children
ReactNode
—
- Name
- Type
React.ReactNode | undefined
Value
The current value of the combobox. Doesn't render its own HTML element.
children
ReactNode | ((selectedValue: any) => ReactNode)
—
children
ReactNode | ((selectedValue: any) => ReactNode)
—
- Name
- Type
| React.ReactNode | ((selectedValue: any) => ReactNode)
Icon
An icon that indicates that the trigger button opens the popup.
Renders a <span>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Icon.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Icon.State, ) => ReactElement)
Input
A text input to search for items in the list.
Renders an <input>
element.
disabled
boolean
false
disabled
boolean
false
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined
- Default
false
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Input.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Input.State, ) => ReactElement)
data-popup-open
Present when the corresponding popup is open.
data-pressed
Present when the input is pressed.
data-disabled
Present when the component is disabled.
data-readonly
Present when the component is readonly.
data-required
Present when the component is required.
data-valid
Present when the component is in valid state (when wrapped in Field.Root).
data-invalid
Present when the component is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the component's value has changed (when wrapped in Field.Root).
data-touched
Present when the component has been touched (when wrapped in Field.Root).
data-filled
Present when the component has a value (when wrapped in Field.Root).
data-focused
Present when the input is focused (when wrapped in Field.Root).
Clear
Clears the value when clicked.
Renders a <button>
element.
nativeButton
boolean
true
nativeButton
boolean
true
- Name
- Description
Whether the component renders a native
<button>
element when replacing it via therender
prop. Set tofalse
if the rendered element is not a button (e.g.<div>
).- Type
boolean | undefined
- Default
true
disabled
boolean
false
disabled
boolean
false
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined
- Default
false
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Clear.State) => string)
keepMounted
boolean
false
keepMounted
boolean
false
- Name
- Description
Whether the component should remain mounted in the DOM when not visible.
- Type
boolean | undefined
- Default
false
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Clear.State, ) => ReactElement)
data-popup-open
Present when the corresponding popup is open.
data-disabled
Present when the button is disabled.
data-starting-style
Present when the button is animating in.
data-ending-style
Present when the button is animating out.
Trigger
A button that opens the popup.
Renders a <button>
element.
nativeButton
boolean
true
nativeButton
boolean
true
- Name
- Description
Whether the component renders a native
<button>
element when replacing it via therender
prop. Set tofalse
if the rendered element is not a button (e.g.<div>
).- Type
boolean | undefined
- Default
true
disabled
boolean
false
disabled
boolean
false
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined
- Default
false
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.Trigger.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Trigger.State, ) => ReactElement)
data-popup-open
Present when the corresponding popup is open.
data-pressed
Present when the trigger is pressed.
data-disabled
Present when the component is disabled.
data-readonly
Present when the component is readonly.
data-required
Present when the component is required.
data-valid
Present when the component is in valid state (when wrapped in Field.Root).
data-invalid
Present when the component is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the component's value has changed (when wrapped in Field.Root).
data-touched
Present when the component has been touched (when wrapped in Field.Root).
data-filled
Present when the component has a value (when wrapped in Field.Root).
data-focused
Present when the trigger is focused (when wrapped in Field.Root).
Chips
A container for the chips in a multiselectable input.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Chips.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Chips.State, ) => ReactElement)
Chip
An individual chip that represents a value in a multiselectable input.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Chip.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Chip.State, ) => ReactElement)
ChipRemove
A button to remove a chip.
Renders a <button>
element.
nativeButton
boolean
true
nativeButton
boolean
true
- Name
- Description
Whether the component renders a native
<button>
element when replacing it via therender
prop. Set tofalse
if the rendered element is not a button (e.g.<div>
).- Type
boolean | undefined
- Default
true
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.ChipRemove.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.ChipRemove.State, ) => ReactElement)
List
A list container for the items.
Renders a <div>
element.
children
ReactNode | ((item: any, index: number) => ReactNode)
—
children
ReactNode | ((item: any, index: number) => ReactNode)
—
- Name
- Type
| React.ReactNode | ((item: any, index: number) => ReactNode)
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.List.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.List.State, ) => ReactElement)
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>
.
container
Union
—
container
Union
—
- Name
- Description
A parent element to render the portal element into.
- Type
| HTMLElement | React.RefObject<HTMLElement | null> | null | undefined
children
ReactNode
—
children
ReactNode
—
- Name
- Type
React.ReactNode
keepMounted
boolean
false
keepMounted
boolean
false
- Name
- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
boolean | undefined
- Default
false
Backdrop
An overlay displayed beneath the popup.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.Backdrop.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Backdrop.State, ) => ReactElement)
data-open
Present when the popup is open.
data-closed
Present when the popup is closed.
data-starting-style
Present when the popup is animating in.
data-ending-style
Present when the popup is animating out.
Positioner
Positions the popup against the trigger.
Renders a <div>
element.
collisionAvoidance
CollisionAvoidance
—
collisionAvoidance
CollisionAvoidance
—
- Description
Determines how to handle collisions when positioning the popup.
- Type
| { side?: 'none' | 'flip' align?: 'shift' | 'none' | 'flip' fallbackAxisSide?: 'none' | 'start' | 'end' } | { side?: 'shift' | 'none' align?: 'shift' | 'none' fallbackAxisSide?: 'none' | 'start' | 'end' } | undefined
- Example
<Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} />
align
Align
'center'
align
Align
'center'
- Name
- Description
How to align the popup relative to the specified side.
- Type
'center' | 'start' | 'end' | undefined
- Default
'center'
alignOffset
number | OffsetFunction
0
alignOffset
number | OffsetFunction
0
- Name
- Description
Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
data
object parameter with the following properties:data.anchor
: the dimensions of the anchor element with propertieswidth
andheight
.data.positioner
: the dimensions of the positioner element with propertieswidth
andheight
.data.side
: which side of the anchor element the positioner is aligned against.data.align
: how the positioner is aligned relative to the specified side.
- Type
| number | ((data: { side: Side align: Align anchor: { width: number; height: number } positioner: { width: number; height: number } }) => number) | undefined
- Default
0
- Example
<Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} />
side
Side
'bottom'
side
Side
'bottom'
- Name
- Description
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
- Type
| 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | undefined
- Default
'bottom'
sideOffset
number | OffsetFunction
0
sideOffset
number | OffsetFunction
0
- Name
- Description
Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
data
object parameter with the following properties:data.anchor
: the dimensions of the anchor element with propertieswidth
andheight
.data.positioner
: the dimensions of the positioner element with propertieswidth
andheight
.data.side
: which side of the anchor element the positioner is aligned against.data.align
: how the positioner is aligned relative to the specified side.
- Type
| number | ((data: { side: Side align: Align anchor: { width: number; height: number } positioner: { width: number; height: number } }) => number) | undefined
- Default
0
- Example
<Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} />
arrowPadding
number
5
arrowPadding
number
5
- Name
- Description
Minimum distance to maintain between the arrow and the edges of the popup.
Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
- Type
number | undefined
- Default
5
anchor
Union
—
anchor
Union
—
- Name
- Description
An element to position the popup against. By default, the popup will be positioned against the trigger.
- Type
| Element | React.RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | null | undefined
collisionBoundary
Boundary
'clipping-ancestors'
collisionBoundary
Boundary
'clipping-ancestors'
- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
| Element | 'clipping-ancestors' | Element[] | Rect | undefined
- Default
'clipping-ancestors'
collisionPadding
Padding
5
collisionPadding
Padding
5
- Name
- Description
Additional space to maintain from the edge of the collision boundary.
- Type
| { top?: number right?: number bottom?: number left?: number } | number | undefined
- Default
5
sticky
boolean
false
sticky
boolean
false
- Name
- Description
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.
- Type
boolean | undefined
- Default
false
positionMethod
'fixed' | 'absolute'
'absolute'
positionMethod
'fixed' | 'absolute'
'absolute'
- Name
- Description
Determines which CSS
position
property to use.- Type
'fixed' | 'absolute' | undefined
- Default
'absolute'
trackAnchor
boolean
true
trackAnchor
boolean
true
- Name
- Description
Whether the popup tracks any layout shift of its positioning anchor.
- Type
boolean | undefined
- Default
true
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.Positioner.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Positioner.State, ) => ReactElement)
data-open
Present when the popup is open.
data-closed
Present when the popup is closed.
data-anchor-hidden
Present when the anchor is hidden.
data-align
Indicates how the popup is aligned relative to specified side.
data-empty
Present when the items list is empty.
data-side
Indicates which side the popup is positioned relative to the trigger.
--anchor-height
The anchor's height.
--anchor-width
The anchor's width.
--available-height
The available height between the trigger and the edge of the viewport.
--available-width
The available width between the trigger and the edge of the viewport.
--transform-origin
The coordinates that this element is anchored to. Used for animations and transitions.
Popup
A container for the list.
Renders a <div>
element.
initialFocus
Union
—
initialFocus
Union
—
- Name
- Description
Determines the element to focus when the popup is opened.
false
: Do not move focus.true
: Move focus based on the default behavior (first tabbable element or popup).RefObject
: Move focus to the ref element.function
: Called with the interaction type (mouse
,touch
,pen
, orkeyboard
). Return an element to focus,true
to use the default behavior, orfalse
/undefined
to do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( openType: InteractionType, ) => boolean | void | HTMLElement | null) | undefined
finalFocus
Union
—
finalFocus
Union
—
- Name
- Description
Determines the element to focus when the popup is closed.
false
: Do not move focus.true
: Move focus based on the default behavior (trigger or previously focused element).RefObject
: Move focus to the ref element.function
: Called with the interaction type (mouse
,touch
,pen
, orkeyboard
). Return an element to focus,true
to use the default behavior, orfalse
/undefined
to do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( closeType: InteractionType, ) => boolean | void | HTMLElement | null) | undefined
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Popup.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Popup.State, ) => ReactElement)
data-open
Present when the popup is open.
data-closed
Present when the popup is closed.
data-align
Indicates how the popup is aligned relative to specified side.
data-empty
Present when the items list is empty.
data-instant
Present if animations should be instant.
data-side
Indicates which side the popup is positioned relative to the trigger.
data-starting-style
Present when the popup is animating in.
data-ending-style
Present when the popup is animating out.
Arrow
Displays an element positioned against the anchor.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Arrow.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Arrow.State, ) => ReactElement)
data-open
Present when the popup is open.
data-closed
Present when the popup is closed.
data-uncentered
Present when the arrow is uncentered.
data-anchor-hidden
Present when the anchor is hidden.
data-align
Indicates how the popup is aligned relative to specified side.
data-side
Indicates which side the popup is positioned relative to the trigger.
Status
Displays a status message whose content changes are announced politely to screen readers.
Useful for conveying the status of an asynchronously loaded list.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Status.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Status.State, ) => ReactElement)
Empty
Renders its children only when the list is empty.
Requires the items
prop on the root component.
Announces changes politely to screen readers.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Empty.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Empty.State, ) => ReactElement)
Collection
Renders filtered list items. Doesn't render its own HTML element.
If rendering a flat list, pass a function child to the List
component instead, which implicitly wraps it.
children*
((item: any, index: number) => ReactNode)
—
children*
((item: any, index: number) => ReactNode)
—
- Name
- Type
(item: any, index: number) => ReactNode
Row
Displays a single row of items in a grid list.
Enable grid
on the root component to turn the listbox into a grid.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Row.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Row.State, ) => ReactElement)
Item
An individual item in the list.
Renders a <div>
element.
value
any
null
value
any
null
- Name
- Description
A unique value that identifies this item.
- Type
any
- Default
null
onClick
function
—
onClick
function
—
- Name
- Description
An optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing
Enter
with the keyboard if the item is highlighted when theInput
orList
element has focus.- Type
React.MouseEventHandler<HTMLElement> | undefined
index
number
—
index
number
—
- Name
- Description
The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.
- Type
number | undefined
nativeButton
boolean
false
nativeButton
boolean
false
- Name
- Description
Whether the component renders a native
<button>
element when replacing it via therender
prop. Set totrue
if the rendered element is a native button.- Type
boolean | undefined
- Default
false
disabled
boolean
false
disabled
boolean
false
- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined
- Default
false
children
ReactNode
—
children
ReactNode
—
- Name
- Type
React.ReactNode
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Item.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Item.State, ) => ReactElement)
data-selected
Present when the item is selected.
data-highlighted
Present when the item is highlighted.
data-disabled
Present when the item is disabled.
ItemIndicator
Indicates whether the item is selected.
Renders a <span>
element.
children
ReactNode
—
children
ReactNode
—
- Name
- Type
React.ReactNode
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.ItemIndicator.State) => string)
keepMounted
boolean
false
keepMounted
boolean
false
- Name
- Description
Whether to keep the HTML element in the DOM when the item is not selected.
- Type
boolean | undefined
- Default
false
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.ItemIndicator.State, ) => ReactElement)
Group
Groups related items with the corresponding label.
Renders a <div>
element.
items
any[]
—
items
any[]
—
- Name
- Description
Items to be rendered within this group. When provided, child
Collection
components will use these items.- Type
any[] | undefined
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Combobox.Group.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.Group.State, ) => ReactElement)
GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div>
element.
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Combobox.GroupLabel.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Combobox.GroupLabel.State, ) => ReactElement)
Separator
A separator element accessible to screen readers.
Renders a <div>
element.
orientation
Orientation
'horizontal'
orientation
Orientation
'horizontal'
- Name
- Description
The orientation of the separator.
- Type
'horizontal' | 'vertical' | undefined
- Default
'horizontal'
className
string | function
—
className
string | function
—
- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
string | ((state: Separator.State) => string)
render
ReactElement | function
—
render
ReactElement | 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
| ReactElement | (( props: HTMLProps, state: Separator.State, ) => ReactElement)
useFilter
Matches items against a query using Intl.Collator
for robust string matching. This hook is used when externally filtering items. Pass the result to the filter
prop of Combobox.Root
.
Input parameters
Accepts all Intl.CollatorOptions
, plus the following options:
locale
Intl.LocalesArgument
—
locale
Intl.LocalesArgument
—
- Name
- Description
The locale to use for string comparison.
- Type
Intl.LocalesArgument
multiple
boolean
false
multiple
boolean
false
- Name
- Description
Whether the combobox is in multiple selection mode.
- Type
boolean
- Default
false
value
any
—
value
any
—
- Name
- Description
The current value of the combobox. For single selection, pass this so the selected item remains visible when the query is empty or matches the selection.
- Type
any
Return value
contains
(itemValue: any, query: string) => boolean
—
contains
(itemValue: any, query: string) => boolean
—
- Name
- Description
Returns whether the item matches the query anywhere.
- Type
(itemValue: any, query: string) => boolean
startsWith
(itemValue: any, query: string) => boolean
—
startsWith
(itemValue: any, query: string) => boolean
—
- Name
- Description
Returns whether the item starts with the query.
- Type
(itemValue: any, query: string) => boolean
endsWith
(itemValue: any, query: string) => boolean
—
endsWith
(itemValue: any, query: string) => boolean
—
- Name
- Description
Returns whether the item ends with the query.
- Type
(itemValue: any, query: string) => boolean
Examples
Multiple select
The combobox can allow multiple selections by adding the multiple
prop to Combobox.Root
. Selection chips are rendered with Combobox.Chip
inside the input that can be removed.
Input inside popup
Combobox.Input
can be rendered inside Combobox.Popup
to create a searchable select popup.
Creatable
Create a new item when the filter matches no items, opening a creation Dialog
.
Virtualized
Efficiently handle large datasets using a virtualization library like @tanstack/react-virtual
.