ComboboxNew
A searchable, data-driven single-select — typeahead filtering, grouping, keyboard navigation, an optional create-on-the-fly row, and a loading state, with no Radix or cmdk.
Preview & playground
Edit the code — the preview updates live. Try changing props, text, or classes.
function Demo() { const [value, setValue] = useState("next") const frameworks = [ { value: "next", label: "Next.js", description: "The React framework for the web", group: "Full-stack" }, { value: "remix", label: "Remix", description: "Web standards, nested routes", group: "Full-stack" }, { value: "astro", label: "Astro", description: "Content-driven, islands", group: "Static" }, { value: "vite", label: "Vite", description: "Instant dev server", group: "Build tools" }, { value: "webpack", label: "webpack", description: "The battle-tested bundler", group: "Build tools" }, ] return ( <div className="w-72"> <Combobox options={frameworks} value={value} onValueChange={setValue} placeholder="Pick a framework" searchPlaceholder="Search frameworks…" clearable /> </div> ) } render(<Demo />)
Examples
Common variations — edit any of them live.
Create on the fly
Type a value that isn't in the list and press Enter to add it.
function Demo() { const [options, setOptions] = useState([ { value: "react", label: "React" }, { value: "vue", label: "Vue" }, { value: "svelte", label: "Svelte" }, ]) const [value, setValue] = useState("") return ( <div className="w-72"> <Combobox options={options} value={value} onValueChange={setValue} creatable onCreate={(input) => { const opt = { value: input.toLowerCase(), label: input } setOptions((o) => [...o, opt]) setValue(opt.value) }} placeholder="Pick or create a tag" /> </div> ) } render(<Demo />)
Async loading state
Show a spinner while options are being fetched.
function Demo() { const [loading, setLoading] = useState(false) const [options, setOptions] = useState([]) const load = () => { setLoading(true) setOptions([]) setTimeout(() => { setOptions([ { value: "ada", label: "Ada Lovelace" }, { value: "alan", label: "Alan Turing" }, { value: "grace", label: "Grace Hopper" }, ]) setLoading(false) }, 1200) } return ( <div className="flex w-72 flex-col gap-3"> <Button size="sm" variant="outline" onClick={load}>Simulate fetch</Button> <Combobox options={options} loading={loading} placeholder="Load people…" /> </div> ) } render(<Demo />)
Installation
Copy the source into your project with the registry CLI:
$pnpm dlx shadcn@latest add @stacklyui/comboboxOr install the package and import it:
$pnpm add @stacklyui/ui motionUsage
No Radix, no cmdk — pass an array of options and the Combobox handles the rest: case-insensitive typeahead (add keywords for extra match terms), group headings, and the full ARIA combobox keyboard pattern (↑/↓ to move, Home/End to jump, Enter to pick, Esc to close). The dropdown is portal-positioned and flips up automatically when there's no room below. Opt into clearable for a reset ×, creatable + onCreate for an inline “Create …” row, and loading for a spinner while you fetch. Works controlled (value + onValueChange) or uncontrolled (defaultValue), and drops a hidden input when you pass name.