Autocomplete
A list that filters as the user types
import {
Autocomplete,
AutocompleteCollection,
AutocompleteContent,
AutocompleteEmpty,
AutocompleteGroup,
AutocompleteGroupLabel,
AutocompleteInput,
AutocompleteItem,
AutocompleteList,
AutocompleteSeparator,
AutocompleteStatus,
AutocompleteTrigger,
} from "@nyte-ai/ui/autocomplete";A search field for a long list, such as fonts or models. For a short list, use Select.
Usage
- Pass the current value as the children of
AutocompleteTrigger. - Pass the data to
itemsonAutocompleteand render each entry from a function child ofAutocompleteList. Inside anAutocompleteGroup, render its entries withAutocompleteCollection. - Give each
AutocompleteItemavalue. The selected item shows a checkmark. valueandonValueChangeonAutocompletehold the selection.onValueChangepassesnullwhen the selection clears.inputValueandonInputValueChangehold the search text.- To nest the list in another surface, such as a submenu, set
inlineandopenonAutocomplete, dropAutocompleteContent, and setvariant="inline". - Keep
AutocompleteStatusandAutocompleteEmptymounted and change their children, so screen readers announce the change.
Anatomy
<Autocomplete>
<AutocompleteTrigger />
<AutocompleteContent>
<AutocompleteInput />
<AutocompleteStatus />
<AutocompleteList>
<AutocompleteGroup>
<AutocompleteSeparator />
<AutocompleteGroupLabel />
<AutocompleteCollection>
<AutocompleteItem />
</AutocompleteCollection>
</AutocompleteGroup>
</AutocompleteList>
<AutocompleteEmpty />
</AutocompleteContent>
</Autocomplete>Examples
Searchable picker
interface ModelGroup {
readonly label: string;
readonly items: readonly string[];
}
const groups: readonly ModelGroup[] = [
{ label: "Anthropic", items: ["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4-5"] },
{ label: "OpenAI", items: ["gpt-6-luna"] },
{ label: "Google", items: ["gemini-3-pro"] },
];
const [model, setModel] = useState("claude-sonnet-4-6");
const [search, setSearch] = useState("");
<Autocomplete
items={groups}
value={model}
onValueChange={(next) => {
if (next !== null) setModel(next);
}}
inputValue={search}
onInputValueChange={setSearch}
autoHighlight
>
<AutocompleteTrigger aria-label="Model">{model}</AutocompleteTrigger>
<AutocompleteContent>
<AutocompleteInput aria-label="Search models" placeholder="Search models" />
<AutocompleteList>
{(group: ModelGroup, index: number) => (
<AutocompleteGroup key={group.label} items={group.items}>
{index > 0 && <AutocompleteSeparator />}
<AutocompleteGroupLabel>{group.label}</AutocompleteGroupLabel>
<AutocompleteCollection>
{(item: string) => (
<AutocompleteItem key={item} value={item}>
{item}
</AutocompleteItem>
)}
</AutocompleteCollection>
</AutocompleteGroup>
)}
</AutocompleteList>
<AutocompleteEmpty>No models match</AutocompleteEmpty>
</AutocompleteContent>
</Autocomplete>;Inside a submenu
The Menu submenu supplies the popup. filter={null} leaves filtering to
you.
<MenuSubContent>
<Autocomplete
inline
open
filter={null}
autoHighlight
items={options}
value={current}
onValueChange={(next) => {
if (next !== null) choose(next);
}}
inputValue={search}
onInputValueChange={setSearch}
>
<AutocompleteInput variant="inline" aria-label="Search models" placeholder="Search models" />
<MenuSeparator />
<AutocompleteList variant="inline">
{(option: ModelOption) => (
<AutocompleteItem variant="inline" key={option.key} value={option}>
{option.name}
</AutocompleteItem>
)}
</AutocompleteList>
</Autocomplete>
</MenuSubContent>Props
Styled parts take xstyle, className, and style; see
Theming. Each sets data-slot to its kebab-case name, such as
autocomplete-item. Autocomplete, AutocompleteValue, AutocompleteInputGroup,
AutocompleteGroup, and AutocompleteCollection pass through Base UI.
The reference tables below come from Base UI, MIT, ยฉ Material-UI SAS.
Autocomplete
Groups all parts of the combobox. Doesn't render its own HTML element.
Root Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | - | Identifies the field when a form is submitted. |
| defaultValue | Value[] | Value | null | - | The uncontrolled selected value of the combobox when it's initially rendered. To render a controlled combobox, use the value prop instead. |
| value | Value[] | Value | null | - | The selected value of the combobox. Use when controlled. |
| onValueChange | ((value: Value[] | Value | null, eventDetails: Combobox.Root.ChangeEventDetails) => void) | - | Event handler called when the selected value of the combobox changes. |
| defaultInputValue | string | number | string[] | - | The uncontrolled input value when initially rendered. To render a controlled input, use the inputValue prop instead. |
| inputValue | string | string[] | number | - | The input value of the combobox. Use when controlled. |
| onInputValueChange | ((inputValue: string, eventDetails: Combobox.Root.ChangeEventDetails) => void) | - | Event handler called when the input value changes. |
| defaultOpen | boolean | false | Whether the popup is initially open. To render a controlled popup, use the open prop instead. |
| open | boolean | - | Whether the popup is currently open. Use when controlled. |
| onOpenChange | ((open: boolean, eventDetails: Combobox.Root.OpenChangeEventDetails) => void) | - | Event handler called when the popup is opened or closed. |
| autoHighlight | boolean | false | Whether the first matching item is highlighted automatically while filtering. |
| highlightItemOnHover | boolean | true | Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS :hover to be differentiated from the :focus (data-highlighted) state. |
| actionsRef | React.RefObject<Combobox.Root.Actions | null> | - | A ref to imperative actions. unmount: Ends the closing phase of the combobox after an externally controlled closing animation finishes.
Call preventUnmountOnClose() in onOpenChange first, otherwise the combobox completes closing on its own.
Whether it leaves the DOM is decided by keepMounted on the portal.close: Closes the combobox imperatively when called.highlightItem: Moves or clears the highlight while the popup is open.
'next' and 'previous' move sequentially through the items, including across rows in a
grid, and wrap when loopFocus is enabled. Unlike the arrow keys, they never return the
highlight to the input. 'first' and 'last' highlight the first or last item.
'none' clears the highlight.
Calling this action does not open the popup. To highlight an item after opening it, call
the action from onOpenChangeComplete when open is true.
Highlight changes requested through this action report the reason 'imperative-action'
to onItemHighlighted. |
| autoComplete | string | - | Provides a hint to the browser for autofill. |
| filter | ((item: Item, query: string, itemToString?: ((item: Item) => string)) => boolean) | null | - | ComboboxFilter function used to match items vs input query.
Receives the source item, which is the derived value's item when items is a createItems()
collection, and the item itself otherwise. |
| filteredItems | Item[] | Group<Item>[] | - | Filtered items to display in the list.
When provided, the list uses these items instead of filtering the items prop internally.
When items is also provided, this array must preserve its flat or grouped structure.
With a createItems() collection, pass source items rather than derived values.
Nullish entries are not supported, as in items.
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 | false | Whether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows. |
| inline | boolean | false | 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. |
| 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.
With a createItems() collection, both arguments are derived values.
Defaults to Object.is comparison. |
| 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.
With a createItems() collection, this receives the derived value, and the collection's
getLabel takes precedence for values it can resolve. |
| 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.
With a createItems() collection, this receives the derived value. |
| items | any[] | Group[] | ComboboxItemCollection<Item, Value> | - | The items to be displayed in the list.
Can be a flat array of items, an array of groups with items, or a collection created by
the createItems() function, which derives each item's selection value and label.
Nullish entries are not supported: remove them from the data before passing it. |
| limit | number | -1 | The maximum number of items to display in the list. |
| locale | Intl.LocalesArgument | - | The locale to use for string comparison. Defaults to the user's runtime locale. |
| loopFocus | boolean | true | 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 | false | 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. On touch devices, a true modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior. |
| multiple | boolean | false | Whether multiple items can be selected. |
| onItemHighlighted | ((highlightedValue: Value | undefined, eventDetails: Combobox.Root.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: 'keyboard': the highlight changed due to keyboard navigation.'pointer': the highlight changed due to pointer hovering. The event may be a MouseEvent
rather than a PointerEvent.'imperative-action': the highlight changed via actionsRef's highlightItem.'none': the highlight changed for another reason, such as typing, autoHighlight, the
item list changing, or the popup opening or closing. |
| onOpenChangeComplete | ((open: boolean) => void) | - | Event handler called after any animations complete when the popup is opened or closed. |
| openOnInputClick | boolean | true | Whether the popup opens when clicking the input. |
| virtualized | boolean | false | Whether the items are being externally virtualized. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| readOnly | boolean | false | Whether the user should be unable to choose a different option from the popup. |
| required | boolean | false | Whether the user must choose a value before submitting a form. |
| inputRef | React.Ref<HTMLInputElement> | - | A ref to the hidden input element. |
| id | string | - | The id of the component. |
| children | React.ReactNode | - | - |
autoComplete Prop References:
AutocompleteTrigger
A button that opens the popup.
Renders a <button> element.
Trigger Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| nativeButton | boolean | true | 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>). |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Combobox.Trigger.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Trigger.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Trigger.State) => ReactElement) | - | 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. |
Trigger Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-popup-open | - | Present when the corresponding popup is open. |
| data-popup-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null | Indicates which side the corresponding popup is positioned relative to its anchor. |
| data-list-empty | - | Present when the corresponding items list is empty. |
| data-pressed | - | Present when the trigger is pressed. |
| data-disabled | - | Present when the component is disabled. |
| data-readonly | - | Present when the component is readonly. |
| data-required | - | Present when the component is required. |
| data-valid | - | Present when the component is in 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-dirty | - | Present when the component's value has changed (when wrapped in Field.Root). |
| data-touched | - | Present when the component has been touched (when wrapped in Field.Root). |
| data-filled | - | Present when the component has a value (when wrapped in Field.Root). |
| data-focused | - | Present when the trigger is focused (when wrapped in Field.Root). |
| data-placeholder | - | Present when the combobox doesn't have a value. |
AutocompleteValue
The current value of the combobox. Doesn't render its own HTML element.
Value Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| placeholder | React.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. |
| children | React.ReactNode | ((selectedValue: any) => React.ReactNode) | - | Accepts a function that returns a ReactNode to format the selected value.
Treat the value as read-only: in multiple mode it may be a shared frozen array
when nothing is selected. |
AutocompleteClear
Clears the value when clicked.
Renders a <button> element.
Clear Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| nativeButton | boolean | true | 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>). |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Combobox.Clear.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Clear.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| keepMounted | boolean | false | Whether the component should remain mounted in the DOM when not visible. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Clear.State) => ReactElement) | - | 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. |
Clear Data Attributes:
| Attribute | Type | 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. |
AutocompleteContent
Renders the portal, positioner, and popup. The positioning props below go to the positioner. Everything else goes to the popup.
| Prop | Type | Default | Description |
|---|---|---|---|
side | "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end" | "bottom" | |
align | "start" | "center" | "end" | "start" | |
sideOffset | number | OffsetFunction | 4 | Pixels. |
alignOffset | number | OffsetFunction | ||
anchor | AutocompleteContentProps["anchor"] | Element or virtual element to open from. | |
collisionAvoidance | CollisionAvoidance | ||
tint | Tint | Scopes the popup to a hue. |
Positioner
Positions the popup against the trigger.
Renders a <div> element.
Positioner Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| disableAnchorTracking | boolean | false | Whether to disable the popup from tracking any layout shift of its positioning anchor. |
| align | Align | 'center' | 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: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.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. |
| side | Side | 'bottom' | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
| sideOffset | number | OffsetFunction | 0 | Distance between the anchor and the popup in pixels.
Also accepts a function that returns the distance to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.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. |
| arrowPadding | number | 5 | 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. |
| anchor | Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | - | An element to position the popup against. By default, the popup will be positioned against the trigger. |
| collisionAvoidance | CollisionAvoidance | - | Determines how to handle collisions when positioning the popup. side controls overflow on the preferred placement axis (top/bottom or left/right): 'flip': keep the requested side when it fits; otherwise try the opposite side
(top and bottom, or left and right).'shift': never change side; keep the requested side and move the popup within
the clipping boundary so it stays visible.'none': do not correct side-axis overflow. align controls overflow on the alignment axis (start/center/end): 'flip': keep side, but swap start and end when the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the
alignment axis to fit.'none': do not correct alignment-axis overflow. fallbackAxisSide controls fallback behavior on the perpendicular axis when the
preferred axis cannot fit: 'start': allow perpendicular fallback and try the logical start side first
(top before bottom, or left before right in LTR).'end': allow perpendicular fallback and try the logical end side first
(bottom before top, or right before left in LTR).'none': do not fallback to the perpendicular axis. When side is 'shift', explicitly setting align only supports 'shift' or 'none'.
If align is omitted, it defaults to 'flip'. |
| collisionBoundary | Boundary | 'clipping-ancestors' | An element or a rectangle that delimits the area that the popup is confined to. |
| collisionPadding | Padding | 5 | Additional space to maintain from the edge of the collision boundary. |
| sticky | boolean | false | Whether to maintain the popup in the viewport after the anchor element was scrolled out of view. |
| positionMethod | 'absolute' | 'fixed' | 'absolute' | Determines which CSS position property to use. |
| className | string | ((state: Combobox.Positioner.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Positioner.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Positioner.State) => ReactElement) | - | 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. |
alignOffset Prop Example:
<Positioner
alignOffset={({ side, align, anchor, positioner }) => {
return side === 'top' || side === 'bottom' ? anchor.width : anchor.height;
}}
/>sideOffset Prop Example:
<Positioner
sideOffset={({ side, align, anchor, positioner }) => {
return side === 'top' || side === 'bottom' ? anchor.height : anchor.width;
}}
/>collisionAvoidance Prop Example:
<Positioner
collisionAvoidance={{
side: 'shift',
align: 'shift',
fallbackAxisSide: 'none',
}}
/>Positioner Data Attributes:
| Attribute | Type | 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-align | 'start' | 'center' | 'end' | Indicates how the popup is aligned relative to specified side. |
| data-empty | - | Present when the items list is empty. |
| data-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | Indicates which side the popup is positioned relative to the trigger. |
Positioner CSS Variables:
| Variable | Type | Description |
|---|---|---|
--anchor-height | number | The anchor's height. |
--anchor-width | number | The anchor's width. |
--available-height | number | The available height between the trigger and the edge of the viewport. |
--available-width | number | The available width between the trigger and the edge of the viewport. |
--transform-origin | string | The coordinates that this element is anchored to. Used for animations and transitions. |
Popup
A container for the list.
Renders a <div> element.
Popup Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| initialFocus | boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null) | - | 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, or keyboard).
Return an element to focus, true to use the default behavior, or false/undefined to do nothing. |
| finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null) | - | 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, or keyboard).
Return an element to focus, true to use the default behavior, or false/undefined to do nothing. |
| className | string | ((state: Combobox.Popup.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Popup.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Popup.State) => ReactElement) | - | 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. |
Popup Data Attributes:
| Attribute | Type | 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-align | 'start' | 'center' | 'end' | Indicates how the popup is aligned relative to specified side. |
| data-empty | - | Present when the items list is empty. |
| data-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | Indicates which side the popup is positioned relative to the trigger. |
| data-starting-style | - | Present when the popup begins animating in. |
| data-ending-style | - | Present when the popup is animating out. |
AutocompleteInput
A text input to search for items in the list.
Renders an <input> element.
Input Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | Whether the component should ignore user interaction. |
| className | string | ((state: Combobox.Input.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Input.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Input.State) => ReactElement) | - | 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. |
Input Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-popup-open | - | Present when the corresponding popup is open. |
| data-popup-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null | Indicates which side the corresponding popup is positioned relative to its anchor. |
| data-list-empty | - | Present when the corresponding items list is empty. |
| data-pressed | - | Present when the input is pressed. |
| data-disabled | - | Present when the component is disabled. |
| data-readonly | - | Present when the component is readonly. |
| data-required | - | Present when the component is required. |
| data-valid | - | Present when the component is in 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-dirty | - | Present when the component's value has changed (when wrapped in Field.Root). |
| data-touched | - | Present when the component has been touched (when wrapped in Field.Root). |
| data-filled | - | Present when the component has a value (when wrapped in Field.Root). |
| data-focused | - | Present when the input is focused (when wrapped in Field.Root). |
AutocompleteInputGroup
A wrapper for the input and its associated controls.
Renders a <div> element.
InputGroup Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: Combobox.InputGroup.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.InputGroup.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.InputGroup.State) => ReactElement) | - | 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. |
InputGroup Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-popup-open | - | Present when the corresponding popup is open. |
| data-popup-side | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null | Indicates which side the corresponding popup is positioned relative to its anchor. |
| data-list-empty | - | Present when the corresponding items list is empty. |
| 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-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-dirty | - | Present when the component's value has changed (when wrapped in Field.Root). |
| data-touched | - | Present when the component has been touched (when wrapped in Field.Root). |
| data-filled | - | Present when the component has a value (when wrapped in Field.Root). |
| data-focused | - | Present when the component is focused (when wrapped in Field.Root). |
| data-placeholder | - | Present when the combobox doesn't have a value. |
AutocompleteList
A list container for the items.
Renders a <div> element.
List Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | ((item: any, index: number) => React.ReactNode) | - | - |
| className | string | ((state: Combobox.List.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.List.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.List.State) => ReactElement) | - | 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. |
AutocompleteItem
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "popup" | "inline" | "popup" | See Variant. |
An individual item in the list.
Renders a <div> element.
Item Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| value | any | null | A unique value that identifies this item. |
| onClick | ((event: BaseUIEvent<React.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. |
| 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 | false | 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. |
| disabled | boolean | false | Whether the component should ignore user interaction. |
| children | React.ReactNode | - | - |
| className | string | ((state: Combobox.Item.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Item.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Item.State) => ReactElement) | - | 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. |
Item Data Attributes:
| Attribute | Type | 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. |
AutocompleteCollection
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.
Collection Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ((item: any, index: number) => React.ReactNode) | - | - |
AutocompleteGroup
Groups related items with the corresponding label.
Renders a <div> element.
Group Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| items | any[] | - | Items to be rendered within this group.
When provided, child Collection components will use these items. |
| className | string | ((state: Combobox.Group.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Group.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Group.State) => ReactElement) | - | 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. |
AutocompleteGroupLabel
An accessible label that is automatically associated with its parent group.
Renders a <div> element.
GroupLabel Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: Combobox.GroupLabel.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.GroupLabel.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.GroupLabel.State) => ReactElement) | - | 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. |
AutocompleteSeparator
A visual separator between items or groups.
Renders a <div> element.
Separator Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | Orientation | 'horizontal' | The orientation of the separator. |
| className | string | ((state: Combobox.Separator.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Separator.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Separator.State) => ReactElement) | - | 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. |
Separator Data Attributes:
| Attribute | Type | Description |
|---|---|---|
| data-orientation | 'horizontal' | 'vertical' | Indicates the orientation of the separator. |
AutocompleteEmpty
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.
Empty Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: Combobox.Empty.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Empty.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Empty.State) => ReactElement) | - | 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. |
AutocompleteStatus
Takes up no space while empty.
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.
Status Props:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | ((state: Combobox.Status.State) => string | undefined) | - | CSS class applied to the element, or a function that returns a class based on the component's state. |
| style | React.CSSProperties | ((state: Combobox.Status.State) => React.CSSProperties | undefined) | - | Style applied to the element, or a function that returns a style object based on the component's state. |
| render | ReactElement | ((props: HTMLProps, state: Combobox.Status.State) => ReactElement) | - | 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. |
Variant
AutocompleteInput, AutocompleteList, AutocompleteItem, and AutocompleteGroupLabel take
variant.
| Value | Geometry |
|---|---|
"popup" | Default. Sized for AutocompleteContent. |
"inline" | Menu row geometry, for a host such as a submenu. |
Accessibility
- Name the input and the trigger with
aria-label. The trigger's text is only the current value. AutocompleteListrendersrole="listbox"and eachAutocompleteItemrole="option". The checkmark is hidden from assistive technology.- Arrow Down and Up move the highlight. The input is part of the loop. Enter picks the highlighted item. Escape closes the popup.
AutocompleteGroupLabelnames its group.- Keyboard focus on the trigger shows the focus ring.