Skip to content
Drivn logoDrivn

Combobox

Searchable select with filtering, single and multi selection, and full keyboard navigation. Powered by cmdk.

Preview

Installation

npx drivn add combobox

Usage

1import { useState } from "react"
2import { Combobox } from "@/components/ui/combobox"
3
4const frameworks = [
5 { label: "React", value: "react" },
6 { label: "Vue", value: "vue" },
7 { label: "Angular", value: "angular" },
8 { label: "Svelte", value: "svelte" },
9 { label: "Next.js", value: "nextjs" },
10]
11
12export default function Page() {
13 const [value, setValue] = useState("")
14
15 return (
16 <Combobox value={value} onChange={setValue}>
17 <Combobox.Trigger placeholder="Select framework...">
18 {frameworks.find(f => f.value === value)?.label}
19 </Combobox.Trigger>
20 <Combobox.Content placeholder="Search frameworks...">
21 <Combobox.Empty />
22 {frameworks.map(f => (
23 <Combobox.Item key={f.value} value={f.value}>
24 {f.label}
25 </Combobox.Item>
26 ))}
27 </Combobox.Content>
28 </Combobox>
29 )
30}

Multi Select

With Groups

Clearable

With Icons

Disabled Items

Custom Empty State

API Reference

Combobox

PropTypeDefaultDescription
valuestring | string[]Controlled value. String for single, string[] for multi
onChange(value: string | string[]) => voidCallback when the selected value changes
multiplebooleanfalseEnable multi-select mode with tag chips
classNamestringAdditional CSS classes for the root element

Combobox.Trigger

PropTypeDefaultDescription
placeholderstring"Select..."Text shown when no value is selected
clearablebooleanfalseShow a clear button (X) instead of chevron when a value is selected
childrenReactNodeCustom display for the selected value (single mode)
classNamestringAdditional CSS classes for the trigger

Combobox.Content

PropTypeDefaultDescription
placeholderstring"Search..."Placeholder text for the search input
childrenReactNodeCombobox items, groups, empty, and separators
classNamestringAdditional CSS classes for the dropdown content

Combobox.Item

PropTypeDefaultDescription
valuestringUnique value for the item
iconComponentType | ReactElementIcon component or element displayed before the label
disabledbooleanfalseWhether the item is disabled
childrenReactNodeLabel content for the item
classNamestringAdditional CSS classes for the item

Combobox.Group

PropTypeDefaultDescription
headingstringGroup heading displayed above the items
childrenReactNodeCombobox items within the group
classNamestringAdditional CSS classes for the group

Combobox.Label

PropTypeDefaultDescription
childrenReactNodeLabel text content
classNamestringAdditional CSS classes for the label

Combobox.Empty

PropTypeDefaultDescription
childrenReactNode"No results found."Custom content for the empty state
classNamestringAdditional CSS classes for the empty state

Combobox.Separator

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the separator