Tabs
vig-tabs vig-tab [vigTabLabel] [vigTabContent]
import { Tabs, Tab, TabLabel, TabContent } from '@vigdx/ui/tabs';Basic
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.
Day tickets cost €39; children under six enter free.
Weekdays 10:00–18:00, weekends 09:00–20:00.
Custom labels and disabled
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.
Attachments shared with you.
Not available on your plan.
Controlled
[(value)] to preselect a tab, read the active one or switch tabs from elsewhere on the page.
Order #1042 · 3 items · €128.40
Express delivery to Berlin, arriving Thursday.
Placed, paid and packed.
Deferred content
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"]
| Part | Element | data-state |
|---|---|---|
list | role="tablist" row. | — |
tab | aria-selected ). | active, inactive |
Tab [data-scope="tabs"]
| Part | Element | data-state |
|---|---|---|
panel | role="tabpanel" . | active, inactive |
Accessibility
- Follows the WAI-ARIA APG tabs pattern: a
role="tablist"ofrole="tab"buttons witharia-selected, and arole="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. Whereuntil-foundis not supported they are simply hidden. Panels of disabled tabs and not-yet-createdvigTabContenttemplates are not searchable. - Give the tab list an accessible name with
ariaLabelwhenever 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
vigTabLabeltemplates render inside the tab button: keep them to text, icons and badges, never nested buttons or links.
API
Tabs
vig-tabsTabbed 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.
<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>| Name | Type | Default | Description |
|---|---|---|---|
ariaLabel | string | undefined | undefined | — |
value | string | undefined | undefined | The active tab's value; two-way bindable. Defaults to the first tab. |
| Name | Payload | Description |
|---|---|---|
valueChange | string | undefined | The active tab's value; two-way bindable. Defaults to the first tab. |
| Signature | Description |
|---|---|
panelId(value: string): string | — |
tabId(value: string): string | — |
Tab
vig-tabOne 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.
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | — |
label | string | '' | — |
value | string | — | — |
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 : |