# Tabs

Tabs are used to separate information into logical sections in the context of a single page and to quickly navigate between them.

With Element v48, the tabs have been completely re-implemented including breaking changes in the API. The old tabs have been renamed to `*-legacy` and are available via legacy entrypoint `@siemens/element-ng/tabs-legacy`. For more details, see the BREAKING CHANGES notes for Element v48.0.0 in the [changelog](<https://element.siemens.io/CHANGELOG/>).

## Usage

![Tabs](<../images/tabs.png>)

### When to use

- Use tabs to group content that belongs to the same category.
- Use tabs when there is a large amount of content that can be separated.
- Use tabs to make the content accessible without navigating across pages or compromising on space.
- Different tab-panes should be logically related but mutually exclusive. A content element should only be in one tab at a time.

### Best practices

- Don't mix different content types within the same tab structure.
- Avoid nested tabs (2 levels of tabs stacked on top of each other) since they add visual complexity, and are harder to navigate.

## Design

### Elements

![Tabs](<../images/tabs-elements.png>)

> 1. Active tab, 2. Badge (optional), 3. Default tab, 4. Overflow menu

### Tab label

![Tabs](<../images/tabs-usage-behavior-long-label.png>)

- The label describes the content contained within it.
- Labels are concise and use no more than two words.
- Tab labels should be written in title case and all words should be proper nouns.
- The label will not be truncated and uses the space it needs.
- The minimum width of a tab is `124px`.

### Number of tabs

In most scenarios, you should use no more than six tabs. This ensures an uncluttered UI and reduces cognitive load for users. If more than six tabs are needed, consider other navigation patterns.

### Order

The order of all tabs should be consistent across all pages. Tabs with related content should be grouped adjacent to each other. The most important tab should be the first.

### Badge

![Tabs](<../images/tabs-usage-badge.png>)

A small badge (dot) can be displayed in tabs to indicate when new information is available. The badge can also contain a number to display the amount of notifications.

### Icon tabs

![Tabs](<../images/tabs-usage-icons.png>)

If there is not enough space to display meaningful labels, a tab version with icons can be used.

> **Note:** This version only works with meaningful icons!

### Closable tabs

![Tabs closable](<../images/tabs-closable.png>)

This variation allows users to open multiple tabs for multitasking or comparing information side by side, and subsequently close them as needed. They can be used in combination with badges.

> **Note:** Closable tabs cannot be used in combination with icons.

### Responsive behavior

When there isn’t enough space to display all the tabs, the ones that no longer fit collapse into a menu. This menu contains all the tabs in the same order, ensuring consistent navigation while optimizing space.

![Tabs](<../images/tabs-responsive.png>)

## Code

### Usage

```
import { SiTabComponent, SiTabsetComponent } from '@siemens/element-ng/tabs';

@Component({
  imports: [
    SiTabComponent,
    SiTabsetComponent,
    ...
  ]
})
```

### Tabs

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SiTabComponent, SiTabsetComponent } from '@siemens/element-ng/tabs';
import { LOG_EVENT } from '@siemens/live-preview';

interface TabModel {
  heading: string;
  closable?: boolean;
  disabled?: boolean;
  icon?: string;
  iconAltText?: string;
  badgeColor?: string;
  badgeContent?: string | boolean;
  active?: boolean;
}

@Component({
  selector: 'app-sample',
  imports: [FormsModule, SiTabsetComponent, SiTabComponent],
  templateUrl: './si-tabs.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  selectedTabIndex = 0;
  deselectable = true;
  activable = true;
  logEvent = inject(LOG_EVENT);

  tabs: TabModel[] = [
    { heading: 'Reception', closable: true, badgeContent: '11', active: true },
    {
      heading: 'Conference room',
      closable: true,
      badgeContent: true
    },
    {
      heading: 'Lobby',
      disabled: true
    },
    {
      heading: 'Pantry',
      badgeColor: 'danger',
      badgeContent: '1'
    },
    {
      heading: 'Washroom',
      badgeColor: 'warning',
      badgeContent: '2'
    }
  ];

  closeTab(tab: TabModel): void {
    this.tabs.splice(
      this.tabs.findIndex(t => t.heading === tab.heading),
      1
    );
  }

  canDeactivate = (): boolean => {
    return this.deselectable;
  };

  canActivate = (): boolean => {
    if (!this.activable) {
      this.logEvent('Enable Allow Lobby tab activation to activate this tab');
    }
    return this.activable;
  };
}
```

Template:

```html
<si-tabset>
  @for (tab of tabs; track tab) {
    <si-tab
      [active]="tab.active ?? false"
      [badgeColor]="tab.badgeColor"
      [badgeContent]="tab.badgeContent"
      [closable]="tab.closable"
      [heading]="tab.heading"
      [canActivate]="tab.heading === 'Lobby' ? canActivate : undefined"
      (closeTriggered)="closeTab(tab)"
    >
      <p class="mt-4"> Content for {{ tab.heading }} </p>
    </si-tab>
  }
  <si-tab heading="Deselectable" [canDeactivate]="canDeactivate">
    <p class="mt-4">Uncheck to prevent switching to another tab.</p>
    <label class="form-check mb-2">
      <input type="checkbox" class="form-check-input" [(ngModel)]="deselectable" />
      <span class="form-check-label">Enable tab switching</span>
    </label>
  </si-tab>
</si-tabset>

<div class="e2e-ignore">
  <label class="form-check mb-2">
    <input type="checkbox" class="form-check-input" [(ngModel)]="activable" />
    <span class="form-check-label">Allow Lobby tab activation</span>
  </label>
</div>
```

### Tabs - Routing

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { AfterViewInit, Component, inject } from '@angular/core';
import { ActivatedRoute, Router, RouterLink, RouterOutlet } from '@angular/router';
import { Link, SiLinkDirective } from '@siemens/element-ng/link';
import { SiTabsetComponent, SiTabLinkComponent } from '@siemens/element-ng/tabs';
import { provideExampleRoutes } from '@siemens/live-preview';

// Dummy components to be used in the router outlet for the example
@Component({
  selector: 'app-home',
  template: `<div class="p-5">This is the home page</div>`
})
export class HomeComponent {}

@Component({
  selector: 'app-energy',
  template: `<div class="p-5">Energy consumption</div>`
})
export class EnergyComponent {}

@Component({
  selector: 'app-test-coverage',
  imports: [RouterOutlet, SiLinkDirective],
  template: `<div class="p-5"
    >Total test coverage: 80%
    <br />
    <br />
    <a [siLink]="e2eRouterLink">Check E2E coverage details</a><br />
    <br />
    <a [siLink]="unitRouterLink">Check Unit tests coverage details</a>
    <br />
    <br />
    <router-outlet />
  </div>`
})
export class TestCoverageComponent {
  e2eRouterLink: Link = { link: 'e2e-coverage' };
  unitRouterLink: Link = { link: 'unit-coverage' };
}

@Component({
  selector: 'app-e2e-coverage',
  template: `E2E test coverage is 70%`
})
export class E2ECoverageComponent {}

@Component({
  selector: 'app-unit-coverage',
  template: `Unit test coverage is 90%`
})
export class UnitCoverageComponent {}

@Component({
  selector: 'app-sample',
  imports: [SiTabsetComponent, SiTabLinkComponent, RouterOutlet, RouterLink],
  templateUrl: './si-tabs-routing.html',
  providers: [
    provideExampleRoutes([
      {
        path: 'tab-1',
        component: HomeComponent
      },
      {
        path: 'tab-2',
        component: EnergyComponent
      },
      {
        path: 'tab-3',
        component: TestCoverageComponent,
        children: [
          { path: 'e2e-coverage', component: E2ECoverageComponent },
          {
            path: 'unit-coverage',
            component: UnitCoverageComponent
          }
        ]
      }
    ])
  ],
  host: { class: 'p-5' }
})
export class SampleComponent implements AfterViewInit {
  protected tabLink1 = ['tab-1'];
  protected tabLink2 = ['tab-2'];
  protected tabLink3 = ['tab-3'];

  router = inject(Router);
  activatedRoute = inject(ActivatedRoute);
  ngAfterViewInit(): void {
    // Wait for live preview to initialize the router configs
    setTimeout(() => {
      this.router.navigate(this.tabLink1, {
        relativeTo: this.activatedRoute
      });
    }, 1);
  }
}
```

Template:

```html
<si-tabset>
  <a si-tab heading="Home" [routerLink]="tabLink1"></a>
  <a si-tab heading="Energy" [routerLink]="tabLink2"></a>
  <a si-tab heading="Test coverage" [routerLink]="tabLink3"></a>

  <router-outlet />
</si-tabset>
```

### Tabs - Icons

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject } from '@angular/core';
import { SiTabComponent, SiTabsetComponent } from '@siemens/element-ng/tabs';
import { LOG_EVENT } from '@siemens/live-preview';

interface TabModel {
  heading: string;
  closable?: boolean;
  disabled?: boolean;
  icon?: string;
  badgeColor?: string;
  badgeContent?: string | boolean;
  active?: boolean;
}

@Component({
  selector: 'app-sample',
  imports: [SiTabsetComponent, SiTabComponent],
  templateUrl: './si-tabs-icons.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  selectedTabIndex = 0;
  deselectable = true;
  logEvent = inject(LOG_EVENT);

  tabs: TabModel[] = [
    {
      heading: 'Reception',
      icon: 'element-reception',
      closable: true,
      badgeContent: '11',
      active: true
    },
    {
      heading: 'Conference',
      icon: 'element-meeting',
      closable: true,
      badgeContent: true
    },
    {
      heading: 'Lobby',
      disabled: true,
      icon: 'element-couch'
    },
    {
      heading: 'Pantry',
      icon: 'element-break',
      badgeColor: 'danger',
      badgeContent: '1'
    }
  ];

  closeTab(tab: TabModel): void {
    this.tabs.splice(
      this.tabs.findIndex(t => t.heading === tab.heading),
      1
    );
  }
}
```

Template:

```html
<si-tabset>
  @for (tab of tabs; track tab) {
    <si-tab
      [active]="tab.active ?? false"
      [badgeColor]="tab.badgeColor"
      [badgeContent]="tab.badgeContent"
      [closable]="tab.closable"
      [heading]="tab.heading"
      [icon]="tab.icon"
      (closeTriggered)="closeTab(tab)"
    >
      <p class="mt-4"> Content for {{ tab.heading }} </p>
    </si-tab>
  }
</si-tabset>
```

### External Tab Content

Use `SiTabPortalComponent` to render tab content in a different part of the DOM outside of the `si-tabset`. This is useful for split layouts such as [list-details](<https://element.siemens.io/components/layout-navigation/list-details/>). In these layouts, the tabs are in a header area and the content is in a separate body area.

Pass the `SiTabsetComponent` reference to the `tabset` input on `SiTabPortalComponent`.

```
<si-tabset #tabset>
  <si-tab heading="Overview" [active]="true"> Overview </si-tab>
  <si-tab heading="History"> History </si-tab>
</si-tabset>

<!-- Rendered elsewhere in the DOM -->
<si-tab-portal [tabset]="tabset" />
```

### Toolbars

Tabs can be combined with toolbar actions (e.g. icon buttons) positioned inline in the tab bar. This pattern requires:

1. A **wrapper container** with the classes `.nav-tabs .d-flex .align-items-center` — this ensures the tabs and toolbar buttons are rendered on the same row, vertically aligned.
2. The `si-tabset` must have `.flex-fill .overflow-hidden` — `.flex-fill` allows the tabset to take all available space (pushing toolbar buttons to the end), and `.overflow-hidden` ensures the responsive overflow menu works correctly within the flex layout.
3. `SiTabPortalComponent` to render tab content separately from the tab header — this ensures toolbar buttons come before the tab content in the DOM/tab order for accessible keyboard navigation.

```
<!-- Wrapper container -->
<div class="nav-tabs d-flex align-items-center">
  <si-tabset #tabset class="flex-fill overflow-hidden">
    <si-tab heading="Write" [active]="true"> ... </si-tab>
    <si-tab heading="Preview"> ... </si-tab>
  </si-tabset>
  <!-- Toolbar actions placed after the tabset -->
  <si-menu-bar>
    <si-menu-item icon="element-link" aria-label="Link" siTooltip="Link" />
    <si-menu-item icon="element-settings" aria-label="Settings" siTooltip="Settings" />
  </si-menu-bar>
</div>
<!-- Tab content rendered separately for correct tab order -->
<si-tab-portal [tabset]="tabset" />
```

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject } from '@angular/core';
import { SiMenuBarDirective, SiMenuItemComponent } from '@siemens/element-ng/menu';
import { SiTabComponent, SiTabPortalComponent, SiTabsetComponent } from '@siemens/element-ng/tabs';
import { SiTooltipDirective } from '@siemens/element-ng/tooltip';
import { LOG_EVENT } from '@siemens/live-preview';

@Component({
  selector: 'app-sample',
  imports: [
    SiMenuBarDirective,
    SiMenuItemComponent,
    SiTabComponent,
    SiTabPortalComponent,
    SiTabsetComponent,
    SiTooltipDirective
  ],
  templateUrl: './si-tabs-toolbar.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  logEvent = inject(LOG_EVENT);
}
```

Template:

```html
<div class="card h-100">
  <div class="card-header">
    <div class="nav-tabs d-flex align-items-center">
      <si-tabset #tabset class="flex-fill overflow-hidden">
        <si-tab heading="Write" [active]="true">
          <div class="mt-4 text-center">Write content</div>
        </si-tab>
        <si-tab heading="Preview">
          <div class="mt-4 text-center">Preview content</div>
        </si-tab>
      </si-tabset>
      <si-menu-bar>
        <si-menu-item
          icon="element-link"
          aria-label="Link"
          siTooltip="Link"
          (triggered)="logEvent('link')"
        />
        <si-menu-item
          icon="element-settings"
          aria-label="Settings"
          siTooltip="Settings"
          (triggered)="logEvent('settings')"
        />
      </si-menu-bar>
    </div>
  </div>
  <div class="card-body">
    <si-tab-portal [tabset]="tabset" />
  </div>
</div>
```

### [SiTabsetComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tabset.component.ts#L61-L161>)

**Kind:** component

**Selector:** `si-tabset`

```
import { SiTabsetComponent } from '@siemens/element-ng/tabs';
```

A component to group multiple tabs together. Can either be used with [SiTabLinkComponent](<index.html#SiTabLinkComponent>) or [SiTabComponent](<index.html#SiTabComponent>) components.

```
component SiTabsetComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [contentOverflowAuto](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tabset.component.ts#L66-L66>) | `boolean` | `false` | When set, the overflowing content inside the tab will automatically scroll |

### [SiTabComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L37-L81>)

**Kind:** component

**Selector:** `si-tab`

```
import { SiTabComponent } from '@siemens/element-ng/tabs';
```

Creates a normal tab that can contain any content.

Example:

```html
<si-tabset>
  <si-tab heading="Tab 1">
    <p>Content of Tab 1</p>
  </si-tab>
</si-tabset>
```

```
component SiTabComponent extends SiTabBaseDirective implements OnDestroy
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [active](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L43-L43>) | `boolean` | `false` | Whether the tab is active or not. If set to `true`, the tab will be selected and its content will be displayed.<br><br>Inherited from `SiTabBaseDirective` |
| [badgeColor](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L65-L65>) (inherited) | `string \| undefined` |  | Background color of the badge. If no color is provided a red dot badge will be rendered.<br><br>Inherited from `SiTabBaseDirective` |
| [badgeContent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L60-L60>) (inherited) | `boolean \| TranslatableString \| undefined` |  | Additional badge content. A value of<br><br>• `true` will render a red dot<br><br>• any string without a `badgeColor` will render a red dot with text<br><br>• any string with a `badgeColor` will render a normal badge<br><br>Inherited from `SiTabBaseDirective` |
| [canActivate](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L49-L49>) | `(() => boolean) \| undefined` |  | Guard to check if the tab can be activated. If not provided, the tab can always be activated. |
| [canDeactivate](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L54-L54>) | `(() => boolean) \| undefined` |  | Guard to check if the tab can be deactivated. If not provided, the tab can always be deactivated. |
| [closable](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L81-L83>) (inherited) | `boolean` | `false` | Close the current tab.<br><br>Inherited from `SiTabBaseDirective` |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L71-L75>) (inherited) | `boolean` | `false` | Disables the tab.<br><br>Inherited from `SiTabBaseDirective` |
| [heading](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L48-L48>) (required, inherited) | `TranslatableString` |  | Title of the tab item.<br><br>Inherited from `SiTabBaseDirective` |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L53-L53>) (inherited) | `string \| undefined` |  | Icon of the tab item. If provided, heading text will be ignored and only icon will be displayed.<br><br>Inherited from `SiTabBaseDirective` |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [activeChange](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L43-L43>) | `boolean` | Whether the tab is active or not. If set to `true`, the tab will be selected and its content will be displayed.<br><br>Inherited from `SiTabBaseDirective` |
| [closeTriggered](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L85-L85>) (inherited) | `void` | Event emitter to notify when a tab is closed.<br><br>Inherited from `SiTabBaseDirective` |

#### Attributes and Methods

##### selectTab

[Source for selectTab](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L64-L75>)

{@inheritDoc}

Inherited from `SiTabBaseDirective`

```
selectTab(retainFocus?: boolean): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [retainFocus](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab.component.ts#L64-L64>) (optional) | `boolean` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### [SiTabLinkComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-link.component.ts#L41-L62>)

**Kind:** component

**Selector:** `a[si-tab][routerLink]`

```
import { SiTabLinkComponent } from '@siemens/element-ng/tabs';
```

Creates a tab that uses the Angular router.

Example:

```html
<si-tabset>
  <a si-tab routerLink="/home" heading="Home"></a>

  <router-outlet />
</si-tabset>
```

```
component SiTabLinkComponent extends SiTabBaseDirective
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [badgeColor](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L65-L65>) (inherited) | `string \| undefined` |  | Background color of the badge. If no color is provided a red dot badge will be rendered.<br><br>Inherited from `SiTabBaseDirective` |
| [badgeContent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L60-L60>) (inherited) | `boolean \| TranslatableString \| undefined` |  | Additional badge content. A value of<br><br>• `true` will render a red dot<br><br>• any string without a `badgeColor` will render a red dot with text<br><br>• any string with a `badgeColor` will render a normal badge<br><br>Inherited from `SiTabBaseDirective` |
| [closable](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L81-L83>) (inherited) | `boolean` | `false` | Close the current tab.<br><br>Inherited from `SiTabBaseDirective` |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L71-L75>) (inherited) | `boolean` | `false` | Disables the tab.<br><br>Inherited from `SiTabBaseDirective` |
| [heading](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L48-L48>) (required, inherited) | `TranslatableString` |  | Title of the tab item.<br><br>Inherited from `SiTabBaseDirective` |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L53-L53>) (inherited) | `string \| undefined` |  | Icon of the tab item. If provided, heading text will be ignored and only icon will be displayed.<br><br>Inherited from `SiTabBaseDirective` |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [closeTriggered](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-base.directive.ts#L85-L85>) (inherited) | `void` | Event emitter to notify when a tab is closed.<br><br>Inherited from `SiTabBaseDirective` |

#### Attributes and Methods

##### active

[Source for active](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-link.component.ts#L47-L49>)

**Modifiers:** readonly

**Type:** `Signal<boolean | undefined>`

**Default:** `false`

Inherited from `SiTabBaseDirective`

##### selectTab

[Source for selectTab](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-link.component.ts#L51-L61>)

{@inheritDoc}

Inherited from `SiTabBaseDirective`

```
selectTab(retainFocus?: boolean): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [retainFocus](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs/si-tab-link.component.ts#L51-L51>) (optional) | `boolean` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### Types Documentation

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```

## Code (legacy)

Element implements tabset and tab components that provide the correct styling and responsive behavior. It supports the usage combined with the Angular router (preferred way) or alternatively as plain components.

> **Note:** This is the legacy tabs implementation. For new projects, use the [improved tabs component](<https://element.siemens.io/components/layout-navigation/tabs/#code>).

### Tabs with Angular Router

When using the tabs with the Angular router, each tab is just an anchor with a `routerLink`. Make sure to nest the `<router-outlet />` inside the `si-tabset-legacy` component as the tabset applies some accessibility attributes. No need to apply `routerLinkActive`, this is done automatically.

```
<si-tabset-legacy>
  <a si-tab-legacy heading="Tab 1" routerLink="./tab-1"></a>
  <a si-tab-legacy heading="Tab 2" routerLink="./tab-2"></a>

  <router-outlet />
</si-tabset-legacy>
```

```
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { SiTabsetLegacyComponent, SiTabLegacyComponent } from '@siemens/element-ng/tabs-legacy';

@Component({
  templateUrl: './my-component.html',
  imports: [SiTabsetLegacyComponent, SiTabLegacyComponent, RouterLink]
})
export class MyComponent {}
```

A corresponding route definition looks like this:

```
import { Route } from '@angular/router';

export const routes: Routes = [
  { path: '', redirectTo: 'tab-1', pathMatch: 'full' }, // Select the first tab by default
  { path: 'tab-1', component: Tab1Component },
  { path: 'tab-2', component: Tab2Component }
];
```

### Tabs with plain components

In general, using the tabs with the Angular router is preferred as the state is stored in the URL. So deep-linking and bookmarking is supported. In some cases, this might not be needed, e.g. when using the tabs to group simple information on a page.

In this case, you can use the `si-tabset` component with `si-tab` components as children.

```
<si-tabset-legacy>
  <si-tab-legacy heading="Tab 1">Tab 1 content</si-tab-legacy>
  <si-tab-legacy heading="Tab 2" [active]="true">Tab 2 content</si-tab-legacy>
</si-tabset-legacy>
```

```
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { SiTabsetLegacyComponent, SiTabLegacyComponent } from '@siemens/element-ng/tabs-legacy';

@Component({
  templateUrl: './my-component.html',
  imports: [SiTabsetLegacyComponent, SiTabLegacyComponent]
})
export class MyComponent {}
```

By default, no tab is active until the user clicks one. You can set the `active` property to `true` on one of the tabs to make it active by default. Ensure that only one tab has the `active` property set to `true`. Otherwise, the behavior is undefined.

### Closable tabs

Both tab variants can be used as a closable tab. A tab that can be closed must be explicitly marked as closable by setting the `closable` property to `true`.

```
<si-tabset-legacy>
  @if(showTab1) {
  <a
    si-tab-legacy
    heading="Tab 1"
    routerLink="./tab-1"
    closable
    (closeTriggered)="removeTab1()"
  ></a>
  }
</si-tabset-legacy>
```

```
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';
import { SiTabsetLegacyComponent, SiTabLegacyComponent } from '@siemens/element-ng/tabs-legacy';

@Component({
  templateUrl: './my-component.html',
  imports: [SiTabsetLegacyComponent, SiTabLegacyComponent, RouterLink]
})
export class MyComponent {
  showTab1 = true;

  removeTab1() {
    this.showTab1 = false;
  }
}
```

The tabset does not automatically remove a closed tab. When `closeTriggered` is emitted, you need to handle the removal of the tab in your component logic.

### Tab access control and guarding

By default, tabs should be hidden when the feature is irrelevant to the user’s role. However if there’s a clear reason for the user to see the tab (for example: to request access, or contact an admin), the tab may remain visible. In this case, navigation should still work but lead to a screen with an info page component with something like: "You don’t have access to this feature." "Contact your administrator to request access."

To achieve this use `canActivate` or `canDeactivate` provided by angular router guards or as custom callback input function in case of tabs with plain components to determine whether given tab can be activated or deactivated.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
/* eslint-disable  @typescript-eslint/no-deprecated */
import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {
  SiTabDeselectionEvent,
  SiTabLegacyComponent,
  SiTabsetLegacyComponent
} from '@siemens/element-ng/tabs-legacy';
import { LOG_EVENT } from '@siemens/live-preview';

interface TabModel {
  heading: string;
  closable?: boolean;
  disabled?: boolean;
  icon?: string;
  iconAltText?: string;
  badgeColor?: string;
  badgeContent?: string | boolean;
}

@Component({
  selector: 'app-sample',
  imports: [SiTabLegacyComponent, SiTabsetLegacyComponent, FormsModule],
  templateUrl: './si-tabs-legacy.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  selectedTabIndex = 0;
  deselectable = true;
  logEvent = inject(LOG_EVENT);

  tabs: TabModel[] = [
    { heading: 'Reception', closable: true, badgeContent: '11' },
    {
      heading: 'Conference room',
      closable: true,
      badgeContent: true
    },
    {
      heading: 'Lobby',
      disabled: true,
      icon: 'element-couch',
      iconAltText: 'Hall'
    },
    {
      heading: 'Pantry',
      badgeColor: 'danger',
      badgeContent: '1'
    },
    {
      heading: 'Washroom',
      badgeColor: 'warning',
      badgeContent: '2'
    }
  ];

  deselection(e: SiTabDeselectionEvent): void {
    if (e.target.heading === 'Deselectable' && !this.deselectable) {
      e.cancel();
    }
  }

  closeTab(tab: TabModel): void {
    this.tabs.splice(this.tabs.indexOf(tab), 1);
  }
}
```

Template:

```html
<si-tabset-legacy
  [(selectedTabIndex)]="selectedTabIndex"
  (deselect)="deselection($event)"
  (selectedTabIndexChange)="logEvent($event)"
>
  @for (tab of tabs; track tab) {
    <si-tab-legacy
      [badgeColor]="tab.badgeColor"
      [badgeContent]="tab.badgeContent"
      [closable]="tab.closable"
      [heading]="tab.heading"
      [icon]="tab.icon"
      [iconAltText]="tab.iconAltText"
      (closeTriggered)="closeTab(tab)"
    >
      <p class="mt-4"> Content for {{ tab.heading }} </p>
    </si-tab-legacy>
  }
  <si-tab-legacy heading="Deselectable">
    <p class="mt-4">Uncheck to prevent switching to another tab.</p>
    <label class="form-check mb-2">
      <input type="checkbox" class="form-check-input" [(ngModel)]="deselectable" />
      <span class="form-check-label">Enable tab switching</span>
    </label>
  </si-tab-legacy>
</si-tabset-legacy>
```

### [SiTabsetLegacyComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L60-L322>)

**Kind:** component

**Selector:** `si-tabset-legacy`

```
import { SiTabsetLegacyComponent } from '@siemens/element-ng/tabs-legacy';
```

Deprecated: Use the new components from `@siemens/element-ng/tabs` instead. See [https://element.siemens.io/components/layout-navigation/tabs/\#code](<https://element.siemens.io/components/layout-navigation/tabs/#code>) for usage instructions.

```
component SiTabsetLegacyComponent implements AfterViewInit, OnDestroy
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [selectDefaultTab](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L84-L84>) | `boolean` | `true` | If selectDefaultTab is passed as 'false', this implies no default tab selection i.e. on initial load of tabset component no tab gets selected. |
| [selectedTabIndex](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L105-L107>) | `number` |  | Returns the currently selected tab index. |
| [tabButtonMaxWidth](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L110-L110>) (optional) | `number` |  | Define an optional max-width in px for the tab buttons. The minimum value is `100`. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [deselect](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L122-L122>) | `SiTabDeselectionEvent` | Event emitter to notify when a tab became inactive. |
| [selectedTabIndexChange](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tabset/si-tabset-legacy.component.ts#L117-L117>) | `number` | Event emitter to notify about selected tab index changes. You can either use bi-directional binding with \[(selectedTabIndex)\] or separate both with \[selectedTabIndex\]=... and (selectedTabIndexChange)=... |

### [SiTabLegacyComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L32-L90>)

**Kind:** component

**Selector:** `si-tab-legacy`

```
import { SiTabLegacyComponent } from '@siemens/element-ng/tabs-legacy';
```

Deprecated: Use the new components from `@siemens/element-ng/tabs` instead. See [https://element.siemens.io/components/layout-navigation/tabs/\#code](<https://element.siemens.io/components/layout-navigation/tabs/#code>) for usage instructions.

```
component SiTabLegacyComponent implements OnChanges
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [badgeColor](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L51-L51>) (optional) | `string` |  | Background color of the badge. If no color is provided a red dot badge will be rendered. |
| [badgeContent](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L46-L46>) (optional) | `boolean \| TranslatableString` |  | Additional badge content. A value of<br><br>• `true` will render a red dot<br><br>• any string without a `badgeColor` will render a red dot with text<br><br>• any string with a `badgeColor` will render a normal badge |
| [closable](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L63-L63>) (optional) | `boolean` | `false` | Close the current tab. |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L57-L57>) | `boolean` | `false` | Disables the tab. |
| [heading](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L35-L35>) (optional) | `TranslatableString` |  | Title of the tab item. |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L37-L37>) (optional) | `string` |  | Icon of the tab item. |
| [iconAltText](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L39-L39>) (optional) | `TranslatableString` |  | Alternative name or translation key for icon. Used for A11y. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [closeTriggered](<https://github.com/siemens/element/blob/main/projects/element-ng/tabs-legacy/si-tab/si-tab-legacy.component.ts#L65-L65>) | `SiTabLegacyComponent` | Event emitter to notify when a tab is closed. |
