Skip to content

Tabs

NavigationSince 0.2.0

Switch between peer views of related content. Tabs implements the WAI-ARIA APG Tabs pattern: a labelled tablist of native buttons with a roving tabindex, and one tabpanel per tab. Activation is automatic (select on focus) or manual (Enter/Space), orientation is horizontal or vertical, arrow keys are mirrored in RTL, and a horizontal tablist that overflows scrolls with the selected tab kept in view.

  • Accessible tab panelsTabs and panels are linked for screen readers, with roving focus on the tab list.
  • Automatic or manualActivate tabs as focus moves, or only when users press Enter or Space.
  • Two orientationsHorizontal or vertical layouts with the matching arrow key mapping and RTL support.
  • Disabled tabsDisabled tabs stay visible and are skipped by keyboard navigation.

Use it for

  • Switching between peer views of related content in the same context, such as Overview, Activity, and Settings.
  • Reducing page length when users need only one section at a time.

Use something else for

  • Sequential steps: use a stepper or wizard.
  • Navigating between pages or routes: use links (navigation bar, breadcrumb).
  • Content users need to compare side by side.
  • Many sections users read in order: use headings or an accordion.
Anatomy
<div class="aui-tabs aui-tabs--horizontal"> (consumer host)
<div class="aui-tabs__list" role="tablist" aria-label aria-orientation>
<button class="aui-tabs__tab" role="tab" id aria-selected aria-controls tabindex>
<svg class="aui-icon" aria-hidden="true"> (optional)
<span class="aui-tabs__label">Label</span>
</button>
...
</div>
<div class="aui-tabs__panels">
<div class="aui-tabs__panel" role="tabpanel" id aria-labelledby tabindex="0"> (selected)
<div class="aui-tabs__panel" role="tabpanel" hidden> (inactive)
</div>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

The part of the Application shell showcase that uses Tabs. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Navigation showcase: an application shell with a collapsible sidebar, a menu bar, breadcrumb,
// tabs, a stepper, pagination, an actions menu, and a context menu, all kept in sync.
import { Breadcrumb } from '@absoluteui/components/breadcrumb';
import { Button } from '@absoluteui/components/button';
import { ContextMenu } from '@absoluteui/components/context-menu';
import { Menu, type MenuItem } from '@absoluteui/components/menu';
import { MenuBar } from '@absoluteui/components/menu-bar';
import { Pagination, type PaginationChangeDetail } from '@absoluteui/components/pagination';
import { Sidebar, type SidebarChangeDetail } from '@absoluteui/components/sidebar';
import { Stepper } from '@absoluteui/components/stepper';
import { Tabs } from '@absoluteui/components/tabs';
import { annotate, choice, createShowcase, hostIn, section, toggle } from './kit.js';
const sc = createShowcase({
title: 'Application shell',
description: 'Choose a page in the sidebar, open menus with the keyboard, switch tabs, step through onboarding, and page through results.',
});
// The shell (sidebar, menu bar, breadcrumb, actions menu, tabs); the directory and the stepper
// follow in their own sections, so each component's focus view stays small.
const shell = annotate(hostIn(sc.stage), ['sidebar', 'menu-bar', 'breadcrumb', 'menu', 'tabs']);
shell.className = 'sc-shell';
const side = hostIn(shell);
side.className = 'sc-shell__side';
const main = hostIn(shell, 'main');
main.className = 'sc-shell__main';
const PAGES: Record<string, string> = { dashboard: 'Dashboard', people: 'People', teams: 'Teams', payroll: 'Payroll', reports: 'Reports', settings: 'Settings' };
const sidebar = Sidebar.create(side, {
label: 'Main',
value: 'people',
collapsible: true,
expanded: ['org'],
items: [
{ id: 'dashboard', label: 'Dashboard', icon: 'list-bulleted' },
{ type: 'group', id: 'org', label: 'Organization', icon: 'menu', items: [
{ id: 'people', label: 'People' },
{ id: 'teams', label: 'Teams' },
] },
{ id: 'payroll', label: 'Payroll', icon: 'file' },
{ id: 'reports', label: 'Reports', icon: 'filter' },
{ id: 'settings', label: 'Settings', icon: 'more-horizontal', disabled: true },
],
});
const bar = MenuBar.create(hostIn(main), {
label: 'Application',
items: [
{ id: 'file', label: 'File', items: [{ id: 'new', label: 'New employee' }, { id: 'import', label: 'Import…' }, { type: 'separator' }, { id: 'export', label: 'Export CSV' }] },
{ id: 'view', label: 'View', items: [{ type: 'checkbox', id: 'compact', label: 'Compact rows', checked: false }, { type: 'checkbox', id: 'photos', label: 'Show photos', checked: true }, { type: 'separator' }, { type: 'radio', id: 'sort-name', label: 'Sort by name', group: 'sort', checked: true }, { type: 'radio', id: 'sort-date', label: 'Sort by start date', group: 'sort', checked: false }] },
{ id: 'help', label: 'Help', items: [{ id: 'shortcuts', label: 'Keyboard shortcuts' }, { id: 'about', label: 'About' }] },
],
});
const crumbs = Breadcrumb.create(hostIn(main), { items: [{ label: 'Home', href: '#home' }, { label: 'Organization', href: '#org' }, { label: 'People' }] });
const title = document.createElement('h2');
title.className = 'sc-shell__title';
title.textContent = 'People';
main.append(title);
const actionsRow = hostIn(main);
actionsRow.className = 'sc-row';
const trigger = Button.create({ text: 'Actions', icon: 'chevron-down', iconPosition: 'end' }, document);
actionsRow.append(trigger.element);
const actionItems: MenuItem[] = [
{ id: 'invite', label: 'Invite people', icon: 'plus' },
{ id: 'download', label: 'Download list', icon: 'download' },
{ type: 'separator' },
{ type: 'group', label: 'Danger zone', items: [{ id: 'archive', label: 'Archive team', icon: 'trash' }] },
];
Menu.create(trigger.element, { items: actionItems, label: 'Actions' });
const tabs = Tabs.create(hostIn(main), {
label: 'People views',
tabs: [
{ id: 'directory', label: 'Directory' },
{ id: 'onboarding', label: 'Onboarding' },
{ id: 'archived', label: 'Archived', disabled: true },
],
value: 'directory',
});
// Directory: a list with a context menu and pagination.
const people = ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu', 'Hiro Tanaka', 'Inés García', 'Jonas Berg', 'Kofi Mensah', 'Lena Novak', 'Mateo Rossi', 'Nora Lind', 'Omar Aziz', 'Priya Shah', 'Quinn Moore', 'Rosa Diaz', 'Sami Kallio', 'Tomas Weber', 'Uma Rao', 'Victor Hugo', 'Wen Li'];
const pageSize = 5;
const directoryText = document.createElement('p');
directoryText.textContent = `${String(people.length)} people in Organization.`;
tabs.panel('directory')?.append(directoryText);
const directory = section(sc, 'People directory', ['pagination', 'context-menu']);
const list = document.createElement('ul');
list.className = 'sc-people';
list.tabIndex = 0;
list.setAttribute('aria-label', 'People on this page. Press Shift+F10 or the context menu key for actions.');
directory.append(list);
const pager = Pagination.create(hostIn(directory), { page: 1, total: people.length, pageSize, pageSizes: [5, 10], showSummary: true, showFirstLast: true });
let size = pageSize;
const renderPage = (page: number): void => {
list.replaceChildren(
...people.slice((page - 1) * size, page * size).map((p) => {
const li = document.createElement('li');
li.textContent = p;
return li;
}),
);
};
renderPage(1);
pager.host.addEventListener('aui-change', (e) => {
const d = (e as CustomEvent<PaginationChangeDetail>).detail;
size = d.pageSize ?? size;
renderPage(d.page);
});
ContextMenu.create(list, {
label: 'Person actions',
items: [
{ id: 'open', label: 'Open profile' },
{ id: 'message', label: 'Send message' },
{ type: 'separator' },
{ type: 'checkbox', id: 'favorite', label: 'Favorite', checked: false },
],
});
// Onboarding: a stepper.
const onboardingText = document.createElement('p');
onboardingText.textContent = 'Onboarding: one of four steps complete.';
tabs.panel('onboarding')?.append(onboardingText);
const onboarding = section(sc, 'Onboarding', ['stepper']);
const stepper = Stepper.create(hostIn(onboarding), {
label: 'Onboarding',
linear: true,
value: 'details',
steps: [
{ id: 'account', label: 'Account', description: 'Email and sign-in', status: 'complete' },
{ id: 'details', label: 'Details', description: 'Role and team' },
{ id: 'documents', label: 'Documents', description: 'Contract and ID' },
{ id: 'review', label: 'Review' },
],
});
sidebar.host.addEventListener('aui-change', (e) => {
const value = (e as CustomEvent<SidebarChangeDetail>).detail.value;
const label = PAGES[value] ?? value;
title.textContent = label;
crumbs.update({ items: [{ label: 'Home', href: '#home' }, ...(value === 'people' || value === 'teams' ? [{ label: 'Organization', href: '#org' }] : []), { label }] });
});
sc.listen(sidebar.host, ['aui-change', 'aui-collapsed-change', 'aui-expanded-change'], 'sidebar');
sc.listen(bar.host, ['aui-select'], 'menu bar');
sc.listen(trigger.element, ['aui-select'], 'actions menu');
sc.listen(list, ['aui-select'], 'context menu');
sc.listen(tabs.host, ['aui-change'], 'tabs');
sc.listen(stepper.host, ['aui-change'], 'stepper');
sc.listen(pager.host, ['aui-change'], 'pagination');
sc.listen(crumbs.host, ['aui-navigate'], 'breadcrumb');
crumbs.host.addEventListener('click', (e) => {
if (e.target instanceof HTMLAnchorElement) e.preventDefault();
});
toggle(sc, 'Sidebar collapsed', false, (collapsed) => {
sidebar.update({ collapsed });
}, ['sidebar']);
toggle(sc, 'Linear stepper', true, (linear) => {
stepper.update({ linear });
}, ['stepper']);
choice(
sc,
'Tabs activate',
[
{ value: 'automatic', label: 'On focus' },
{ value: 'manual', label: 'On Enter or Space' },
],
'automatic',
(activation) => {
tabs.update({ activation });
},
['tabs'],
);
import { Tabs } from '@absoluteui/components/tabs';
const host = document.createElement('div');
document.body.append(host);
Tabs.create(host, {
label: 'Account',
tabs: [
{ id: 'overview', label: 'Overview', content: 'Plan, usage, and contacts.' },
{ id: 'billing', label: 'Billing', icon: 'info', content: 'Invoices and payment methods.' },
{ id: 'audit', label: 'Audit log', disabled: true },
],
});

Manual activation with lazily filled panels

Section titled “Manual activation with lazily filled panels”
import { Tabs, type TabsChangeDetail } from '@absoluteui/components/tabs';
const host = document.createElement('div');
document.body.append(host);
const tabs = Tabs.create(host, {
label: 'Reports',
activation: 'manual',
tabs: [
{ id: 'daily', label: 'Daily' },
{ id: 'weekly', label: 'Weekly' },
],
});
const fill = (id: string): void => {
const panel = tabs.panel(id);
if (panel && panel.childElementCount === 0) {
const table = document.createElement('table');
panel.append(table);
}
};
fill(tabs.value);
host.addEventListener('aui-change', (event) => {
fill((event as CustomEvent<TabsChangeDetail>).detail.value);
});
import { Tabs } from '@absoluteui/components/tabs';
const host = document.createElement('div');
document.body.append(host);
const settings = Tabs.create(host, {
label: 'Settings',
orientation: 'vertical',
tabs: [
{ id: 'profile', label: 'Profile' },
{ id: 'security', label: 'Security' },
{ id: 'notifications', label: 'Notifications' },
],
value: 'security',
});
settings.select('notifications');
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { Tabs } from '@absoluteui/components/tabs';
import '@absoluteui/components/tabs/style.css';
import { Tabs, type TabsChangeDetail } from '@absoluteui/components/tabs';
import '@absoluteui/components/tabs/style.css';
const host = document.querySelector<HTMLElement>('#report-tabs');
if (host) {
const tabs = Tabs.create(host, { label: 'Reports', tabs: [{ id: 'daily', label: 'Daily' }, { id: 'weekly', label: 'Weekly' }] });
host.addEventListener('aui-change', (event) => {
const panel = tabs.panel((event as CustomEvent<TabsChangeDetail>).detail.value);
if (panel && panel.childElementCount === 0) panel.append(document.createElement('table'));
});
}
More usage
import { Tabs } from '@absoluteui/components/tabs';
const host = document.createElement('div');
document.body.append(host);
Tabs.create(host, {
label: 'Account',
tabs: [
{ id: 'overview', label: 'Overview', content: 'Plan, usage, and contacts.' },
{ id: 'billing', label: 'Billing', content: 'Invoices and payment methods.' },
],
});

Using Angular? See Tabs for Angular.

Tabs.create(host: HTMLElement, options: TabsOptions): Tabs

Global configuration key: tabs (see Configuration).

Option Type Default Description
label string Accessible name of the tablist (aria-label). Required.
tabs readonly { id: string; label: string; icon?: IconRef; disabled?: boolean; content?: Node | string }[] Tabs in order. Ids must be unique; they are consumer keys, not DOM ids. Required.
value string Selected tab id. Default: the first enabled tab.
activation 'automatic' | 'manual' "automatic" automatic selects on focus; manual needs Enter or Space. Globally configurable.
orientation 'horizontal' | 'vertical' "horizontal" Layout and arrow keys (Left/Right or Up/Down). Globally configurable.
direction 'ltr' | 'rtl' "ltr" Mirrors Left/Right in rtl. An ancestor dir=rtl also mirrors. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement Consumer host; its children are owned by the component.
tablist HTMLDivElement The role=tablist element.
value string Selected tab id.
options Readonly<TabsOptions> Current instance options.
Method Description
panel(id: string): HTMLDivElement | null The tabpanel for a tab id, for consumers to fill.
select(id: string): void Select programmatically (no events).
update(options: Partial<TabsOptions>): void Merge and apply options. Panels are kept by id.
destroy(): void Remove rendering, listeners, observers, and subscriptions.
Event Detail Bubbles Cancelable Description
aui-change { value: string; previous: string } Yes No The user selected a different tab.
Area Description
panel One tabpanel per tab: tabs.panel(id), or the tab’s content option.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-tabs Host.
aui-tabs--horizontal | --vertical Orientation modifiers on the host.
aui-tabs__list role=tablist.
aui-tabs__tab role=tab button.
aui-tabs__label Tab label text.
aui-tabs__panels Panel container.
aui-tabs__panel role=tabpanel.

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-border-width | --aui-border-width-strong | --aui-color-border | --aui-color-focus-ring | --aui-color-hover | --aui-color-primary | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-duration-fast | --aui-easing-standard | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-weight-semibold | --aui-icon-size-sm | --aui-line-height-normal | --aui-space-1 | --aui-space-2 | --aui-space-4 | --aui-touch-target-min

TypeScript definitions
type TabsActivation = 'automatic' | 'manual';
type TabsOrientation = 'horizontal' | 'vertical';
interface TabItem { id: string; label: string; icon?: IconRef; disabled?: boolean; content?: Node | string }
interface TabsChangeDetail { value: string; previous: string }

Pattern: WAI-ARIA APG Tabs pattern (automatic and manual activation), with native buttons as tabs.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
Tab Focus outside the tablist Moves focus to the selected tab (single tab stop).
Tab Tab focused Moves focus into the active panel (or its first focusable element).
ArrowRight / ArrowLeft Horizontal tablist Next / previous enabled tab, wrapping; mirrored in RTL. Automatic mode also selects it.
ArrowDown / ArrowUp Vertical tablist Next / previous enabled tab, wrapping. Automatic mode also selects it.
Home / End Tab focused First / last enabled tab. Automatic mode also selects it.
Enter / Space Tab focused (manual activation) Selects the focused tab.
Element Role
tab container tablist
<button> tab
panel tabpanel
Attribute Element Value
aria-label tablist label option
aria-orientation tablist horizontal | vertical
aria-selected tab true on the selected tab, false otherwise
aria-controls tab id of its tabpanel
aria-labelledby tabpanel id of its tab
tabindex tabpanel 0 when the panel contains no focusable element
disabled tab Native disabled for disabled tabs (skipped by arrow keys)

One tab stop on the selected tab. In manual mode focus can move without selecting; when focus leaves the tablist, the tab stop returns to the selected tab. Re-rendering never moves or blurs the focused tab.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.1 Use of Color A
2.1.1 Keyboard A
2.4.3 Focus Order A
2.4.7 Focus Visible AA
4.1.2 Name, Role, Value A

Automated test results: Accessibility and compliance.

  • Selection is conveyed by aria-selected, an indicator bar, and heavier weight (not color alone).
  • Inactive panels use the hidden attribute, so they are removed from the accessibility tree.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/tabs 35.5 kB 12.5 kB 11.1 kB 0.8 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
Tabs.create with 20 tabs < 2 ms in headless Chromium

Tested scale: 20 tabs in an overflowing tablist in the unit tests.

Three listeners on the tablist (click, keydown, focusout), one MutationObserver on the panel container, and one configuration subscription per instance. Re-renders reuse tab and panel elements by id. Budget: under 2 ms for Tabs.create with 20 tabs.

Measured run times: Performance.

States

default, hover, focus-visible, selected, disabled, overflowing (scrollable tablist).

State transitions
From Trigger To
tab A selected click tab B, or arrow to B (automatic) B selected; aui-change
tab A selected arrow to B (manual) A still selected; B focused with the tab stop
B focused (manual) Enter / Space B selected; aui-change
B focused (manual) focus leaves the tablist tab stop returns to the selected tab
any select(id) / update({ value }) selection changes; no event
selected tab removed by update({ tabs }) re-render first enabled tab selected; no event
Accessibility notes
  • Selection is shown by an indicator bar and semibold weight, not by color alone (WCAG 1.4.1).
  • Re-rendering never re-inserts a focused tab, so focus is not lost during automatic activation.
  • Icons are decorative; the label text is the accessible name.
  • Manual screen-reader verification is pending (see Known limitations).
Responsive behavior

The horizontal tablist never wraps. It scrolls horizontally (overflow-x: auto, thin scrollbar), and after every selection the tablist, never the page, is scrolled so the selected tab is fully visible. Tabs keep the minimum touch-target height.

Right-to-left

Logical properties throughout. ArrowLeft/ArrowRight are mirrored when direction is 'rtl' or when the host inherits dir="rtl". The vertical indicator is on the inline-start edge.

Theming

Colors come from role tokens only. Verified in the light, dark, and high-contrast themes. In forced-colors mode the selected indicator uses Highlight and disabled tabs use GrayText.

Global configuration
configureAbsoluteUI({ components: { tabs: { activation: 'manual' } } });

Changes apply to existing instances immediately.

Component configuration

Instance options override global and theme defaults. All options are dynamic.

Icons

Each tab accepts an optional decorative icon (IconRef). There are no built-in icon slots.

Security

Labels and string content use textContent; HTML strings are never parsed. Node content is inserted as provided, so the consumer owns its safety. CSP-safe: no inline styles or handlers.

Data handling

No persistence, network access, or telemetry.

Supported data scale

Tested with 20 tabs in an overflowing tablist. Beyond about 10 tabs, consider a different navigation pattern.

Edge cases
  • If every tab is disabled, the first tab is selected and the tablist has no tab stop.
  • A selected tab that becomes disabled stays selected; the tab stop moves to the first enabled tab.
  • Removing the selected tab through update({ tabs }) selects the first enabled tab without an event.
  • Consumer ids can be any non-empty string; DOM ids are generated separately.
Errors
Code Category Cause
TABS_OPTIONS configuration Missing label, empty tabs, duplicate or empty ids, empty tab labels, or a value/select(id) that is not a tab id.
CFG_INVALID_VALUE configuration Invalid activation, orientation, or direction.

A failed construction leaves no rendering, listeners, or subscriptions behind. A failed update() keeps the previous state.

Known limitations
  • Panels are always in the DOM; lazy loading is the consumer’s job (for example on aui-change).
  • No closable, reorderable, or user-added tabs.
  • No scroll buttons for an overflowing tablist.
  • Screen-reader behavior has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Unsupported scenarios
  • HTML strings as labels or content.
  • Tabs that navigate to separate URLs.