Tabs

Switches between related panels that share one place on the page, one panel at a time. Use tabs for peer views of the same object, not for steps of a flow.

  • vig-tabs
  • vig-tab
  • [vigTabLabel]
  • [vigTabContent]
Import
import { Tabs, Tab, TabLabel, TabContent } from '@vigdx/ui/tabs';

Basic

Each vig-tab has a unique value and a label ; its content is the panel. The first enabled tab is active by default. Name the tab list with ariaLabel .

The park opens on 1 April and closes on 31 October.

Custom labels and disabled

An ng-template vigTabLabel inside a tab replaces its text label, e.g. with an icon and a count. A disabled tab cannot be selected and is skipped by the arrow keys.

12 unread messages.

Controlled

Two-way bind [(value)] to preselect a tab, read the active one or switch tabs from elsewhere on the page.

Express delivery to Berlin, arriving Thursday.

Active tab: shipping

Deferred content

Projected panel content is created with the page and stays in the DOM while hidden, so the browser's find-in-page can reach it. For a heavy panel, put its content in an ng-template vigTabContent : it is created on the tab's first activation and keeps its state when the user switches away, but find-in-page cannot see it until then.

Revenue is up 12% on last quarter.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="tabs"][data-part="list"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Tabs [data-scope="tabs"]

Tabs styling hooks
Part Element data-state
list The role="tablist" row. —
tab A tab button ( aria-selected ). active, inactive

Tab [data-scope="tabs"]

Tab styling hooks
Part Element data-state
panel The role="tabpanel" . active, inactive

Accessibility

  • Follows the WAI-ARIA APG tabs pattern: a role="tablist" of role="tab" buttons with aria-selected, and a role="tabpanel" labelled by its tab.
  • The tab list is a single tab stop on the active tab. ArrowLeft and ArrowRight move and activate (automatic activation, wrapping, mirrored in right-to-left layouts); Home and End jump to the first and last enabled tab.
  • When the active panel holds no focusable content it becomes a tab stop (tabindex="0"), so Tab moves from the tab list straight into it; a panel with its own controls leaves Tab to them.
  • Inactive panels are hidden with hidden="until-found": the browser's find-in-page and text-fragment links can reveal their text, which selects their tab. Where until-found is not supported they are simply hidden. Panels of disabled tabs and not-yet-created vigTabContent templates are not searchable.
  • Give the tab list an accessible name with ariaLabel whenever the page holds more than one set of tabs.
  • The selected tab is marked by its underline, not by color alone, and only that tab keeps an underline in forced-colors mode.
  • Custom vigTabLabel templates render inside the tab button: keep them to text, icons and badges, never nested buttons or links.

API

Tabs

vig-tabs component

Tabbed view following the APG tabs pattern: one roving tab stop on the tablist, arrow keys move and activate. Inactive panels stay in the DOM as hidden="until-found", so the browser's find-in-page (and text-fragment links) can reveal them, which selects their tab; browsers without until-found treat them as plain hidden. Wrap heavy panel content in a vigTabContent template to create it on first activation instead.

Example :
<vig-tabs [(value)]="active">
  <vig-tab value="general" label="General">…panel…</vig-tab>
  <vig-tab value="pricing">
    <ng-template vigTabLabel><i class="pi pi-dollar"></i> Pricing</ng-template>
    …panel…
  </vig-tab>
</vig-tabs>
Tabs props
Name Type Default Description
ariaLabelstring | undefinedundefined
—
value model string | undefinedundefined

The active tab's value; two-way bindable. Defaults to the first tab.

Tab

vig-tab component

One tab: value identifies it, label (or a vigTabLabel template) names it, and the projected content is the panel — hidden (but findable) while inactive. A vigTabContent template is created on first activation.

Tab props
Name Type Default Description
disabledbooleanfalse
—
labelstring''
—
value required string—
—

Templates and directives

Templates and directives
Selector Export Description
[vigTabLabel]TabLabel

Marks an ng-template as a tab's custom header content (icon, badge…).

ng-template[vigTabContent]TabContent

Marks an ng-template as a tab's deferred panel content: it is created on the tab's first activation and kept afterwards (state survives switching away). Until then find-in-page cannot reach it, so use it only for heavy panels; plain projected content stays searchable while hidden.

Example :
<vig-tab value="charts" label="Charts">
  <ng-template vigTabContent><app-charts /></ng-template>
</vig-tab>

Are you sure?