Tab Layout
An ARIA tablist with active-tab state, roving keyboard navigation (Arrow / Home / End, skipping disabled tabs), badges, and a swapping panel. A Lit web component.
Preview
<esa-tab-layout id="tabs">
<div slot="panel-0">Overview content — summary metrics and status.</div>
<div slot="panel-1">Activity content — recent events log.</div>
<div slot="panel-2">Settings content — configuration form.</div>
</esa-tab-layout>
<script>
document.getElementById('tabs').tabs = [
{ label: 'Overview' }, { label: 'Activity' }, { label: 'Settings' },
];
</script> Appearance
Two appearances, aligned to Beacon's UiTabsAppearance. underline (default) shows an underlined indicator on the active tab; segmented renders a segmented control — a sunken, bordered track with a filled selected segment and no indicator. (variant="pill" is the legacy alias for segmented.)
<esa-tab-layout appearance="underline">…</esa-tab-layout>
<esa-tab-layout appearance="segmented">…</esa-tab-layout> Sizes
<esa-tab-layout size="xs">…</esa-tab-layout>
<esa-tab-layout size="sm">…</esa-tab-layout>
<esa-tab-layout size="md">…</esa-tab-layout>
<esa-tab-layout size="lg">…</esa-tab-layout> States
Tabs accept badges, and any tab can be disabled — keyboard navigation skips disabled tabs.
<script>
el.tabs = [
{ label: 'Inbox', badge: 4 },
{ label: 'Drafts', disabled: true },
{ label: 'Archive', badge: 128 },
];
</script> API
| Prop | Type | Default | Description |
|---|---|---|---|
tabs | EsaTab[] | [] | Tab definitions (property, set via JS). Each is { label; icon?; badge?; disabled? }. |
active-index | number | 0 | Index of the selected tab. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Tab height and type scale. Reflected as an attribute. |
appearance | 'underline' | 'segmented' | 'underline' | Tab style (aligned to Beacon): underlined indicator or a segmented control on a sunken track. Reflected as an attribute. |
variant | 'underline' | 'pill' | 'underline' | Legacy alias for appearance — pill maps to segmented. Prefer appearance. |
Events
| Event | Type | Default | Description |
|---|---|---|---|
tabchange | CustomEvent | — | Fired when the active tab changes. detail: { index: number }. Bubbles and composed. |
tabs is an array property — set it in JS, not as an attribute. Each EsaTab.icon is a raw inline SVG string.
Slots
| Prop | Type | Default | Description |
|---|---|---|---|
panel-{index} | slot | — | Content for the matching tab; the active panel is shown. Falls back to the default slot. |
The routed-tabs (RouterOutlet) branch of the Angular component is replaced here by content panels via the named slots above.
Accessibility
- Follows the ARIA tablist pattern:
role="tablist"/role="tab"/role="tabpanel"witharia-selected. - Roving
tabindex— only the active tab is in the tab order; ArrowLeft / ArrowRight / Home / End move focus and selection, skipping disabled tabs. - Disabled tabs are non-interactive and excluded from keyboard traversal.
Theming surface
Every public token this component reads, extracted from its source at build time.
The Resolves to column walks each token's real lineage —
component → semantic → primitive → raw value — so you
can see exactly where re-pointing it lands. A spoke re-skins by overriding these in
its theme-<slug>.css; component internals are never edited. No
hook for what you need? File it with /request-lego.
| Token | Tier | Resolves to |
|---|---|---|
--focus-ring-color | component | #65ba74 via --color-border-focus → --color-grass-8 |
--focus-ring-width | component | 2px |
--tab-layout-border-color | component | #cecece via --color-border → --color-gray-7 |
--tab-layout-color | component | #646464 via --color-text-secondary → --color-gray-11 |
--tab-layout-color-active | component | #46a758 via --color-primary → --color-grass-9 |
--tab-layout-height-lg | component | 52px |
--tab-layout-height-md | component | 44px |
--tab-layout-height-sm | component | 36px |
--tab-layout-height-xs | component | 30px |
--tab-layout-indicator-color | component | #46a758 via --color-primary → --color-grass-9 |
--color-border | semantic | #cecece via --color-gray-7 |
--color-primary | semantic | #46a758 via --color-grass-9 |
--color-surface | semantic | #fcfcfc via --color-gray-1 |
--color-surface-sunken | semantic | #f0f0f0 via --color-gray-3 |
--color-text-inverse | semantic | #fcfcfc via --color-gray-1 |
--color-text-primary | semantic | #202020 via --color-gray-12 |
--type-size-100 | semantic | clamp(0.625rem, 0.56rem + 0.32vw, 0.75rem) |
--type-size-150 | semantic | clamp(0.6875rem, 0.61rem + 0.38vw, 0.875rem) |
--type-size-200 | semantic | clamp(0.75rem, 0.66rem + 0.44vw, 0.9375rem) |
--type-size-300 | semantic | clamp(0.875rem, 0.77rem + 0.52vw, 1.125rem) |
--font-weight-medium | primitive | 500 |
--font-weight-semibold | primitive | 550 |
--radius-100 | primitive | 0.25rem |
--radius-200 | primitive | 0.5rem |
--radius-full | primitive | 9999px |
--shadow-50 | primitive | 0 1px 4px 0 rgba(0, 0, 0, 0.03) |
--spacing-050 | primitive | 0.125rem |
--spacing-100 | primitive | 0.25rem |
--spacing-150 | primitive | 0.375rem |
--spacing-200 | primitive | 0.5rem |
--spacing-300 | primitive | 0.75rem |
--spacing-400 | primitive | 1rem |
--spacing-500 | primitive | 1.5rem |