Forms
Combobox
A field that filters a list as you type: for a long list, where a select would need scrolling.
import { Combobox, ComboboxContent, ComboboxInput, ComboboxItem, ComboboxList } from 'omuk-ui/combobox';Forms
A field that filters a list as you type: for a long list, where a select would need scrolling.
import { Combobox, ComboboxContent, ComboboxInput, ComboboxItem, ComboboxList } from 'omuk-ui/combobox';Change the props on the right. The combobox and its code follow.
import {
Combobox,
ComboboxContent,
ComboboxEmpty,
ComboboxInput,
ComboboxItem,
ComboboxList,
} from 'omuk-ui/combobox';
import { Label } from 'omuk-ui/label';
<Label htmlFor={id}>Time zone</Label>
<Combobox items={TIME_ZONES} value={zone} onValueChange={setZone}>
<ComboboxInput id={id} className="w-full" placeholder="Search time zones" showClear />
<ComboboxContent>
<ComboboxEmpty>No time zone matches.</ComboboxEmpty>
<ComboboxList>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxList>
</ComboboxContent>
</Combobox>The list shows the items that contain the typed text, with no regard to case or accents. ComboboxList draws each item with its function. showClear adds a button that empties the field.
With multiple, the value is a list and each choice is a chip in the field. A pick keeps the list open; Backspace in an empty field removes the last chip.
ComboboxButton shows the value as a Select does, and a ComboboxInput inside the list is its search. Items can come in groups: each group gives its items to ComboboxCollection.
Combobox is the root and holds the state; the field, the list and the items are its parts.