<Combobox.Root items={specialties}>
<Combobox.Input placeholder="Select a specialty" />
<Combobox.Content>
<Combobox.Empty>No specialty found.</Combobox.Empty>
<Combobox.List>
{(specialty: string) => (
<Combobox.Item key={specialty} value={specialty}>{specialty}</Combobox.Item>
)}
</Combobox.List>
</Combobox.Content>
</Combobox.Root>Combobox.List takes a render function rather than elements, so the filtering
stays inside the component instead of being something you reimplement.
Combobox.Chips, Combobox.Chip and Combobox.ChipsInput turn it into a
multi-select whose picks appear as chips in the field.
API
Combobox.Root
| Prop | Type | Default | |
|---|---|---|---|
actionsRef | RefObject<Actions | null> | — | A ref to imperative actions. |
autoComplete | string | — | Provides a hint to the browser for autofill. |
autoHighlight | boolean | — | Whether the first matching item is highlighted automatically while filtering. |
children | ReactNode | — | |
defaultInputValue | string | number | readonly string[] | — | The uncontrolled input value when initially rendered. To render a controlled input, use the inputValue prop instead. |
defaultOpen | boolean | — | Whether the popup is initially open. To render a controlled popup, use the open prop instead. |
defaultValue | ComboboxValueType<Value, Multiple> | null | — | The uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the value prop instead. |
disabled | boolean | — | Whether the component should ignore user interaction. |
filter | ((itemValue: Value, query: string, itemToString?: ((itemValue: Value) => string) | undefined) => boolean) | null | — | Filter function used to match items vs input query. |
filteredItems | readonly any[] | readonly Group<any>[] | — | Filtered items to display in the list.
When provided, the list will use these items instead of filtering the items prop internally.
Use when you want to control filtering logic externally with the useFilter() hook. |
form | string | — | Identifies the form that owns the internal input. Useful when the combobox is rendered outside the form. |
grid | boolean | — | Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows. |
highlightItemOnHover | boolean | — | Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state. |
id | string | — | The id of the component. |
inline | boolean | — | Whether the list is rendered inline without using the component's own popup. Specify open unconditionally in conjunction with this prop so the list is considered
visible: <Combobox.Root inline open> In a Combobox.Root > Dialog.Root composition, bind the Combobox's open and
onOpenChange props to the Dialog's open and onOpenChange state instead so the
component resets its transient state (filter query, highlighted item, and input value) when
the dialog closes. |
inputRef | Ref<HTMLInputElement> | — | A ref to the hidden input element. |
inputValue | string | number | readonly string[] | — | The input value of the combobox. Use when controlled. |
isItemEqualToValue | ((itemValue: Value, value: Value) => boolean) | — | 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. |
items | readonly any[] | readonly Group<any>[] | — | The items to be displayed in the list. Can be either a flat array of items or an array of groups with items. |
itemToStringLabel | ((itemValue: Value) => string) | — | 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. |
itemToStringValue | ((itemValue: Value) => string) | — | 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. |
limit | number | — | The maximum number of items to display in the list. |
locale | LocalesArgument | — | The locale to use for string comparison. Defaults to the user's runtime locale. |
loopFocus | boolean | — | 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. |
modal | boolean | — | Determines if the popup enters a modal state when open. |
multiple | Multiple | — | Whether multiple items can be selected. |
name | string | — | Identifies the field when a form is submitted. |
onInputValueChange | ((inputValue: string, eventDetails: ChangeEventDetails) => void) | — | Event handler called when the input value changes. |
onItemHighlighted | ((highlightedValue: Value | undefined, eventDetails: HighlightEventDetails) => void) | — | Callback fired when an item is highlighted or unhighlighted.
Receives the highlighted item value (or undefined if no item is highlighted) and event details with a reason property describing why the highlight changed.
The reason can be: |
onOpenChange | ((open: boolean, eventDetails: ChangeEventDetails) => void) | — | Event handler called when the popup is opened or closed. |
onOpenChangeComplete | ((open: boolean) => void) | — | Event handler called after any animations complete when the popup is opened or closed. |
onValueChange | ((value: ComboboxValueType<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: ChangeEventDetails) => void) | — | Event handler called when the selected value of the combobox changes. |
open | boolean | — | Whether the popup is currently open. Use when controlled. |
openOnInputClick | boolean | — | Whether the popup opens when clicking the input. |
readOnly | boolean | — | Whether the user should be unable to choose a different option from the popup. |
required | boolean | — | Whether the user must choose a value before submitting a form. |
value | ComboboxValueType<Value, Multiple> | null | — | The selected value of the combobox. Use when controlled. |
virtualized | boolean | — | Whether the items are being externally virtualized. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-root.tsx.
Combobox.Chip
| Prop | Type | Default | |
|---|---|---|---|
showRemove | boolean | true | |
className | string | ((state: ComboboxChipState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxChipState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxChipState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-chip.tsx.
Combobox.Chips
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxChipsState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxChipsState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxChipsState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-chips.tsx.
Combobox.ChipsInput
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxInputState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
render | ComponentRenderFn<HTMLProps, ComboboxInputState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxInputState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-chips-input.tsx.
Combobox.Collection
| Prop | Type | Default | |
|---|---|---|---|
children | (item: any, index: number) => ReactNode | required |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-collection.tsx.
Combobox.Content
| Prop | Type | Default | |
|---|---|---|---|
align | Align | "start" | How to align the popup relative to the specified side. |
alignOffset | number | OffsetFunction | 0 | 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: |
anchor | Element | RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | null | — | An element to position the popup against. By default, the popup will be positioned against the trigger. |
className | string | ((state: ComboboxPopupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
finalFocus | boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | — | Determines the element to focus when the popup is closed. |
initialFocus | boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | — | Determines the element to focus when the popup is opened. |
render | ComponentRenderFn<HTMLProps, ComboboxPopupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
side | Side | "bottom" | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
sideOffset | number | OffsetFunction | 6 | 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: |
style | CSSProperties | ((state: ComboboxPopupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-content.tsx.
Combobox.Empty
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxEmptyState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxEmptyState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxEmptyState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-empty.tsx.
Combobox.Group
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxGroupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
items | readonly any[] | — | Items to be rendered within this group.
When provided, child Collection components will use these items. |
render | ComponentRenderFn<HTMLProps, ComboboxGroupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxGroupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-group.tsx.
Combobox.Input
| Prop | Type | Default | |
|---|---|---|---|
showClear | boolean | false | |
showTrigger | boolean | true | |
className | string | ((state: ComboboxInputState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | false | Whether the component should ignore user interaction. |
render | ComponentRenderFn<HTMLProps, ComboboxInputState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxInputState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-input.tsx.
Combobox.Item
| Prop | Type | Default | |
|---|---|---|---|
children | ReactNode | — | |
className | string | ((state: ComboboxItemState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
index | number | — | The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
onClick | ((event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void) | — | 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 the Input or List element has focus. |
render | ComponentRenderFn<HTMLProps, ComboboxItemState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxItemState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
value | any | — | A unique value that identifies this item. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-item.tsx.
Combobox.Label
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxGroupLabelState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxGroupLabelState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-label.tsx.
Combobox.List
| Prop | Type | Default | |
|---|---|---|---|
children | ((item: any, index: number) => ReactNode) | ReactNode | — | |
className | string | ((state: ComboboxListState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxListState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxListState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-list.tsx.
Combobox.Row
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxRowState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, ComboboxRowState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxRowState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-row.tsx.
Combobox.Separator
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SeparatorState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
orientation | Orientation | — | The orientation of the separator. |
render | ComponentRenderFn<HTMLProps, SeparatorState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: SeparatorState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-separator.tsx.
Combobox.Trigger
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: ComboboxTriggerState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>). |
render | ComponentRenderFn<HTMLProps, ComboboxTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | 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. |
style | CSSProperties | ((state: ComboboxTriggerState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-trigger.tsx.
Combobox.Value
| Prop | Type | Default | |
|---|---|---|---|
children | ((selectedValue: any) => ReactNode) | ReactNode | — | |
placeholder | ReactNode | — | The placeholder value to display when no value is selected.
This is overridden by children if specified, or by a null item's label in items. |
Plus the DOM props of the element it renders. Source: combobox/components/combobox-value.tsx.