Tabs

Tabs and their panels, one shown at a time. In the look of the app's style.

NavigationExperimental

Usage

import { Component, ViewEncapsulation } from '@angular/core';import {  ScCard,  ScCardBody,  ScCardDescription,  ScCardHeader,  ScCardTitle,  ScTabs,  ScTabsList,  ScTabsPanel,  ScTabsPanelContent,  ScTabsTab,} from '@semantic-components/ui';
@Component({  selector: 'app-tabs-usage-demo',  imports: [    ScTabs,    ScTabsList,    ScTabsTab,    ScTabsPanel,    ScTabsPanelContent,    ScCard,    ScCardHeader,    ScCardTitle,    ScCardDescription,    ScCardBody,  ],  template: `    <div scTabs value="overview" class="w-full max-w-sm">      <!-- A box that scrolls where the tabs don't fit (a phone). -->      <div class="max-w-full overflow-x-auto">        <div scTabsList>          <button scTabsTab value="overview">Overview</button>          <button scTabsTab value="analytics">Analytics</button>          <button scTabsTab value="reports">Reports</button>          <button scTabsTab value="settings">Settings</button>        </div>      </div>      <div scTabsPanel value="overview">        <ng-template scTabsPanelContent>          <div scCard>            <div scCardHeader>              <div scCardTitle>Overview</div>              <p scCardDescription>                View your key metrics and recent project activity. Track                progress across all your active projects.              </p>            </div>            <div scCardBody class="text-muted-foreground text-sm">              You have 12 active projects and 3 pending tasks.            </div>          </div>        </ng-template>      </div>      <div scTabsPanel value="analytics">        <ng-template scTabsPanelContent>          <div scCard>            <div scCardHeader>              <div scCardTitle>Analytics</div>              <p scCardDescription>                Track performance and user engagement metrics. Monitor trends                and identify growth opportunities.              </p>            </div>            <div scCardBody class="text-muted-foreground text-sm">              Page views are up 25% compared to last month.            </div>          </div>        </ng-template>      </div>      <div scTabsPanel value="reports">        <ng-template scTabsPanelContent>          <div scCard>            <div scCardHeader>              <div scCardTitle>Reports</div>              <p scCardDescription>                Generate and download your detailed reports. Export data in                multiple formats for analysis.              </p>            </div>            <div scCardBody class="text-muted-foreground text-sm">              You have 5 reports ready and available to export.            </div>          </div>        </ng-template>      </div>      <div scTabsPanel value="settings">        <ng-template scTabsPanelContent>          <div scCard>            <div scCardHeader>              <div scCardTitle>Settings</div>              <p scCardDescription>                Manage your account preferences and options. Customize your                experience to fit your needs.              </p>            </div>            <div scCardBody class="text-muted-foreground text-sm">              Configure notifications, security, and themes.            </div>          </div>        </ng-template>      </div>    </div>  `,  host: { class: 'flex w-full justify-center' },  encapsulation: ViewEncapsulation.None,})export class TabsUsageDemo {}

Anatomy

Every part is a directive on your element; the tabs' text and icons are yours. A panel's content goes in an ng-template scTabsPanelContent.

import {  ScTabs, ScTabsList, ScTabsTab, ScTabsPanel,  ScTabsPanelContent,} from '@semantic-components/ui';
<div scTabs [(value)]="…">  <div scTabsList>    <button scTabsTab value="…">…</button>  </div>  <div scTabsPanel value="…">    <ng-template scTabsPanelContent>…</ng-template>  </div></div>

Limitation: panel content

Angular Aria, which the tabs are built on, renders a panel only through its template: content written straight in a panel is not allowed (Aria reports it in development). So every panel's content goes in an ng-template scTabsPanelContent.

  • It is created when its tab is selected — a heavy panel costs nothing until it is opened.
  • It is destroyed when another tab is selected: what was typed in a panel's fields, its scroll, its own state are gone when you come back. Keep that state outside the panel — in your component or your form — if it must survive a switch.

Keyboard

  • Tab enters the list on the selected tab, then goes on to its panel.
  • ArrowLeft and ArrowRight move between the tabs (mirrored right to left), ArrowUp and ArrowDown when vertical; Home and End go to the ends.
  • Enter or Space selects the tab — or the arrows select as they move, with activateOnFocus.
  • A disabled tab is reached, not selected.

Examples

Line

import { Component, ViewEncapsulation } from '@angular/core';import {  ScTabs,  ScTabsList,  ScTabsPanel,  ScTabsPanelContent,  ScTabsTab,} from '@semantic-components/ui';
/** variant="line": the selected tab underlined, no box. */

Vertical

import { Component, ViewEncapsulation } from '@angular/core';import {  ScTabs,  ScTabsList,  ScTabsPanel,  ScTabsPanelContent,  ScTabsTab,} from '@semantic-components/ui';
/** orientation="vertical": the list beside the panels; ArrowUp and ArrowDown move. */

Disabled

import { Component, ViewEncapsulation } from '@angular/core';import {  ScTabs,  ScTabsList,  ScTabsPanel,  ScTabsPanelContent,  ScTabsTab,} from '@semantic-components/ui';
/** A disabled tab: reached by the arrows, not selected. */

Icons

import { Component, ViewEncapsulation } from '@angular/core';import {  ScTabs,  ScTabsList,  ScTabsPanel,  ScTabsPanelContent,  ScTabsTab,} from '@semantic-components/ui';import { SiAppWindowIcon, SiCodeIcon } from '@semantic-icons/lucide-icons';

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScCard,  ScCardBody,  ScCardDescription,  ScCardHeader,  ScCardTitle,  ScTabs,  ScTabsList,

API reference

Each part takes class, merged over the style (cn: a later class wins).

PartSelectorDescription
ScTabs[scTabs] The root: [(value)], the selected tab; orientation ('horizontal' or 'vertical').
ScTabsList[scTabsList] The tabs (role tablist): variant ('default' or 'line'), activateOnFocus (the arrows select), wrap.
ScTabsTabbutton[scTabsTab] A tab (role tab): value, disabled.
ScTabsPanel[scTabsPanel] A tab’s panel (role tabpanel), named by its tab: value. Shown while its tab is selected.
ScTabsPanelContentng-template[scTabsPanelContent] In a panel: its content, created when the panel is shown.