Skip to content

Autocomplete

Free-text input with a filtered suggestion popup.

Install

Bash
npx @madeui/cli add autocomplete

Usage

TSX
import {
  Autocomplete,
  AutocompleteContent,
  AutocompleteEmpty,
  AutocompleteInput,
  AutocompleteItem,
  AutocompleteList,
} from '@/components/ui/autocomplete';

Composition

TSX
<Autocomplete items={items}>
  <AutocompleteInput />
  <AutocompleteContent>
    <AutocompleteEmpty />
    <AutocompleteList>
      {(item) => <AutocompleteItem value={item} />}
    </AutocompleteList>
  </AutocompleteContent>
</Autocomplete>

Auto highlight

Set autoHighlight to highlight the first matching item as the user types, so pressing Enter accepts it without arrowing down first.

Autocomplete vs. Combobox

Both filter a list as you type. Combobox selects from a fixed set — the value must be one of the options. Autocomplete is a free-text input where the list only suggests: any typed value is allowed. (Command is the same primitive in inline mode, rendered as a palette.)

API reference

Built on Base UI Autocomplete. Pass items to Autocomplete; filtering and highlight ship with the primitive, and AutocompleteList accepts a render function over the filtered items. All other props are forwarded to the Base UI parts (filter, onValueChange, openOnInputClick, …); see the Base UI Autocomplete API reference.

AutocompleteContent

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''bottom'
sideOffsetnumber6
align'start' | 'center' | 'end''start'
alignOffsetnumber0

Every part accepts a style prop (StyleXStyles, merged last).

Was this page helpful?