Combobox
A select with search for long option lists. Single or multiple values; the value type comes from your options.
Status: beta. Category: Forms.
import { Combobox } from '@glyphui/ui'
Exports: Combobox, comboboxStyles.
Notes
- Built on cmdk and Radix Popover: type to filter, arrow keys to move, Enter to choose, Escape to close.
- Search matches the label and any keywords you add to an option.
- Pass name to submit the value with a native form.
Example: Searchable select
import { Combobox, Field } from '@glyphui/ui'
import { useState } from 'react'
const timezones = [
{ value: 'utc', label: 'UTC', keywords: ['gmt'] },
{
value: 'america-new-york',
label: 'New York',
description: 'UTC−5',
keywords: ['est', 'eastern'],
},
{
value: 'america-los-angeles',
label: 'Los Angeles',
description: 'UTC−8',
keywords: ['pst', 'pacific'],
},
{ value: 'europe-berlin', label: 'Berlin', description: 'UTC+1', keywords: ['cet'] },
{ value: 'asia-kolkata', label: 'Kolkata', description: 'UTC+5:30', keywords: ['ist', 'india'] },
{ value: 'asia-tokyo', label: 'Tokyo', description: 'UTC+9', keywords: ['jst'] },
] as const
type Timezone = (typeof timezones)[number]['value']
export default function Example() {
const [zone, setZone] = useState<Timezone | null>('europe-berlin')
return (
<Field label="Timezone" description="Try “ist” or “pacific”." className="max-w-xs">
<Combobox
options={timezones}
value={zone}
onValueChange={setZone}
placeholder="Pick a timezone"
/>
</Field>
)
}
Example: Multiple
Selected values show as chips; the list stays open.
import { Combobox, Field } from '@glyphui/ui'
const labels = [
{ value: 'bug', label: 'Bug' },
{ value: 'feature', label: 'Feature' },
{ value: 'design', label: 'Design' },
{ value: 'docs', label: 'Documentation' },
{ value: 'performance', label: 'Performance' },
{ value: 'a11y', label: 'Accessibility', keywords: ['a11y'] },
]
export default function Example() {
return (
<Field label="Labels" className="max-w-xs">
<Combobox
multiple
options={labels}
defaultValue={['bug', 'design']}
searchPlaceholder="Filter labels…"
/>
</Field>
)
}
Live page: https://glyphui.xyz/components/combobox