Listbox
Keyboard selection over authored options. Custom element
<ui-listbox id="status-list" value="ready" role="listbox" aria-label="Status"> <div role="option" data-ui-value="draft">Draft</div> <div role="option" data-ui-value="ready">Ready</div> <div role="option" data-ui-value="published">Published</div></ui-listbox>Install
import '@timelessui/components/css/tokens.css'import '@timelessui/components/css/listbox.css'import '@timelessui/components/define/ui-listbox'Anatomy
Parts are authored in your own markup and identified by the selector below, so your CSS can target the same anatomy without loading Timeless styles. Required parts must be present for the component to work. Private data-ui-internal-* hooks are written by the runtime and must never be authored.
| Part | Required | Selector | Purpose |
|---|---|---|---|
listbox | Yes | [role='listbox'] | The option container. |
option | Yes | [role='option'] | One option. Its value comes from value, then data-ui-value, then the element id. Mark unavailable options aria-disabled="true". |
Attributes
Every value below is implemented by the stylesheets this component ships. Boolean attributes are presence-based: author the attribute with no value, or omit it.
| Attribute | Values | Default | Description |
|---|---|---|---|
multiple | presence | absent | Present to allow more than one selected option. The value property then reads and writes an array. |
value | any string | — | The option selected on load and after a form reset. Assign the value property for live changes. |
Element API
Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.
<ui-listbox>
| Property | Type | Notes |
|---|---|---|
multiple | boolean | Reflects the multiple attribute, documented above. |
defaultValue | string | Reflects the value attribute, documented above. |
value | string | Live value. Assigning it does not rewrite the authored default and does not dispatch transition events. |
| Event | Detail | Description |
|---|---|---|
ui-before-change | CustomEvent<ListboxChangeDetail> | Cancelable proposal dispatched before the selection changes. Call preventDefault() to reject the transition and keep the current value. |
ui-change | CustomEvent<ListboxChangeDetail> | Dispatched after the selection has changed. Bubbles and is composed. |
State
Native attributes, ARIA, and platform pseudo-classes are authoritative. Style state through the selectors below rather than adding your own state classes.
| State | Source | How to express it |
|---|---|---|
selected | aria | aria-selected="true" on selected options. |
Styling
Root identity: ui-listbox. Required stylesheets: tokens.css, listbox.css.
This component adds no custom properties of its own. Restyle it through the design tokens or your own CSS.
Design tokens this component reads (13)
These are global Atmosphere tokens. Change them once at the theme level rather than per component.
--ui-accent · --ui-accent-soft · --ui-bg-surface · --ui-bg-surface-raised · --ui-disabled-opacity · --ui-fg · --ui-fg-muted · --ui-line · --ui-radius-lg · --ui-radius-sm · --ui-space-1 · --ui-space-2 · --ui-space-3
Accessibility
Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.
Follows the Listbox pattern from the ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Arrow keys | Move focus to the previous or next option, following the orientation and skipping disabled ones. |
| Home / End | Move focus to the first or last enabled option. |
| Page Up / Page Down | Jump ten options at a time. |
| Enter / Space | Select the focused option, or toggle it when multiple is present. |
| Printable characters | Typeahead: jump to the next option whose text starts with what you typed. |
Selection follows aria-selected, and the active option is tracked with aria-activedescendant so focus stays on the listbox.
Before JavaScript runs
The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.
More examples
Open Listbox in StoryLite for variants, controls, and manual testing.