Components
Combobox
Search and pick one or several items of any shape, composed from parts: field, panel, search, a virtualized list, empty and create rows.
- Everyday checking•• 4821
- Rainy-day savings•• 0937
- Travel credit card•• 1150
- Brokerage•• 7302
Import
import { Combobox, ComboboxTrigger, ComboboxSearch, ComboboxList, ComboboxItem, ComboboxEmpty, ComboboxCreate } from '@rinzai/zen';Examples
Tags
Several at once (chips, removable), and typing a new name offers to add it: ComboboxCreate (Enter works too).
- Essential
- Work
- Treat
- Annual
Many items
2,000 items: the list renders only the rows in view, so it opens and scrolls instantly. Type to filter.
- Account 0001
- Account 0002
- Account 0003
- Account 0004
- Account 0005
- Account 0006
- Account 0007
- Account 0008
- Account 0009
- Account 0010
- Account 0011
- Account 0012
- Account 0013
- Account 0014
- Account 0015
- Account 0016
API reference
<Combobox>
Pick one or several items from a list you can search: a field that opens a panel with a search box and the matching items. Compose it from ComboboxTrigger, ComboboxPopup, ComboboxSearch, ComboboxList (virtualized, for long lists), ComboboxItem, ComboboxEmpty and ComboboxCreate. Keyboard: Enter, Space or ↓ on the field opens it, typing searches, ↑↓ move, Enter chooses, Escape closes. Items can be any shape: say how to read a key and text from one with itemKey and itemText.
| Prop | Type | Default |
|---|---|---|
itemsRequired | readonly T[] | — |
onValueChangeRequired | ((key: string) => void) | ((keys: string[]) => void) | — |
valueRequired | string | readonly string[] | null | — |
filterWhether an item matches the search (default: its text contains it, any case). | ((item: T, query: string) => boolean) | — |
itemKeyHow to read an item's unique key (default: its | ((item: T) => string) | — |
itemTextHow to read an item's text, shown and searched (default: its | ((item: T) => string) | — |
multiple | boolean | — |
selectedItemsChosen items that aren't in | readonly T[] | — |
<ComboboxTrigger>
The field: shows the choice (text, or chips when multiple) or the placeholder, and opens the panel. Pass children to show the value your own way.
| Prop | Type | Default |
|---|---|---|
childrenYour own display of the value (default: its text, or chips). | ReactNode | — |
disabled | boolean | — |
placeholderShown while nothing is chosen. | string | Select an Item |
<ComboboxSearch>
The search box: focused when the panel opens; ↑↓ move through the matches and Enter chooses.
| Prop | Type | Default |
|---|---|---|
aria-label | string | Search options |
placeholder | string | Search |
<ComboboxList>
The matching items, rendered only while in view (so thousands stay fast). Rows are itemHeight px tall; renderItem draws each (default: a ComboboxItem). Put ComboboxEmpty or ComboboxCreate inside for no matches.
| Prop | Type | Default |
|---|---|---|
itemHeightHeight of every row, in px (default 35). | number | 35 |
renderItem | ((item: T) => ReactNode) | — |
<ComboboxItem>
One item in a ComboboxList: a check when chosen, then its text (or your own content).
| Prop | Type | Default |
|---|---|---|
itemRequired | T | — |
className | string | — |
<ComboboxEmpty>
Shown when the search matches nothing.
No props of its own; it accepts the props of the element it renders.
<ComboboxCreate>
Offered when the search matches nothing: adds what was typed (Enter works too). children renders the row from the text (default "Add …").
| Prop | Type | Default |
|---|---|---|
onCreateRequired | (text: string) => void | — |