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.
- Avoid when not rendering an input: Use Select instead of Combobox if no input is being rendered, which includes accessibility features specific to a listbox without an input.
- Form controls must have an accessible name: It can be created using a
<label>element or theFieldcomponent. See Labeling a combobox and the forms guide.
Anatomy
Import the components and place them together:
import { Combobox } from '@base-ui/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>TypeScript
Combobox infers the item type from the defaultValue or value props passed to <Combobox.Root>.
The type of items held in the items array must also match the value prop type passed to <Combobox.Item>.
Examples
Typed wrapper component
The following example shows a typed wrapper around the Combobox component with correct type inference and type safety:
import * as React from 'react';
import { Combobox } from '@base-ui/react/combobox';
export function MyCombobox<Value, Multiple extends boolean | undefined = false>(
props: Combobox.Root.Props<Value, Multiple>,
): React.JSX.Element {
return <Combobox.Root {...props}>{/* ... */}</Combobox.Root>;
}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.
Use the Field component to provide a visible label for the combobox trigger:
<Field.Root>
<Field.Label nativeLabel={false} render={<div />}>
Favorite fruit
</Field.Label>
<Combobox.Root>{/* ... */}</Combobox.Root>
</Field.Root>Replace the rendered <label> element with a <div> element and add nativeLabel={false} so it does not inherit native label behaviors. This ensures clicking on the label will focus the combobox trigger without opening the associated popup to match native <select> behavior, and prevents CSS :hover from activating on the trigger when hovering over the label.
Grouped
Organize related options with <Combobox.Group> and <Combobox.GroupLabel> to add section headings inside the popup.
Groups are represented by an array of objects with an items property, which itself is an array of individual items for each group. An extra property, such as value, can be provided for the heading text when rendering the group label.
interface ProduceGroupItem {
value: string;
items: string[];
}
const groups: ProduceGroupItem[] = [
{
value: 'Fruits',
items: ['Apple', 'Banana', 'Orange'],
},
{
value: 'Vegetables',
items: ['Carrot', 'Lettuce', 'Spinach'],
},
];Async search (single)
Load items from a remote source by fetching on input changes. Keep the selected item in the items list so it remains available while new results stream in. This pattern avoids needing to load items upfront.
Async search (multiple)
Load items from a remote source by fetching on input changes while supporting multiple selections. Selected items remain available in the list while new matches stream in. This pattern avoids needing to load items upfront.
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.
API reference
Root
Groups all parts of the combobox. Doesn’t render its own HTML element.
namestring—
string- Name
- Description
Identifies the field when a form is submitted.
- Type
string | undefined
defaultValueUnion—
Union- Name
- Description
The uncontrolled selected value of the combobox when it’s initially rendered.
To render a controlled combobox, use the
valueprop instead.- Type
Value[] | Value | null | undefined
valueUnion—
Union- Name
- Description
The selected value of the combobox. Use when controlled.
- Type
Value[] | Value | null | undefined
onValueChangefunction—
function- Name
- Description
Event handler called when the selected value of the combobox changes.
- Type
| (( value: Value[] | Value | any | null, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
defaultInputValueUnion—
Union- Description
The uncontrolled input value when initially rendered.
To render a controlled input, use the
inputValueprop instead.- Type
string | number | string[] | undefined
inputValueUnion—
Union- Name
- Description
The input value of the combobox. Use when controlled.
- Type
string | number | string[] | undefined
onInputValueChangefunction—
function- Description
Event handler called when the input value changes.
- Type
| (( inputValue: string, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
defaultOpenbooleanfalse
boolean- Name
- Description
Whether the popup is initially open.
To render a controlled popup, use the
openprop instead.- Type
boolean | undefined- Default
false
openboolean—
boolean- Name
- Description
Whether the popup is currently open. Use when controlled.
- Type
boolean | undefined
onOpenChangefunction—
function- Name
- Description
Event handler called when the popup is opened or closed.
- Type
| (( open: boolean, eventDetails: Combobox.Root.ChangeEventDetails, ) => void) | undefined
autoHighlightbooleanfalse
boolean- Name
- Description
Whether the first matching item is highlighted automatically while filtering.
- Type
boolean | undefined- Default
false
highlightItemOnHoverbooleantrue
boolean- Description
Whether moving the pointer over items should highlight them. Disabling this prop allows CSS
:hoverto be differentiated from the:focus(data-highlighted) state.- Type
boolean | undefined- Default
true
actionsRef| React.RefObject<Combobox.Root.Actions
| null>—
| React.RefObject<Combobox.Root.Actions
| null>- Name
- Description
A ref to imperative actions.
unmount: When specified, the combobox will not be unmounted when closed. Instead, theunmountfunction 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 | null> | undefined
autoCompletestring—
string- Name
- Description
Provides a hint to the browser for autofill.
- Type
string | undefined
filterfunction—
function- Name
- Description
ComboboxFilter function used to match items vs input query.
- Type
((itemValue: Value, query: string, itemToString?: ((itemValue: Value) => string)) => boolean) | null | undefined
filteredItemsany[] | Group[]—
any[] | Group[]- Name
- Description
Filtered items to display in the list. When provided, the list will use these items instead of filtering the
itemsprop internally. Use when you want to control filtering logic externally with theuseFilter()hook.- Type
any[] | Group[] | undefined
gridbooleanfalse
boolean- 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
inlinebooleanfalse
boolean- Name
- Description
Whether the list is rendered inline without using the popup.
- Type
boolean | undefined- Default
false
isItemEqualToValuefunction—
function- 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.iscomparison.- Type
((itemValue: Value, selectedValue: Value) => boolean) | undefined
itemToStringLabelfunction—
function- 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: Value) => string) | undefined
itemToStringValuefunction—
function- 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: Value) => string) | undefined
itemsany[] | Group[]—
any[] | Group[]- 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
any[] | Group[] | undefined
limitnumber-1
number- Name
- Description
The maximum number of items to display in the list.
- Type
number | undefined- Default
-1
localeIntl.LocalesArgument—
Intl.LocalesArgument- Name
- Description
The locale to use for string comparison. Defaults to the user’s runtime locale.
- Type
Intl.LocalesArgument | undefined
loopFocusbooleantrue
boolean- Name
- Description
Whether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing ArrowDown again from the input, or the last item can be reached by pressing ArrowUp from the input. The input is always included in the focus loop per ARIA Authoring Practices. When disabled, focus does not move when on the last element and the user presses ArrowDown, or when on the first element and the user presses ArrowUp.
- Type
boolean | undefined- Default
true
modalbooleanfalse
boolean- 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
multiplebooleanfalse
boolean- Name
- Description
Whether multiple items can be selected.
- Type
boolean | undefined- Default
false
onItemHighlightedfunction—
function- Description
Callback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or
undefinedif no item is highlighted) and event details with areasonproperty describing why the highlight changed. Thereasoncan be:'keyboard': the highlight changed due to keyboard navigation.'pointer': the highlight changed due to pointer hovering.'none': the highlight changed programmatically.
- Type
| (( highlightedValue: Value | undefined, eventDetails: Combobox.Root.HighlightEventDetails, ) => void) | undefined
onOpenChangeCompletefunction—
function- Description
Event handler called after any animations complete when the popup is opened or closed.
- Type
((open: boolean) => void) | undefined
openOnInputClickbooleantrue
boolean- Name
- Description
Whether the popup opens when clicking the input.
- Type
boolean | undefined- Default
true
virtualizedbooleanfalse
boolean- Name
- Description
Whether the items are being externally virtualized.
- Type
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
readOnlybooleanfalse
boolean- Name
- Description
Whether the user should be unable to choose a different option from the popup.
- Type
boolean | undefined- Default
false
requiredbooleanfalse
boolean- Name
- Description
Whether the user must choose a value before submitting a form.
- Type
boolean | undefined- Default
false
inputRefReact.Ref<HTMLInputElement>—
React.Ref<HTMLInputElement>- Name
- Description
A ref to the hidden input element.
- Type
React.Ref<HTMLInputElement> | undefined
idstring—
string- Name
- Description
The id of the component.
- Type
string | undefined
childrenReact.ReactNode—
React.ReactNode- Name
- Type
React.ReactNode | undefined
Additional Types
Combobox.Root.Props
Re-Export of Root props as ComboboxRootProps
Combobox.Root.State
type ComboboxRootState = {};Combobox.Root.Actions
type ComboboxRootActions = { unmount: () => void };Combobox.Root.ChangeEventReason
type ComboboxRootChangeEventReason =
| 'trigger-press'
| 'outside-press'
| 'item-press'
| 'escape-key'
| 'list-navigation'
| 'focus-out'
| 'input-change'
| 'input-clear'
| 'clear-press'
| 'chip-remove-press'
| 'none';Combobox.Root.ChangeEventDetails
type ComboboxRootChangeEventDetails =
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'trigger-press';
event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'outside-press';
event: MouseEvent | PointerEvent | TouchEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'item-press';
event: MouseEvent | PointerEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'list-navigation';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'focus-out';
event: KeyboardEvent | FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'input-change';
event: Event | InputEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'input-clear';
event: Event | FocusEvent | InputEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'clear-press';
event: MouseEvent | PointerEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
}
| {
reason: 'chip-remove-press';
event: MouseEvent | PointerEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
};Combobox.Root.HighlightEventReason
type ComboboxRootHighlightEventReason = 'keyboard' | 'pointer' | 'none';Combobox.Root.HighlightEventDetails
type ComboboxRootHighlightEventDetails =
| BaseUIGenericEventDetail<'none', { index: number }>
| BaseUIGenericEventDetail<'keyboard', { index: number }>
| BaseUIGenericEventDetail<'pointer', { index: number }>;Value
The current value of the combobox. Doesn’t render its own HTML element.
placeholderReact.ReactNode—
React.ReactNode- Name
- Description
The placeholder value to display when no value is selected. This is overridden by
childrenif specified, or by a null item’s label initems.- Type
React.ReactNode | undefined
children| React.ReactNode
| ((selectedValue: any) => React.ReactNode)—
| React.ReactNode
| ((selectedValue: any) => React.ReactNode)- Name
- Type
React.ReactNode | ((selectedValue: any) => React.ReactNode) | undefined
Additional Types
Combobox.Value.Props
Re-Export of Value props as ComboboxValueProps
Combobox.Value.State
type ComboboxValueState = {};Icon
An icon that indicates that the trigger button opens the popup.
Renders a <span> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Icon.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Icon.State, ) => ReactElement) | undefined
Additional Types
Combobox.Icon.Props
Re-Export of Icon props as ComboboxIconProps
Combobox.Icon.State
type ComboboxIconState = {};Input
A text input to search for items in the list.
Renders an <input> element.
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Input.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Input.State, ) => ReactElement) | undefined
data-popup-open
data-popup-side
data-list-empty
data-pressed
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-filled
data-focused
Additional Types
Combobox.Input.Props
Re-Export of Input props as ComboboxInputProps
Combobox.Input.State
type ComboboxInputState = {
open: boolean;
popupSide:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start'
| null;
listEmpty: boolean;
readOnly: boolean;
disabled: boolean;
touched: boolean;
dirty: boolean;
valid: boolean | null;
filled: boolean;
focused: boolean;
}Clear
Clears the value when clicked.
Renders a <button> element.
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Clear.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether the component should remain mounted in the DOM when not visible.
- Type
boolean | undefined- Default
false
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Clear.State, ) => ReactElement) | undefined
Additional Types
Combobox.Clear.Props
Re-Export of Clear props as ComboboxClearProps
Combobox.Clear.State
type ComboboxClearState = { open: boolean; disabled: boolean; transitionStatus: TransitionStatus };Trigger
A button that opens the popup.
Renders a <button> element.
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Trigger.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Trigger.State, ) => ReactElement) | undefined
data-popup-open
data-popup-side
data-list-empty
data-pressed
data-disabled
data-readonly
data-required
data-valid
data-invalid
data-dirty
data-touched
data-filled
data-focused
data-placeholder
Additional Types
Combobox.Trigger.Props
Re-Export of Trigger props as ComboboxTriggerProps
Combobox.Trigger.State
type ComboboxTriggerState = {
open: boolean;
disabled: boolean;
popupSide:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start'
| null;
listEmpty: boolean;
placeholder: boolean;
touched: boolean;
dirty: boolean;
valid: boolean | null;
filled: boolean;
focused: boolean;
}Chips
A container for the chips in a multiselectable input.
Renders a <div> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Chips.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Chips.State, ) => ReactElement) | undefined
Additional Types
Combobox.Chips.Props
Re-Export of Chips props as ComboboxChipsProps
Combobox.Chips.State
type ComboboxChipsState = {};Chip
An individual chip that represents a value in a multiselectable input.
Renders a <div> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Chip.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Chip.State, ) => ReactElement) | undefined
Additional Types
Combobox.Chip.Props
Re-Export of Chip props as ComboboxChipProps
Combobox.Chip.State
type ComboboxChipState = { disabled: boolean };ChipRemove
A button to remove a chip.
Renders a <button> element.
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.ChipRemove.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.ChipRemove.State, ) => ReactElement) | undefined
Additional Types
Combobox.ChipRemove.Props
Re-Export of ChipRemove props as ComboboxChipRemoveProps
Combobox.ChipRemove.State
type ComboboxChipRemoveState = { disabled: boolean };List
A list container for the items.
Renders a <div> element.
children| React.ReactNode
| ((item: any, index: number) => React.ReactNode)—
| React.ReactNode
| ((item: any, index: number) => React.ReactNode)- Name
- Type
React.ReactNode | ((item: any, index: number) => React.ReactNode) | undefined
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.List.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.List.State, ) => ReactElement) | undefined
Additional Types
Combobox.List.Props
Re-Export of List props as ComboboxListProps
Combobox.List.State
type ComboboxListState = { empty: boolean };Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>.
Renders a <div> element.
containerUnion—
Union- Name
- Description
A parent element to render the portal element into.
- Type
| HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undefined
classNamestring | function—
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.Portal.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Portal.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
boolean | undefined- Default
false
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Portal.State, ) => ReactElement) | undefined
Additional Types
Combobox.Portal.Props
Re-Export of Portal props as ComboboxPortalProps
Combobox.Portal.State
type ComboboxPortalState = {};Backdrop
An overlay displayed beneath the popup.
Renders a <div> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Backdrop.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Backdrop.State, ) => ReactElement) | undefined
data-open
data-closed
data-starting-style
data-ending-style
Additional Types
Combobox.Backdrop.Props
Re-Export of Backdrop props as ComboboxBackdropProps
Combobox.Backdrop.State
type ComboboxBackdropState = { open: boolean; transitionStatus: TransitionStatus };Positioner
Positions the popup against the trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
boolean- Description
Whether to disable the popup from tracking any layout shift of its positioning anchor.
- Type
boolean | undefined- Default
false
alignAlign'center'
Align- Name
- Description
How to align the popup relative to the specified side.
- Type
'start' | 'center' | 'end' | undefined- Default
'center'
alignOffsetnumber | OffsetFunction0
number | OffsetFunction- 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
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.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: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; 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; }} />
sideSide'bottom'
Side- 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'
sideOffsetnumber | OffsetFunction0
number | OffsetFunction- 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
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.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: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; 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; }} />
arrowPaddingnumber5
number- 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
anchorUnion—
Union- Name
- Description
An element to position the popup against. By default, the popup will be positioned against the trigger.
- Type
| Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | undefined
collisionAvoidanceCollisionAvoidance—
CollisionAvoidance- Description
Determines how to handle collisions when positioning the popup.
- Type
CollisionAvoidance | undefined- Example
<Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} />
collisionBoundaryBoundary'clipping-ancestors'
Boundary- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
Boundary | undefined- Default
'clipping-ancestors'
collisionPaddingPadding5
Padding- Name
- Description
Additional space to maintain from the edge of the collision boundary.
- Type
Padding | undefined- Default
5
stickybooleanfalse
boolean- 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'absolute' | 'fixed''absolute'
'absolute' | 'fixed'- Name
- Description
Determines which CSS
positionproperty to use.- Type
'absolute' | 'fixed' | undefined- Default
'absolute'
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Positioner.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Positioner.State, ) => ReactElement) | undefined
data-open
data-closed
data-anchor-hidden
data-align
data-empty
data-side
--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.
Additional Types
Combobox.Positioner.Props
Re-Export of Positioner props as ComboboxPositionerProps
Combobox.Positioner.State
type ComboboxPositionerState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
anchorHidden: boolean;
empty: boolean;
}Popup
A container for the list.
Renders a <div> element.
initialFocusUnion—
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,trueto use the default behavior, orfalse/undefinedto do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( openType: 'mouse' | 'touch' | 'pen' | 'keyboard' | '', ) => boolean | void | HTMLElement | null) | undefined
finalFocusUnion—
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,trueto use the default behavior, orfalse/undefinedto do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( closeType: | 'mouse' | 'touch' | 'pen' | 'keyboard' | '', ) => boolean | void | HTMLElement | null) | undefined
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Popup.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Popup.State, ) => ReactElement) | undefined
data-open
data-closed
data-align
data-empty
data-instant
data-side
data-starting-style
data-ending-style
Additional Types
Combobox.Popup.Props
Re-Export of Popup props as ComboboxPopupProps
Combobox.Popup.State
type ComboboxPopupState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
anchorHidden: boolean;
transitionStatus: TransitionStatus;
empty: boolean;
}Arrow
Displays an element positioned against the anchor.
Renders a <div> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Arrow.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Arrow.State, ) => ReactElement) | undefined
data-open
data-closed
data-uncentered
data-align
data-side
Additional Types
Combobox.Arrow.Props
Re-Export of Arrow props as ComboboxArrowProps
Combobox.Arrow.State
type ComboboxArrowState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
uncentered: boolean;
}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.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Status.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Status.State, ) => ReactElement) | undefined
Additional Types
Combobox.Status.Props
Re-Export of Status props as ComboboxStatusProps
Combobox.Status.State
type ComboboxStatusState = {};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.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Empty.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Empty.State, ) => ReactElement) | undefined
Additional Types
Combobox.Empty.Props
Re-Export of Empty props as ComboboxEmptyProps
Combobox.Empty.State
type ComboboxEmptyState = {};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) => React.ReactNode)—
((item: any, index: number) => React.ReactNode)- Name
- Type
((item: any, index: number) => React.ReactNode)
Additional Types
Combobox.Collection.Props
Re-Export of Collection props as ComboboxCollectionProps
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.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Row.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Row.State, ) => ReactElement) | undefined
Additional Types
Combobox.Row.Props
Re-Export of Row props as ComboboxRowProps
Combobox.Row.State
type ComboboxRowState = {};Item
An individual item in the list.
Renders a <div> element.
valueanynull
any- Name
- Description
A unique value that identifies this item.
- Type
any | undefined- Default
null
onClickfunction—
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
Enterwith the keyboard if the item is highlighted when theInputorListelement has focus.- Type
| (( event: BaseUIEvent< React.MouseEvent<HTMLDivElement, MouseEvent> >, ) => void) | undefined
indexnumber—
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
nativeButtonbooleanfalse
boolean- 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
boolean | undefined- Default
false
disabledbooleanfalse
boolean- Name
- Description
Whether the component should ignore user interaction.
- Type
boolean | undefined- Default
false
childrenReact.ReactNode—
React.ReactNode- Name
- Type
React.ReactNode | undefined
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Item.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Item.State, ) => ReactElement) | undefined
data-selected
data-highlighted
data-disabled
Additional Types
Combobox.Item.Props
Re-Export of Item props as ComboboxItemProps
Combobox.Item.State
type ComboboxItemState = { disabled: boolean; selected: boolean; highlighted: boolean };ItemIndicator
Indicates whether the item is selected.
Renders a <span> element.
childrenReact.ReactNode—
React.ReactNode- Name
- Type
React.ReactNode | undefined
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.ItemIndicator.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the HTML element in the DOM when the item is not selected.
- Type
boolean | undefined- Default
false
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.ItemIndicator.State, ) => ReactElement) | undefined
Additional Types
Combobox.ItemIndicator.Props
Re-Export of ItemIndicator props as ComboboxItemIndicatorProps
Combobox.ItemIndicator.State
type ComboboxItemIndicatorState = { selected: boolean; transitionStatus: TransitionStatus };Group
Groups related items with the corresponding label.
Renders a <div> element.
itemsany[]—
any[]- Name
- Description
Items to be rendered within this group. When provided, child
Collectioncomponents will use these items.- Type
any[] | undefined
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.Group.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.Group.State, ) => ReactElement) | undefined
Additional Types
Combobox.Group.Props
Re-Export of Group props as ComboboxGroupProps
Combobox.Group.State
type ComboboxGroupState = {};GroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
classNamestring | function—
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 | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Combobox.GroupLabel.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Combobox.GroupLabel.State, ) => ReactElement) | undefined
Additional Types
Combobox.GroupLabel.Props
Re-Export of GroupLabel props as ComboboxGroupLabelProps
Combobox.GroupLabel.State
type ComboboxGroupLabelState = {};Separator
A separator element accessible to screen readers.
Renders a <div> element.
orientationOrientation'horizontal'
Orientation- Name
- Description
The orientation of the separator.
- Type
'horizontal' | 'vertical' | undefined- Default
'horizontal'
classNamestring | function—
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: SeparatorState) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: SeparatorState, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
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
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: SeparatorState, ) => ReactElement) | undefined
Additional Types
Combobox.Separator.Props
Re-Export of Separator props as ComboboxSeparatorProps
Combobox.Separator.State
type ComboboxSeparatorState = {
orientation: 'horizontal' | 'vertical';
}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>.
Parameters
options{ multiple?: boolean; value?: any; locale?: Intl.LocalesArgument }—
{ multiple?: boolean; value?: any; locale?: Intl.LocalesArgument }- Name
- Type
{ multiple?: boolean; value?: any; locale?: Intl.LocalesArgument } | undefined
Return value
containsfunction—
function- Name
- Type
((item: Item, query: string, itemToString?: ((item: Item) => string)) => boolean)
startsWithfunction—
function- Name
- Type
((item: Item, query: string, itemToString?: ((item: Item) => string)) => boolean)
endsWithfunction—
function- Name
- Type
((item: Item, query: string, itemToString?: ((item: Item) => string)) => boolean)
useFilteredItems
Returns the internally filtered items when called inside <Combobox.Root>.
Return value
T[]