Component

Autocomplete

A combobox input for filtering suggestions, selecting an option, and keeping keyboard control intact.

Preview

Installation

Install the package, then import the component and shared stylesheet in your app.

Package install

Install the package when you want components imported from axie-ui.

install
pnpm add axie-ui

Import

code
import "axie-ui/styles.css";import { Autocomplete } from "axie-ui";

Registry install

Use the direct URL when you want shadcn to copy editable source into your app. This works without the official registry and does not install axie-ui.

registry
pnpm dlx shadcn@latest add https://axie.alexi.life/r/autocomplete.json

Copied source import

code
import "@/styles/axie.css";import { Autocomplete } from "@/components/axie/autocomplete";

Prefer @axie/autocomplete? Add the Axie namespace once from the Installation page, then use that shorthand.

Usage

code
import { Autocomplete, Field } from "axie-ui";export function Example() {  return (    <Field label="Assignee">      <Autocomplete        options={[          { label: "Mira Vale", value: "mira" },          { label: "Talia Nox", value: "talia" }        ]}        placeholder="Search people..."      />    </Field>  );}

Accessibility

  • Keep a visible label outside the input.
  • Make arrow keys, Enter, and Escape work predictably for the suggestion list.
  • Do not hide required choices in autocomplete when the list is short enough for radio or select.

Empty state

Use concise empty text when a query has no matches.

API Reference

PropTypeDefaultDescription
optionsAutocompleteOption[]-Suggested items shown in the listbox.
valuestring-Controlled input text.
defaultValuestring-Initial input text for uncontrolled usage.
onValueChange(value, option?) => void-Called when the input text changes or an option is selected.
onOptionSelect(option) => void-Called with the full option after selection.
emptyTextReactNodeNo matches found.Empty-state content for a filtered list.
...propsInputHTMLAttributes<HTMLInputElement>-Native input props like name, disabled, placeholder, and aria attributes.