Preview
Design guidance
Autocomplete renders the standard Input control at its default 32 px height. Its InputGroup uses the canonical field boundary. Place Clear or Trigger in InputGroup.Addon for the same inset ghost icon buttons used by Combobox.
The popup matches the input width within the available screen space. Compose Field.Root and Field.Label for shared label spacing. Group labels use the same --menu-label-* theme roles as Select and Combobox. Compose Separator between groups.
Use Autocomplete when typing filters a list and the user may commit a free-form value. Use Combobox when the value must come from a bounded set.
| Need | Choose |
|---|---|
| Free text with suggestions | Autocomplete lets people enter text and choose a suggestion. |
| A value from a list | Combobox searches a known set of choices. |
Installation
Install the local ghost-kit source bundle while the registry runs at localhost:3110. It contains this component and its source dependencies. Prepare the local registry first so token dependencies also resolve locally.
Basic usage
Structure
Examples
Async search
Load movie options asynchronously while typing. The specimen shows loading, empty, error and retry states, and ignores responses from older requests.
Inline autocomplete
Autofill the input with the highlighted item while navigating with arrow keys by using mode="both" and inline.
Grouped
Organize related pantry options with Group, GroupLabel, and Collection.
Fuzzy matching
Find a teammate with a subsequence query such as “mp”, even when the query does not match consecutive text.
Limit results
Limit the visible result count and guide users to refine their query with Status.
Auto highlight
Highlight the first matching destination as the user types and report the active option in text.
Command palette
Filter commands and run a local visible action when an item is clicked or accepted with Enter.
Grid layout
Display team options in rows with grid and Row; Arrow keys move across the resulting grid.
Virtualized
Window a 240-item list so only the visible rows mount. Scroll the popup to render a different window.
Memoized items
Use React.memo for lists up to roughly 1,000 items. Memoization reduces updates but does not replace windowing for larger lists.
API reference
For inherited behavior and additional part properties, see the Base UI Autocomplete API.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | number | readonly string[] | The uncontrolled input value of the autocomplete when it's initially rendered. To render a controlled autocomplete, use the `value` prop instead. | |
form | string | Identifies the form that owns the internal input. Useful when the autocomplete is rendered outside the form. | |
filter | ((item: Items[number]["items"][number], query: string, itemToString?: ((item: Items[number]["items"][number]) => string)) => boolean) | null | Filter function used to match items against the input query. | |
disabled | boolean | false | Whether the component should ignore user interaction. |
name | string | Identifies the field when a form is submitted. | |
value | string | number | readonly string[] | The input value of the autocomplete. Use when controlled. | |
id | string | The id of the component. | |
children | ReactNode | Sets children. | |
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: `<Autocomplete.Root inline open>` |
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 <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>. |
onValueChange | ((value: string, eventDetails: AutocompleteRootChangeEventDetails) => void) | Event handler called when the input value of the autocomplete changes. | |
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. |
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. |
onOpenChange | ((open: boolean, eventDetails: AutocompleteRootChangeEventDetails) => void) | Event handler called when the popup is opened or closed. | |
actionsRef | RefObject<AutocompleteRootActions | null> | A ref to imperative actions. - `unmount`: Manually unmounts the autocomplete. Call this after any externally controlled closing animation finishes. | |
open | boolean | Whether the popup is currently open. Use when controlled. | |
defaultOpen | boolean | false | Whether the popup is initially open. To render a controlled popup, use the `open` prop instead. |
onOpenChangeComplete | ((open: boolean) => void) | Event handler called after any animations complete when the popup is opened or closed. | |
itemToStringValue | ((itemValue: Items[number]["items"][number]) => string) | When the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission. If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop. | |
autoHighlight | boolean | "always" | false | Whether the first matching item is highlighted automatically. - `true`: highlight after the user types and keep the highlight while the query changes. - `'always'`: always highlight the first item. |
keepHighlight | boolean | false | Whether the highlighted item should be preserved when the pointer leaves the list. |
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. |
openOnInputClick | boolean | false | Whether the popup opens when clicking the input. |
filteredItems | readonly Items[number]["items"][number][] | readonly Group<Items[number]["items"][number]>[] | 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. Nullish entries are not supported, as in `items`. Use when you want to control filtering logic externally with the `useFilter()` hook. | |
onItemHighlighted | ((highlightedValue: Items[number]["items"][number], eventDetails: AutocompleteRootHighlightEventDetails) => 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. - `'none'`: the highlight changed programmatically. | |
inputRef | Ref<HTMLInputElement> | A ref to the hidden input element. | |
virtualized | boolean | false | Whether the items are being externally virtualized. |
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. | |
submitOnItemClick | boolean | false | Whether clicking an item should submit the autocomplete's owning form. By default, clicking an item via a pointer or <kbd>Enter</kbd> key does not submit the owning form. Useful when the autocomplete is used as a single-field form search input. |
mode | "none" | "list" | "inline" | "both" | 'list' | Controls how the autocomplete behaves with respect to list filtering and inline autocompletion. - `list` (default): items are dynamically filtered based on the input value. The input value does not change based on the active item. - `both`: items are dynamically filtered based on the input value, which will temporarily change based on the active item (inline autocompletion). - `inline`: items are static (not filtered), and the input value will temporarily change based on the active item (inline autocompletion). - `none`: items are static (not filtered), and the input value will not change based on the active item. |
itemsrequired | Items | The items to be displayed in the list. Can be either a flat array of items or an array of groups with items. Nullish entries are not supported: remove them from the data before passing it. |