Autocomplete
Searchable combobox with keyboard navigation, type-to-filter, and optional multi-select. Supports icons, descriptions, avatars, loading state, helper text, and error state.
Quick Preview
Selected: react
Installation
// Copy fromsrc/components/forms/Autocomplete.tsx
Usage
'use client'import { useState } from 'react'import { Autocomplete } from '@/components/forms/Autocomplete'// Single-select (controlled)export function FrameworkPicker() {const [framework, setFramework] = useState<string | undefined>()return (<Autocompleteoptions={[{ value: 'react', label: 'React', icon: '⚛️' },{ value: 'vue', label: 'Vue', icon: '💚' },{ value: 'next', label: 'Next.js', icon: '▲' },]}value={framework}label="Framework"helperText="Select your preferred framework"onChange={(v) => setFramework(v as string | undefined)}/>)}// Multi-select with max limitexport function SkillsPicker() {const [skills, setSkills] = useState<string[]>([])return (<AutocompletemultiplemaxItems={5}options={SKILLS_OPTIONS}value={skills}label="Skills (max 5)"placeholder="Add skill…"onChange={(v) => setSkills(v as string[])}/>)}
Examples
Single select
Default mode — pick one option.
selected: react
Multi-select
Pass multiple to pick many options. Selected items appear as chips inside the input.
selected: [react, next]
With icons and descriptions
Add icon and description to each option.
Loading state
Show a spinner while async results load.
With helper text
Provide contextual hint below the input.
Choose the framework for your project
With error state
Display validation error below input.
This field is required
Disabled
Pass disabled to prevent interaction.
Prompt Preview
Copy a prompt that recreates this UI
Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.
Copy-ready AI prompt
Starts from the current visual reference and project constraints.
Tweak only product-specific copy or data after the first generation pass.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options* | AutocompleteOption[] | - | Array of selectable options |
value | string | string[] | - | Controlled selected value(s) |
defaultValue | string | string[] | - | Uncontrolled default value(s) |
multiple | boolean | false | Enable multi-selection; selected items render as chips |
placeholder | string | 'Search…' | Input placeholder text |
label | string | - | Label displayed above the input |
helperText | string | - | Helper text shown below the input |
errorText | string | - | Error message; overrides helperText and adds red ring |
disabled | boolean | false | Disables all interaction |
loading | boolean | false | Replaces chevron with spinner |
clearable | boolean | true | Show × button to clear selection |
maxItems | number | - | Limit selected items in multi mode |
noOptionsText | string | 'No options found' | Empty-state label |
onChange | (value: string | string[] | undefined) => void | - | Fires when selection changes |
onSearch | (query: string) => void | - | Fires on each keystroke — use for async data fetching |
Keyboard Navigation
| Key | Action |
|---|---|
| ↓ / ↑ | Move focus through options |
| Enter | Select focused option |
| Escape | Close dropdown and blur input |
| Backspace | Remove last selected chip (multi mode, when input is empty) |
| Tab | Close dropdown and move focus to next element |