Autocomplete
A glass field that suggests as you type. Free text is allowed; suggestions fill it in.
Installation#
$ pnpm dlx shadcn@latest add @liquikit/autocompleteNeeds the @liquikit registry in your components.json. Set it up once.
Usage#
import { Autocomplete } from "@/components/liquikit/autocomplete"<Autocomplete.Root items={cities}>
<Autocomplete.Input placeholder="Search cities" aria-label="City" />
<Autocomplete.Popup empty="No city found.">
<Autocomplete.List>
{(city: string) => (
<Autocomplete.Item key={city} value={city}>
{city}
</Autocomplete.Item>
)}
</Autocomplete.List>
</Autocomplete.Popup>
</Autocomplete.Root>Use Combobox when the value must be one of the items.
API Reference#
Autocomplete.Root
| Prop | Type | Default |
|---|---|---|
open | booleanWhether the popup is open. Pair it with | — |
Also takes every prop of Base UI's autocomplete, plus className and style.
Autocomplete.Input
| Prop | Type | Default |
|---|---|---|
theme | "light" | "dark"Light or dark glass. Falls back to the nearest | — |
lens | Partial<LensProfile>Overrides for the lens profile, such as | — |
liquid | numberHow far the glass squashes and stretches as it moves. | — |
refraction | "interactive" | "always"When the glass bends the page. | "interactive" |
Also takes every prop of Base UI's autocomplete, plus className and style.
Autocomplete.Popup
| Prop | Type | Default |
|---|---|---|
empty | ReactNodeShown in the list when nothing matches. | — |
theme | "light" | "dark"Light or dark glass. Falls back to the nearest | — |
refraction | "interactive" | "always"When the glass bends the page. | "interactive" |
children | ReactNodeThe content. | — |
Also takes every prop of Base UI's autocomplete, plus className and style.