Listbox
Shared listbox state and keyboard navigation hook. Manages selection, highlight, and container ARIA props for listbox-pattern components like menu and navigation-list.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
Parameters
Returns
Examples
Basic Listbox
Notes
Keyboard Navigation
Arrow keys and their vim aliases j/k move highlight through items with role="option" inside the container. Enter and Space select the highlighted item. With typeahead enabled, j/k still move the highlight on an empty query buffer and only extend a query already in progress. Navigation uses @diffgazer/keys's useNavigation internally.
Controlled & Uncontrolled
Both selection and highlight support controlled and uncontrolled modes via useControllableState. Pass selectedId/highlighted for controlled, or use defaultSelectedId/defaultHighlighted for uncontrolled.
Used By
Built into menu and navigation-list components. Provides the shared listbox interaction pattern so each component only needs to handle its own rendering.
Source
Highlighted source loads after this disclosure opens. Browse the source repository.