Skip to content
UI

Search docs

Search components and documentation

New
Menu

Autocomplete

A free-text input with a filtered suggestion list — the editable ARIA combobox pattern.

Installation

npx logic2b@latest add autocomplete

Usage

import { Autocomplete } from "@/components/ui/autocomplete"

const [value, setValue] = React.useState("")

<Autocomplete
  options={["Next.js", "Vite", "Astro"]}
  value={value}
  onValueChange={setValue}
  placeholder="Search framework..."
/>

The list filters against what the user types (case-insensitive includes), but the input accepts arbitrary text — that’s what separates it from the select-style Combobox. Reach for Autocomplete when the suggestions are hints (a search box, a tag entry); reach for Combobox when the value must come from a fixed set.

Keyboard

  • / move the active suggestion.
  • Enter picks the active suggestion.
  • Esc closes the list, keeping what you typed.

API

Prop Type Default
options string[] — (required)
value string — (controlled)
defaultValue string ""
onValueChange (value: string) => void
emptyMessage string "No results."
…props React.ComponentProps<"input">