Skip to content

Autocomplete

A text input that suggests values as the user types.

Tags group apps on the Studio page.

hero.tsx

Usage guidelines

  • Use Autocomplete for free-form text with optional suggestions; the value is the typed text. Use Combobox to select and remember one or more values from a searchable collection, and Select to choose from a closed, scannable list without text entry.
  • Give the input an accessible name with FieldLabel inside a Field, or aria-label when the layout already labels it visually.
  • Pass items to the root so filtering and the list share one source. For groups, pass an array of { label, items } objects and render them with useAutocompleteFilteredItems, AutocompleteGroup and AutocompleteCollection.
  • Use AutocompleteClear in the input group to clear the typed text. AutocompleteTrigger is optional and opens the suggestions without typing.
  • Keep AutocompleteEmpty when the empty state needs explanation, for example that the typed text is kept as entered. When omitting AutocompleteEmpty, add data-empty:hidden to AutocompletePositioner so an empty popup frame does not stay visible when nothing matches.
  • The popup follows the input group width and clamps to the viewport with Base UI's --anchor-width and --available-width. Do not replace that sizing with a fixed width.

Anatomy

tsx
tsx

Examples

Grouped suggestions

Group suggestions under an AutocompleteGroupLabel. The filter keeps the group shape, so a group with no matches disappears.

Choose a standard header or type a custom header for the HTTP Request node.

groups.tsx

Inline completion

With mode="both", the input previews the highlighted suggestion while the list filters. Omitting AutocompleteEmpty and setting data-empty:hidden on AutocompletePositioner hides the popup cleanly when no saved instruction matches, while keeping any text the user enters.

Type a prefix to preview an inline completion, or keep any custom instruction.

inline-completion.tsx

Keyboard

KeyAction
Down arroworUp arrowOpens the suggestions and moves the highlight. With mode="both", the input previews the highlighted one.
EnterFills the input with the highlighted suggestion and closes the suggestions.
EscapeCloses the suggestions and keeps the typed text. With the suggestions closed, clears the input.

API reference

Autocomplete

Groups all parts of an autocomplete for free-form text inputs with suggestions. Doesn't render its own HTML element.

Base UI Autocomplete.Root docs

AutocompleteClear

Clears the value when clicked. Renders a <button> element.

Base UI Combobox.Clear docs

Props
PropTypeDefaultDetails
size'large' | 'medium' | 'small''medium'
Base UI Combobox.Clear docs
Data attributes
AttributeDescription
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.

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.

Props
PropTypeDefaultDetails
children required(item: Value, index: number) => React.ReactNodeNo default

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.

Base UI Combobox.Empty docs

AutocompleteGroup

Groups related items with the corresponding label. Renders a <div> element.

Base UI Combobox.Group docs

Props
PropTypeDefaultDetails
itemsreadonly Value[]No default
Base UI Combobox.Group docs

AutocompleteGroupLabel

An accessible label that is automatically associated with its parent group. Renders a <div> element.

Base UI Combobox.GroupLabel docs

AutocompleteIcon

An icon that indicates that the trigger button opens the popup. Renders a <span> element.

Base UI Combobox.Icon docs

AutocompleteInput

A text input to search for items in the list. Renders an <input> element.

Base UI Combobox.Input docs

Props
PropTypeDefaultDetails
size'large' | 'medium' | 'small''medium'
Base UI Combobox.Input docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null

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.

AutocompleteInputGroup

A wrapper for the input and its associated controls. Renders a <div> element.

Base UI Autocomplete.InputGroup docs

Props
PropTypeDefaultDetails
size'large' | 'medium' | 'small''medium'
Base UI Autocomplete.InputGroup docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null

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.

AutocompleteItem

An individual item in the list. Renders a <div> element.

Base UI Autocomplete.Item docs

Props
PropTypeDefaultDetails
valueValueNo default
Base UI Autocomplete.Item docs
Data attributes
AttributeDescription
data-highlighted

Present when the item is highlighted.

data-disabled

Present when the item is disabled.

AutocompleteItemIndicator

Accepts the props of the element it renders.

AutocompleteItemText

Accepts the props of the element it renders.

AutocompleteList

A list container for the items. Renders a <div> element.

Base UI Combobox.List docs

Props
PropTypeDefaultDetails
children((item: Value, index: number) => React.ReactNode) | React.ReactNodeNo default
Base UI Combobox.List docs
Data attributes
AttributeDescription
data-empty

Whether the list is empty.

AutocompletePopup

A container for the list. Renders a <div> element.

Base UI Combobox.Popup docs

Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

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.

AutocompletePortal

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.

Base UI Combobox.Portal docs

AutocompletePositioner

Positions the popup against the trigger. Renders a <div> element.

Base UI Combobox.Positioner docs

Props
PropTypeDefaultDetails
align'center' | 'end' | 'start''start'
sideOffsetnumber | OffsetFunction4
Base UI Combobox.Positioner docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

data-empty

Present when the items list is empty.

CSS variables
VariableDescription
--available-width

Values: number

The available width between the trigger and the edge of the viewport.

--available-height

Values: number

The available height between the trigger and the edge of the viewport.

--anchor-width

Values: number

The anchor's width.

--anchor-height

Values: number

The anchor's height.

--transform-origin

Values: string

The coordinates that this element is anchored to. Used for animations and transitions.

AutocompleteRow

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.

Base UI Combobox.Row docs

AutocompleteSeparator

A visual separator between items or groups. Renders a <div> element.

Base UI Autocomplete.Separator docs

Data attributes
AttributeDescription
data-orientation

Values: 'horizontal' | 'vertical'

The orientation of the separator.

AutocompleteStatus

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.

Base UI Combobox.Status docs

AutocompleteTrigger

A button that opens the popup. Renders a <button> element.

Base UI Autocomplete.Trigger docs

Props
PropTypeDefaultDetails
size'large' | 'medium' | 'small''medium'
Base UI Autocomplete.Trigger docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null

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.

AutocompleteValue

The current value of the autocomplete. Doesn't render its own HTML element.

Base UI Autocomplete.Value docs

useAutocompleteFilter

Parameters
ParameterTypeDescription
optionsGetFilterParametersNo description

Returns

Filter
Return properties
MemberTypeDescription
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.

useAutocompleteFilteredItems

Returns

readonly Value[]