Skip to content

Combobox

Filter an authored listbox from a native text input. Custom element

Combobox
Copy this markup
<ui-combobox>
<label for="component-search">Component</label>
<input id="component-search" role="combobox" type="text" aria-autocomplete="list">
<div role="listbox" popover="manual">
<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>
</div>
</ui-combobox>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/combobox.css'
import '@timelessui/components/css/listbox.css'
import '@timelessui/components/css/popover.css'
import '@timelessui/components/define/ui-combobox'

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.

PartRequiredSelectorPurpose
inputYes[role='combobox']The native text input. Timeless wires aria-expanded, aria-controls, and aria-activedescendant.
listboxYes[role='listbox']The option container.
optionYes[role='option']One option. Its value comes from value, then data-ui-value, then the element id. Filtering hides non-matching options.

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.

AttributeValuesDefaultDescription
valueany stringThe 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-combobox>

PropertyTypeNotes
defaultValuestringReflects the value attribute, documented above.
valuestringLive value. Assigning it does not rewrite the authored default and does not dispatch transition events.
EventDetailDescription
ui-before-changeCustomEvent<ComboboxChangeDetail>Cancelable proposal dispatched before the selected option changes. Call preventDefault() to reject the transition and keep the current value.
ui-changeCustomEvent<ComboboxChangeDetail>Dispatched after the selected option has changed. Bubbles and is composed.

Styling

Root identity: ui-combobox. Required stylesheets: tokens.css, combobox.css, listbox.css, popover.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 (18)

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-focus · --ui-line · --ui-line-strong · --ui-radius-lg · --ui-radius-md · --ui-radius-sm · --ui-shadow-floating · --ui-space-1 · --ui-space-2 · --ui-space-3 · --ui-space-4

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 Combobox pattern from the ARIA Authoring Practices Guide.

KeyAction
Arrow Down / Arrow UpOpen the listbox, then move the active option.
Home / EndMove to the first or last matching option.
EnterCommit the active option.
EscapeClose the listbox, then clear the filter on a second press.

Focus stays in the text input at all times; the active option is exposed with aria-activedescendant. Filtering hides non-matching options rather than removing them.

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 Combobox in StoryLite for variants, controls, and manual testing.