Skip to contentKino
Skip to Content

Autocomplete

A text field that suggests as you type. The text is the value, and a suggestion only fills it in.

npx shadcn add https://kinoui.com/r/autocomplete.json
Share on

Examples

Default

Click the field to see recent searches, then type: the list moves to the height of what still matches, and the matched part of each suggestion is bold.

Notify

With the chevron

An AutocompleteTrigger at the end of the field opens the suggestions that match its text, so an empty field shows them all.

City

From a server

Set filter to null and pass the results as items. The list says it is looking from the first key, and a spinner joins once the search lasts: in the list while it is empty, in the field while older results still show. AutocompleteStatus tells a screen reader how many it found.

We don’t ship there yet.

In a form

In a Field, its label names the input and an invalid field marks it, with the error under it.

Installation

npx shadcn@latest add https://kinoui.com/r/autocomplete.json
Files
lib/reduce-motion.tslib/scroll.tslib/refs.tslib/resize.tslib/swap.tsxlib/popup.tslib/glide.tsxcomponents/kino/tooltip.tsxlib/cut.tsxcomponents/kino/spinner.tsxcomponents/kino/button.tsxcomponents/kino/input.tsxcomponents/kino/separator.tsxlib/run-progress.tslib/highlight.tslib/menu.tsxcomponents/kino/select.tsxlib/filter-list.tsxcomponents/kino/autocomplete.tsx
Packages
@base-ui/reactclass-variance-authority

New to Kino? Installation covers what your project needs first and the @kino namespace.

API reference

Autocomplete

PropTypeDefaultDescription
itemsItem[]{ value, items }[]NoneThe suggestions, or groups of them; the list renders the ones that match.
defaultValuestringNoneThe text at first, when you leave the state to the autocomplete.
valuestringNoneThe text, when you hold the state.
onValueChange(text, details) => voidNoneCalled as the text changes, by typing or by picking a suggestion.
openOnInputClickbooleanfalseOpens the list when the field is clicked, for recent searches.
autoHighlightboolean'always'falseHighlights the first match as you type, so Enter takes it. Off, Enter keeps exactly what was typed.
filterfunctionnullNoneHow a suggestion matches what is typed. null shows items as they are, for results from a server.

AutocompleteContent

PropTypeDefaultDescription
side'left''top''bottom''right''inline-start''inline-end''bottom'The side of the field it opens on.
align'start''center''end''start'How it lines up with the field along that side.
sideOffsetnumberfunction6The gap between it and the field, in pixels.
alignOffsetnumberfunction0How far it shifts along that side, in pixels.
anchorElementRefObjectfunctionNoneWhat it opens under, when not the field.
classNamestringNoneGoes to the content inside the box.

Accessibility

  • The input is a combobox and the list a listbox: arrow keys move the highlight, Enter puts the highlighted suggestion in the field, and Escape closes the list.
  • Escape on a closed list clears the text, as the WAI-ARIA pattern allows.
  • Name it with a Field and its label, or aria-label on the input.
  • The matched part of a suggestion is bold, not only coloured.
  • When the system asks for less motion, the list changes height at once and only fades.