UIComponentsReact
A list of options that is always on the page, with one or many selected, moved through with the arrow keys.
Built on the headless Listbox.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/listbox.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
Put one ListboxItem per option inside Listbox, each holding a ListboxItemText and, to mark what is selected, a ListboxItemIndicator. ListboxGroup with its ListboxGroupLabel heads a set of options, ListboxSeparator divides sets, and ListboxEmpty shows while there are none. Give the listbox a name with aria-label, aria-labelledby or a FieldLabel. The keys, the typeahead, the ranges, the form value and virtualization come from the headless Listbox.
import {
Listbox,
ListboxEmpty,
ListboxGroup,
ListboxGroupLabel,
ListboxItem,
ListboxItemIndicator,
ListboxItemText,
ListboxSeparator,
} from '@/components/ui/listbox'Examples
Default
Two groups of produce with a separator, one option selected and one disabled.
Multiple
Toppings with a checkbox's box in each option, two selected.
Rendered by React 19.3.1
The box is Input's and the options are Select's items: the focused option is filled with the accent color and ringed inside its edges, and the selected one takes a tinted ground with a check at its end. In a multiple listbox the indicator is a Checkbox's box; pass keepMounted so an unchecked box stays. Set a height with class and the options scroll. This item takes Base UI's component ID as its slug and one name per Base UI part.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Listbox's API reference.