Tabs
Associate tabs and panels with native keyboard behavior. Custom element
<ui-tabs id="package-tabs" value="install"> <div role="tablist" aria-label="Package details" aria-orientation="horizontal"> <button id="package-tabs-install-tab" value="install" role="tab" aria-controls="package-tabs-install-panel" aria-selected="true" tabindex="0" type="button">Install</button> <button id="package-tabs-usage-tab" value="usage" role="tab" aria-controls="package-tabs-usage-panel" aria-selected="false" tabindex="-1" type="button">Usage</button> </div> <section id="package-tabs-install-panel" role="tabpanel" aria-labelledby="package-tabs-install-tab" tabindex="0"> <p>Install from the workspace package.</p> </section> <section id="package-tabs-usage-panel" role="tabpanel" aria-labelledby="package-tabs-usage-tab" tabindex="0" hidden> <p>Author native Light DOM anatomy.</p> </section></ui-tabs>Install
import '@timelessui/components/css/tokens.css'import '@timelessui/components/css/tabs.css'import '@timelessui/components/define/ui-tabs'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 |
|---|---|---|---|
tablist | Yes | [role='tablist'] | Container for the tabs. |
tab | Yes | [role='tab'] | One tab. Use <button type="button"> and give it a value; Timeless wires id, aria-controls, aria-selected, and tabindex. |
tabpanel | Yes | [role='tabpanel'] | One panel per tab, in the same order. Timeless wires id, aria-labelledby, and hidden. |
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 |
|---|---|---|---|
activation | automatic · manual | automatic | Whether moving focus with the arrow keys selects the tab immediately (automatic) or waits for Enter or Space (manual). Use manual when selecting a tab is expensive. |
orientation | horizontal · vertical | horizontal | Arrow-key axis. Mirrored onto aria-orientation on the tablist during enhancement. |
value | any string | — | The tab selected on load and after a form reset. Match a tab’s value attribute. 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-tabs>
| Property | Type | Notes |
|---|---|---|
activation | 'automatic' | 'manual' | Reflects the activation attribute, documented above. |
orientation | 'horizontal' | 'vertical' | Reflects the orientation 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<TabsChangeDetail> | Cancelable proposal dispatched before the selected tab changes. Call preventDefault() to reject the transition and keep the current value. |
ui-change | CustomEvent<TabsChangeDetail> | Dispatched after the selected tab 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 the active tab. |
Styling
Root identity: ui-tabs. Required stylesheets: tokens.css, tabs.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 (12)
These are global Atmosphere tokens. Change them once at the theme level rather than per component.
--ui-accent · --ui-accent-soft · --ui-duration-fast · --ui-ease-standard · --ui-fg · --ui-fg-muted · --ui-focus · --ui-line · --ui-radius-md · --ui-space-2 · --ui-space-4 · --ui-space-5
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 Tabs pattern from the ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Arrow keys | Move focus between tabs along the orientation axis. |
| Home / End | Move focus to the first or last tab. |
| Enter / Space | Select the focused tab. Only needed when activation is manual; with automatic the arrow keys select as they move. |
The tablist is one tab stop: Tab moves into the selected tab, then out to the panel. Timeless manages roving tabindex, aria-selected, and panel hidden.
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 Tabs in StoryLite for variants, controls, and manual testing.