An autocomplete input with a dropdown list of suggestions.
Loading...
"use client"
import {Installation
pnpmnpmyarnbun
Usage
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from "@/components/ui/combobox"const items = ["Next.js", "SvelteKit", "Nuxt.js", "Remix"] as const
<Combobox items={items}>
<ComboboxInput placeholder="Select..." />
<ComboboxContent>
<ComboboxEmpty>No results.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>Examples
With Clear Button
Use showClear to display a clear button when a value is selected.
Loading...
"use client"
import {With Objects
Pass an array of objects as items. Use the object's properties to render custom content.
Loading...
"use client"
import * as React from "react"Multiple Selection
Use multiple for multi-select with chips display.
Loading...
"use client"
import * as React from "react"API Reference
Components
Combobox
ComboboxInput
ComboboxContent
ComboboxItem
ComboboxChip
useComboboxAnchor
Hook that returns a ref for custom anchor positioning with ComboboxChips.
const anchor = useComboboxAnchor()
<ComboboxChips ref={anchor}>...</ComboboxChips>
<ComboboxContent anchor={anchor}>...</ComboboxContent>