Skip to content

Enhance authored trigger, value, and listbox anatomy. Custom element

Select
Copy this markup
<ui-select value="ready" name="status">
<label id="release-status-label">Release status</label>
<button class="ui-button" data-ui-part="trigger" type="button" popovertarget="release-status-listbox" aria-labelledby="release-status-label release-status-value">
<span data-ui-part="value" id="release-status-value">Ready</span>
</button>
<div id="release-status-listbox" data-ui-part="listbox" role="listbox" popover="auto" aria-label="Release status">
<div data-ui-part="option" role="option" data-ui-value="draft">Draft</div>
<div data-ui-part="option" role="option" data-ui-value="ready">Ready</div>
<div data-ui-part="option" role="option" data-ui-value="published">Published</div>
</div>
</ui-select>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/core/floating.css'
import '@timelessui/components/css/core/options.css'
import '@timelessui/components/css/core/select.css'
import '@timelessui/components/css/core/button.css'
import '@timelessui/components/css/themes/atmosphere/tokens.css'
import '@timelessui/components/css/themes/atmosphere/button.css'
import '@timelessui/components/css/themes/atmosphere/select.css'
import '@timelessui/components/css/themes/atmosphere/options.css'
import '@timelessui/components/register/ui-select'

A register/ import is a side effect: it defines the element as the module evaluates, so it has to run in code the browser loads. To register explicitly instead — to control the timing, or to define into another window — call the function from the matching define/ entry point, which registers nothing on its own:

Explicit registration
import { defineSelectElement } from '@timelessui/components/define/ui-select'
defineSelectElement()

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
triggerYes[data-ui-part~='trigger']Native button that opens the listbox. Timeless gives it role="combobox", which the Select-Only Combobox pattern asks for; that role takes no name from its content, so give the trigger aria-labelledby or aria-label yourself.
valueNo[data-ui-part~='value']Element inside the trigger that shows the selected label. Timeless writes its text and nothing else.
searchNo[data-ui-part~='search']Text field inside the surface that filters the options under searchable. Left and Right move the caret rather than the highlight.
surfaceNo[data-ui-part~='surface']The popover the listbox sits in. Author it whenever the surface also holds a search field, a header, a footer, or a pager: a role="listbox" may own only options and groups, so those siblings belong beside the listbox rather than inside it. With none of them, the listbox is its own surface and this part is unnecessary.
listboxYes[role='listbox']The option container.
optionYes[role='option']One option. Its value comes from value, then data-ui-value, then its text. Mark unavailable options aria-disabled="true".
option-indicatorNo[data-ui-part~='option-indicator']Decorative affordance inside an option showing that it is selected. Style it from [aria-selected="true"]; it is hidden from assistive technology.
groupNo[data-ui-part~='group']A role="group" wrapper around related options. Options inside it stay navigable, and the group collapses when every option it holds is filtered out.
group-labelNo[data-ui-part~='group-label']The label for a group, wired to it with aria-labelledby.
separatorNo[role='separator']A visual divider between options. Navigation and typeahead skip it.
emptyNo[data-ui-part~='empty']Shown when no option is visible. Hidden again as soon as one is.
statusNo[data-ui-part~='status']A role="status" aria-live="polite" region for result counts, loading, and errors.
headerNo[data-ui-part~='header']Optional content at the top of the surface. Excluded from arrow navigation and reachable with Tab.
footerNo[data-ui-part~='footer']Optional content at the bottom of the surface. Excluded from arrow navigation and reachable with Tab.
pagerNo[data-ui-part~='pager']Wraps the page controls. Hidden unless page-size is set and the options span more than one page.
page-previousNo[data-ui-part~='page-previous']Moves to the previous page. Stays focusable at the first page and takes aria-disabled, so the boundary is discoverable rather than gone.
page-nextNo[data-ui-part~='page-next']Moves to the next page, with the same boundary behavior.
page-statusNo[data-ui-part~='page-status']A role="status" aria-live="polite" region announcing the current page.
chipsNo[data-ui-part~='chips']Container the selected values are rendered into under multiple.
chip-templateNotemplate[data-ui-part~='chip-template']A <template> holding the markup for one chip. Timeless clones it per selected value and fills it in, so every element and class in a chip is yours. Without it a chips container receives a plain comma-separated summary instead.
chipNo[data-ui-part~='chip']One selected value, authored inside chip-template.
chip-labelNo[data-ui-part~='chip-label']Where the selected label is written inside a chip. Omit it only when the chip has no other content.
chip-removeNo[data-ui-part~='chip-remove']Removes its chip. Author it as a real button; Timeless writes the value it removes onto it as data-ui-value and gives it an accessible name naming that value, since one shared template cannot. An aria-label you author wins.
clearNo[data-ui-part~='clear']Empties the whole selection. Marked aria-disabled="true" while there is nothing to clear, rather than disabled, so activating it cannot disable the control that holds focus.

These parts also accept per-item input of their own. No stylesheet selects these attributes — the component reads them.

PartAttributeDescription
optiondata-ui-valueThe value this option submits, when its text is not the value. value wins over it, and its own text is the fallback.
optiondata-ui-labelThe text filtering and typeahead match against, when the visible content is not what a reader would type. label wins over it, then this, then aria-label, then the option text. None of the four change the accessible name.

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
openpresenceabsentPresent to render the listbox open on load.
placementbottom · top · right · leftbottomPreferred side of the trigger for the listbox surface.
searchablepresenceabsentPresent to filter from a search field inside the surface. Focus moves into that field on open and stays there; the highlight travels through aria-activedescendant.
valueany string—The option selected on load and after a form reset. Once the user commits a change the attribute stops applying, the way it does on a native input.
alignstart · endstartWhich edge of the trigger the surface aligns to. The surface is never narrower than the trigger.
filtercontains · starts-with · offcontainsHow typed text narrows the options. off hands visibility to you: listen for ui-input and set hidden yourself, and navigation, the empty state, group collapse, and paging all follow.
multiplepresenceabsentPresent to allow more than one selected option. Selected values render as chips and submit one form entry each under the same name.
nameany string—Form field name. The element submits its own value through ElementInternals.
requiredpresenceabsentPresent to block submission while nothing is selected, with valueMissing.
disabledpresenceabsentPresent to disable the control. A control inside a disabled <fieldset> is disabled too, and submits nothing either way.
page-sizeany number—Options to render per page. Absent means unpaged, which is the default and adds no pager. The resolved number is available on the read-only pageCount property.

Element API

Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.

<ui-select>

PropertyTypeNotes
openbooleanReflects the open attribute, documented above.
placement'bottom' | 'top' | 'right' | 'left'Reflects the placement attribute, documented above.
searchablebooleanReflects the searchable attribute, documented above.
defaultValuestringReflects the value attribute, documented above.
valuestringLive value. Assigning it does not rewrite the authored default and does not dispatch transition events.
align'start' | 'end'Reflects the align attribute, documented above.
filter'contains' | 'starts-with' | 'off'Reflects the filter attribute, documented above.
multiplebooleanReflects the multiple attribute, documented above.
namestringReflects the name attribute, documented above.
requiredbooleanReflects the required attribute, documented above.
disabledbooleanReflects the disabled attribute, documented above.
pageSizestringReflects the page-size attribute, documented above.
EventDetailDescription
ui-before-changeCustomEvent<SelectChangeDetail>Cancelable proposal dispatched before the selected option changes. Call preventDefault() to reject the transition and keep the current value.
ui-changeCustomEvent<SelectChangeDetail>Dispatched after the selected option has changed. Bubbles and is composed.
ui-openCustomEvent<SelectToggleDetail>Dispatched after the listbox opens.
ui-closeCustomEvent<SelectToggleDetail>Dispatched after the listbox closes.
ui-inputCustomEvent<SelectInputDetail>Dispatched when the query text changes, before options are filtered. Under filter="off" this is where you set hidden yourself.
ui-pageCustomEvent<SelectPageDetail>Dispatched after the rendered page of a paged list changes.

Styling

Root identity: ui-select. Required stylesheets: tokens.css, core/floating.css, core/options.css, core/select.css, core/button.css, themes/atmosphere/tokens.css, themes/atmosphere/button.css, themes/atmosphere/select.css, themes/atmosphere/options.css.

Set these custom properties to restyle the component:

Custom propertyControls
--ui-collection-surface-inline-sizeMinimum width of the listbox surface. The trigger width wins whenever it is larger.
--ui-floating-offsetGap between the trigger and the surface.
Design tokens this component reads (32)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-accent · --ui-accent-soft · --ui-bg-accent · --ui-bg-accent-active · --ui-bg-accent-hover · --ui-bg-control · --ui-bg-control-active · --ui-bg-control-hover · --ui-bg-control-muted · --ui-bg-danger · --ui-bg-danger-active · --ui-bg-danger-hover · --ui-bg-surface · --ui-bg-surface-raised · --ui-disabled-opacity · --ui-duration-fast · --ui-ease-standard · --ui-fg · --ui-fg-muted · --ui-focus · --ui-line · --ui-radius-control · --ui-radius-lg · --ui-radius-sm · --ui-shadow-control-accent · --ui-shadow-control-active · --ui-shadow-control-danger · --ui-shadow-floating · --ui-shadow-outline-control · --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 Select-Only Combobox pattern from the ARIA Authoring Practices Guide.

KeyAction
Enter / SpaceOpen the listbox, or commit the active option when it is already open.
Arrow keysOpen the listbox from the closed trigger, or move the active option when it is already open.
Home / EndMove to the first or last option while the listbox is open.
EscapeClose the listbox without changing the value.
Printable charactersTypeahead over the option labels. On a closed Select this selects a match without opening, as the native control does.
BackspaceIn an empty search field under multiple, removes the last chip.

Timeless gives the trigger role="combobox", which is what the Select-Only Combobox pattern asks for and what makes aria-activedescendant legal on it. Your own role wins over that, and the relationship follows the role: set one that cannot carry aria-activedescendant, such as button, and Timeless writes no relationship rather than an invalid one, while the active option is still highlighted — checkMarkup reports the role, because the degradation is otherwise silent. That role does not take its name from its content, so the trigger needs your aria-labelledby or aria-label; checkMarkup reports it when missing. Focus stays on the trigger and the active option is announced through aria-activedescendant; under searchable focus moves into the search field instead and the same mechanism carries the highlight. The trigger carries popovertarget, so it opens the surface before any script runs. Light dismiss and Escape come from the Popover API. header, footer, and the pager sit outside arrow navigation and are reached with Tab.

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