Combobox
A searchable input that selects and remembers one or more values.
The chatbot answers from this knowledge base.
Usage guidelines
- Use
Comboboxto select and remember one or more values from a searchable collection. UseSelectto choose from a closed, scannable list without text entry, andAutocompletefor free-form text with optional suggestions, where the value is the typed text. - Give the input an accessible name. An input-based combobox inside a
FieldtakesFieldLabel; a trigger-based combobox takesComboboxLabel, and a popup that holds its own search input is named witharia-label. - Pass
itemsto the root so filtering, typeahead andComboboxValueshare one source of truth. Keep the caller's value type withCombobox<Value, Multiple, Item>; in multiple mode the second generic is the literaltrueand matchesmultiple. - Use
ComboboxClearto clear the selected value, in the input group outside the popup. When the search input sits inside the popup, do not add a control that clears the typed query: the popup resets the query itself, and a second clear button adds a tab stop that means something other than clearing the selection. - Render chips through
ComboboxValuearoundComboboxChips, and label the chips container only while it has chips and thetoolbarrole. Localize the chip's Backspace/Delete description, eachComboboxChipRemovename, and the input's selection count and Left Arrow hint. - The popup follows the anchor width and clamps to the viewport with Base UI's
--anchor-widthand--available-width. Do not replace that sizing with a fixed width.
Anatomy
Chips are for multiple selection only; a single combobox puts ComboboxInput directly in the input group. For a select-like field, render ComboboxLabel and a ComboboxTrigger with ComboboxValue and ComboboxIcon, and move the input group into ComboboxPopup.
Examples
Multiple selection with chips
Selected values render as chips that wrap inside the input group, and ArrowLeft from the start of the input moves focus onto them. The chip description, the remove button names and the selection hint in FieldDescription are your strings to localize.
Reviewers approve changes before the app is published. 2 selected. From the start of the input, press Left Arrow to focus the selected reviewers.
Grouped options with live status
Pass grouped { label, items } objects to items and render them with ComboboxGroup, ComboboxGroupLabel, ComboboxSeparator and ComboboxCollection. ComboboxStatus announces the filtered result count as the user types.
Empty groups hide automatically as you filter.
ID values with a popup search input
createComboboxItems keeps full records for the list while the value stays a stable ID. getLabel drives filtering and the trigger text. An unpublished app is a disabled item: it stays visible but cannot be chosen. ComboboxClear sits beside the trigger to clear the selected value, while the search input inside the popup has no clear button of its own.
Saved value: app_81c2
Keyboard
| Key | Action |
|---|---|
| Down arroworUp arrow | Opens the popup from the input and moves the highlight between items. |
| EnterorDown arrow | Opens the popup from a ComboboxTrigger and moves focus to its search input. |
| Enter | Selects the highlighted item. In single mode it fills the input and closes the popup. |
| Escape | Closes the popup and restores the input. With the popup closed, clears the selected value. |
| Left arrow | Moves focus from the start of the input to the last chip, then to the previous chip. |
| Right arrow | Moves focus to the next chip, then back to the input. |
| BackspaceorDelete | Removes the focused chip. Backspace in an empty input removes the last chip. |
API reference
Combobox
Groups all parts of a filterable combobox for selecting one or multiple predefined options. Doesn't render its own HTML element.
Supports inline input triggers, popup search inputs via ComboboxTrigger, and external surfaces via inline.
| Prop | Type | Default | Details |
|---|---|---|---|
children | React.ReactNode | No default | |
name | string | No default | |
form | string | No default | |
id | string | No default | |
required | boolean | false | |
readOnly | boolean | false | |
disabled | boolean | false | |
defaultOpen | boolean | false | |
open | boolean | No default | |
onOpenChangeComplete | ((open: boolean) => void) | No default | |
openOnInputClick | boolean | true | |
loopFocus | boolean | true | |
inputValue | string | number | readonly string[] | No default | |
defaultInputValue | string | number | readonly string[] | No default | |
inputRef | React.Ref<HTMLInputElement> | No default | |
grid | boolean | false | |
items | ComboboxItemCollection<Item, Value> | readonly any[] | readonly Group<any>[] | No default | |
filteredItems | readonly Item[] | readonly Group<Item>[] | No default | |
filter | ((item: Item, query: string, itemToString?: ((item: Item) => string) | undefined) => boolean) | null | No default | |
virtualized | boolean | false | |
inline | boolean | false | |
modal | boolean | false | |
limit | number | -1 | |
locale | Intl.LocalesArgument | No default | |
multiple | Multiple | false | |
autoComplete | string | No default | |
autoHighlight | boolean | false | |
highlightItemOnHover | boolean | true | |
itemToStringLabel | ((itemValue: Value) => string) | No default | |
itemToStringValue | ((itemValue: Value) => string) | No default | |
isItemEqualToValue | ((itemValue: Value, value: Value) => boolean) | No default | |
defaultValue | ComboboxInputValue<Value, Multiple> | null | No default | |
actionsRef | React.RefObject<AriaCombobox.Actions | null> | No default | |
onOpenChange | ((open: boolean, eventDetails: BaseCombobox.Root.OpenChangeEventDetails) => void) | No default | |
onInputValueChange | ((inputValue: string, eventDetails: BaseCombobox.Root.ChangeEventDetails) => void) | No default | |
onItemHighlighted | ((highlightedValue: Value | undefined, eventDetails: BaseCombobox.Root.HighlightEventDetails) => void) | No default | |
value | ComboboxInputValue<Value, Multiple> | null | No default | |
onValueChange | ((value: ComboboxOutputValue<Value, Multiple> | (Multiple extends true ? never : null), eventDetails: BaseCombobox.Root.ChangeEventDetails) => void) | No default | |
ComboboxChip
An individual chip that represents a value in a multiselectable input. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxChipState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxChipState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxChipState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-disabled | Whether the component should ignore user interaction. |
ComboboxChipRemove
A button to remove a chip. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxChipRemoveState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxChipRemoveState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxChipRemoveState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
| Attribute | Description |
|---|---|
data-disabled | Whether the component should ignore user interaction. |
ComboboxChips
A container for the chips in a multiselectable input. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxChipsState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxChipsState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxChipsState) => React.CSSProperties | undefined) | No default | |
ComboboxClear
Clears the value when clicked. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
size | 'large' | 'medium' | 'small' | 'medium' | |
disabled | boolean | false | |
keepMounted | boolean | false | |
className | string | ((state: ComboboxClearState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxClearState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxClearState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
| Attribute | Description |
|---|---|
data-popup-open | Present when the corresponding popup is open. |
data-disabled | Present when the button is disabled. |
data-visible | Present when the clear button is visible. |
data-starting-style | Present when the button begins animating in. |
data-ending-style | Present when the button is animating out. |
ComboboxCollection
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.
| Prop | Type | Default | Details |
|---|---|---|---|
children required | (item: Item, index: number) => React.ReactNode | No default | |
ComboboxEmpty
Renders its children only when the list is empty. Requires the items prop on the root component. Announces changes politely to screen readers. This component's root element must remain mounted in the DOM to announce changes consistently across screen readers. Avoid hiding or removing the component itself with display: none, hidden, aria-hidden, or conditional rendering. Prefer updating or conditionally rendering its children instead. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxEmptyState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxEmptyState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxEmptyState) => React.CSSProperties | undefined) | No default | |
ComboboxGroup
Groups related items with the corresponding label. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
items | readonly Item[] | No default | |
className | string | ((state: ComboboxGroupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxGroupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxGroupState) => React.CSSProperties | undefined) | No default | |
ComboboxGroupLabel
An accessible label that is automatically associated with its parent group. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxGroupLabelState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxGroupLabelState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxGroupLabelState) => React.CSSProperties | undefined) | No default | |
ComboboxIcon
An icon that indicates that the trigger button opens the popup. Renders a <span> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxIconState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxIconState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxIconState) => React.CSSProperties | undefined) | No default | |
ComboboxInput
A text input to search for items in the list. Renders an <input> element.
| Prop | Type | Default | Details |
|---|---|---|---|
size | 'large' | 'medium' | 'small' | 'medium' | |
className | string | ((state: ComboboxInputState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxInputState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxInputState) => React.CSSProperties | undefined) | No default | |
disabled | boolean | false | |
| Attribute | Description |
|---|---|
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-popup-side | Values: Indicates which side the corresponding popup is positioned relative to its anchor. |
data-required | Present when the component is required. |
data-valid | Present when the component is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the component is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the component has been touched (when wrapped in Field.Root). |
data-dirty | Present when the component's value has changed (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). |
data-list-empty | Present when the corresponding items list is empty. |
ComboboxInputGroup
A wrapper for the input and its associated controls. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
size | 'large' | 'medium' | 'small' | 'medium' | |
className | string | ((state: ComboboxInputGroupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxInputGroupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxInputGroupState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-popup-open | Present when the corresponding popup is open. |
data-pressed | Present when the input group is pressed. |
data-disabled | Present when the component is disabled. |
data-readonly | Present when the component is readonly. |
data-popup-side | Values: Indicates which side the corresponding popup is positioned relative to its anchor. |
data-valid | Present when the component is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the component is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the component has been touched (when wrapped in Field.Root). |
data-dirty | Present when the component's value has changed (when wrapped in Field.Root). |
data-filled | Present when the component has a value (when wrapped in Field.Root). |
data-focused | Present when the component is focused (when wrapped in Field.Root). |
data-list-empty | Present when the corresponding items list is empty. |
data-placeholder | Present when the combobox doesn't have a value. |
ComboboxInputTrigger
A button that opens the popup. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
size | 'large' | 'medium' | 'small' | 'medium' | |
disabled | boolean | false | |
className | string | ((state: ComboboxTriggerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxTriggerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxTriggerState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
| Attribute | Description |
|---|---|
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-popup-side | Values: Indicates which side the corresponding popup is positioned relative to its anchor. |
data-required | Present when the component is required. |
data-valid | Present when the component is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the component is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the component has been touched (when wrapped in Field.Root). |
data-dirty | Present when the component's value has changed (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). |
data-list-empty | Present when the corresponding items list is empty. |
data-placeholder | Present when the combobox doesn't have a value. |
ComboboxItem
An individual item in the list. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
value | Value | No default | |
className | string | ((state: ComboboxItemState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxItemState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxItemState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | false | |
children | React.ReactNode | No default | |
index | number | No default | |
disabled | boolean | false | |
| Attribute | Description |
|---|---|
data-selected | Present when the item is selected. |
data-highlighted | Present when the item is highlighted. |
data-disabled | Present when the item is disabled. |
ComboboxItemIndicator
Indicates whether the item is selected. Renders a <span> element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | React.ReactNode | No default | |
className | string | ((state: ComboboxItemIndicatorState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxItemIndicatorState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxItemIndicatorState) => React.CSSProperties | undefined) | No default | |
keepMounted | boolean | false | |
| Attribute | Description |
|---|---|
data-starting-style | Present when the indicator begins animating in. |
data-ending-style | Present when the indicator is animating out. |
ComboboxItemText
Accepts the props of the element it renders.
ComboboxLabel
An accessible label that is automatically associated with the combobox trigger. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxLabelState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxLabelState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxLabelState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-disabled | Present when the component should ignore user interaction. |
data-touched | Present when the field has been touched. |
data-dirty | Present when the field value has changed from its initial value. |
data-filled | Present when the field has a value. |
data-focused | Present when the field is focused. |
ComboboxList
A list container for the items. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | ((item: Item, index: number) => React.ReactNode) | React.ReactNode | No default | |
className | string | ((state: ComboboxListState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxListState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxListState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-empty | Whether the list is empty. |
ComboboxPopup
A container for the list. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxPopupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxPopupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxPopupState) => React.CSSProperties | undefined) | No default | |
initialFocus | boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-anchor-hidden | Present when the anchor is hidden. |
data-empty | Present when the items list is empty. |
ComboboxPortal
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.
| Prop | Type | Default | Details |
|---|---|---|---|
keepMounted | boolean | false | |
container | HTMLElement | React.RefObject<HTMLElement | ShadowRoot | null> | ShadowRoot | null | No default | |
className | string | ((state: ComboboxPortalState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxPortalState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxPortalState) => React.CSSProperties | undefined) | No default | |
ComboboxPositioner
Positions the popup against the trigger. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
align | 'center' | 'end' | 'start' | 'start' | |
sideOffset | number | OffsetFunction | 4 | |
className | string | ((state: ComboboxPositionerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxPositionerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxPositionerState) => React.CSSProperties | undefined) | No default | |
anchor | Element | React.RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | null | No default | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
side | 'bottom' | 'inline-end' | 'inline-start' | 'left' | 'right' | 'top' | 'bottom' | |
alignOffset | number | OffsetFunction | 0 | |
collisionBoundary | Boundary | 'clipping-ancestors' | |
collisionPadding | Padding | 5 | |
sticky | boolean | false | |
arrowPadding | number | 5 | |
disableAnchorTracking | boolean | false | |
collisionAvoidance | CollisionAvoidance | No default | |
| Attribute | Description |
|---|---|
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-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-empty | Present when the items list is empty. |
| Variable | Description |
|---|---|
--available-width | Values: The available width between the trigger and the edge of the viewport. |
--available-height | Values: The available height between the trigger and the edge of the viewport. |
--anchor-width | Values: The anchor's width. |
--anchor-height | Values: The anchor's height. |
--transform-origin | Values: The coordinates that this element is anchored to. Used for animations and transitions. |
ComboboxRow
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.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxRowState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxRowState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxRowState) => React.CSSProperties | undefined) | No default | |
ComboboxSeparator
A visual separator between items or groups. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
orientation | 'horizontal' | 'vertical' | 'horizontal' | |
className | string | ((state: ComboboxSeparatorState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxSeparatorState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxSeparatorState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-orientation | Values: The orientation of the separator. |
ComboboxStatus
Displays a status message whose content changes are announced politely to screen readers. Useful for conveying the status of an asynchronously loaded list. This component's root element must remain mounted in the DOM to announce changes consistently across screen readers. Avoid hiding or removing the component itself with display: none, hidden, aria-hidden, or conditional rendering. Prefer updating or conditionally rendering its children instead. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: ComboboxStatusState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxStatusState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxStatusState) => React.CSSProperties | undefined) | No default | |
ComboboxTrigger
Opens the combobox popup; carries only focus-ring styles so callers own its appearance directly or via render. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
disabled | boolean | false | |
className | string | ((state: ComboboxTriggerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, ComboboxTriggerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: ComboboxTriggerState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
| Attribute | Description |
|---|---|
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-popup-side | Values: Indicates which side the corresponding popup is positioned relative to its anchor. |
data-required | Present when the component is required. |
data-valid | Present when the component is in a valid state (when wrapped in Field.Root). |
data-invalid | Present when the component is in an invalid state (when wrapped in Field.Root). |
data-touched | Present when the component has been touched (when wrapped in Field.Root). |
data-dirty | Present when the component's value has changed (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). |
data-list-empty | Present when the corresponding items list is empty. |
data-placeholder | Present when the combobox doesn't have a value. |
ComboboxValue
The current value of the combobox. Doesn't render its own HTML element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | ((selectedValue: ComboboxSelectedValue<Value, Multiple>) => React.ReactNode) | React.ReactNode | No default | |
placeholder | React.ReactNode | No default | |
createComboboxItems
Creates a collection for the root's items prop. Values and labels are derived on first use.
Accepts either a flat item array or an array of groups. The getValue and getLabel accessors receive items, not groups.
Items cannot have an items array property because they would be interpreted as groups. Rename that field or cast the data when the runtime values are known not to contain arrays.
The data must not contain nullish entries: remove them before creating the collection, as for the root's items prop.
Create static collections at module scope. Wrap dynamic collections in React.useMemo() keyed by their data.
| Parameter | Type | Description |
|---|---|---|
data required | (ComboboxItemsData<Item> & RejectGroupShapedItems<Item>) | undefined | The flat or grouped source items, or |
options required | CreateComboboxItemsOptions<Item, Value> | Functions that derive each source item's selection value and display label. |
Returns
ComboboxItemCollection<Item, Value>A collection whose selection value is the getValue accessor's return value.
useComboboxFilter
Matches items against a query using Intl.Collator for robust string matching.
| Parameter | Type | Description |
|---|---|---|
options | UseComboboxFilterOptions | No description |
Returns
Filter| Member | Type | Description |
|---|---|---|
contains required | <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean | Returns whether the item matches the query anywhere. |
startsWith required | <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean | Returns whether the item starts with the query. |
endsWith required | <Item>(item: Item, query: string, itemToString?: (item: Item) => string) => boolean | Returns whether the item ends with the query. |
useComboboxFilteredItems
Returns the internally filtered items. Treat the result as read-only: it is internal state and may be a shared frozen array.
Returns
T[]