Create

Navigation

Tabs

Copy page View as Markdown Open in ChatGPT Open in Claude

A set of layered sections of content, known as tab panels, that are displayed one at a time.

Usage#

app.component.ts
import { WDS_TABS } from '@wds/angular/tabs';

Examples#

Default#

A wds-tab and a wds-tab-panel with the same value belong together. value on wds-tabs selects a tab (the first enabled one by default); wds-change reports the value chosen by the user and the previous one.

OverviewAnalyticsReportsSettings
$12,480

Revenue

+2,350

New users

Selected: overview

Line#

variant="line" removes the background and underlines the selected tab.

Overview Analytics Reports

Content of the Overview tab.

Content of the Analytics tab.

Content of the Reports tab.

Vertical#

orientation="vertical" places the tab list to the left of the panels; the Up and Down arrow keys move between tabs.

Account Password Notifications Name Save
Current password New password
Change password
Email notifications A weekly summary of your activity.

Command#

variant="command" puts the tabs in the header of a bordered block, for example to pick a package manager. Content of the actions slot goes to the right of the tab bar, such as a copy button.

pnpmnpmyarnbun
pnpm add @wds/core
npm install @wds/core
yarn add @wds/core
bun add @wds/core

Disabled#

A disabled tab cannot be selected and the arrow keys skip it; disabled on wds-tabs disables all tabs.

Home Disabled About

The “Disabled” tab cannot be clicked and the arrow keys skip it.

About us.

Manual activation#

With activation="manual" the arrow keys only move focus and Enter or Space selects the tab. Use it when showing a panel is slow, such as when it loads data.

Overview Analytics Reports

The arrow keys move focus; press Enter or Space to open a tab.

Content of the Analytics tab.

Content of the Reports tab.

Icons#

An <svg> icon in a tab is sized and aligned with the label.

Preview Code Button
<wds-button>Button</wds-button>

API References#

wds-tabs#

Layered sections of content shown one at a time (WAI-ARIA Tabs pattern). wds-tab elements go to the tab list and wds-tab-panel elements below it; a tab and its panel are linked by value.

Attributes

AttributeTypeDefaultDescription
valuestring''The selected tab (value of a wds-tab). Defaults to the first enabled tab.
variantWdsTabsVariant'default'line: no background, the selected tab is underlined. command: a bordered block with the tabs in its header (such as npm / yarn / pnpm / bun commands), horizontal only.
orientationWdsTabsOrientation'horizontal'Direction of the tab list; vertical places it to the left of the panels.
disabledbooleanfalseDisables all tabs.
activationWdsTabsActivation'automatic'automatic: the arrow keys select a tab at once; manual: they only move focus and Enter or Space selects.

Events

EventDescription
wds-changeCustomEvent<WdsTabsChangeDetail>The user selected another tab.

Slots

SlotDescription
tabThe wds-tab elements (assigned automatically).
(default)The wds-tab-panel elements.
actionsActions on the right of the tab bar (such as a copy button), only with variant="command".

CSS parts (::part)

PartDescription
baseThe box around the header and the panels; it has the border in variant="command".
headerThe bar with the tab list and the actions (variant="command").
listThe tab list (role="tablist").

CSS custom properties

PropertyDescription
--wds-tabs-border-colorBorder color of the block and of its header in variant="command" (default --wds-border).

wds-tab#

A tab in wds-tabs. It moves itself to the tab list (the tab slot).

Attributes

AttributeTypeDefaultDescription
valuestring''Identifier that links the tab to its wds-tab-panel.
disabledbooleanfalseDisables the tab: it cannot be selected and the arrow keys skip it.

Slots

SlotDescription
(default)Label (text, an <svg> icon).

CSS parts (::part)

PartDescription
baseThe box with the padding and the border.

wds-tab-panel#

Content of the tab with the same value. Visible only while that tab is selected.

Attributes

AttributeTypeDefaultDescription
valuestring''Identifier of the tab (wds-tab value).

Slots

SlotDescription
(default)Content.

CSS parts (::part)

PartDescription
baseThe box around the content; it has the padding in wds-tabs variant="command".

Accessibility#

Screen reader#

The tab bar has role="tablist" with aria-orientation. Each wds-tab has role="tab", aria-selected and aria-controls pointing to its panel.

Each wds-tab-panel has role="tabpanel" named by its tab (aria-labelledby). Panels of other tabs are hidden, also from screen readers.

A panel is focusable (tabindex="0"), so Tab from the tab list reaches it even when it has no focusable content.

A disabled tab has aria-disabled="true". A tab with only an icon needs an accessible name, such as aria-label.

Keyboard support#

KeyFunction
TabMoves focus to the selected tab, then into the panel.
ArrowRightArrowLeftMoves focus to the next or previous tab, wrapping around, and selects it (with activation="manual" only moves focus). Disabled tabs are skipped.
ArrowDownArrowUpThe same with orientation="vertical".
HomeEndMoves focus to the first or last tab.
EnterSpaceSelects the focused tab (needed with activation="manual").
Footer