TabMenu is a navigation component that displays items as tab headers. Example below uses nested routes with TabMenu.

import { TabMenuModule } from 'primeng/tabmenu';

TabMenu requires a collection of menuitems as its model.

<p-tabMenu [model]="items"></p-tabMenu>

By default item that matches the active route is highlighted, alternatively activeItem property can be used choose the initial active item.

<p-tabMenu [model]="items" [activeItem]="activeItem"></p-tabMenu>

For controlled mode, use activeItem property along with activeItemChange event are needed to manage the active item.

<button type="button" pButton pRipple label="Activate Last" (click)="activateLast()" class="mb-3"></button>
<p-tabMenu [model]="items" [activeItem]="activeItem" (activeItemChange)="onActiveItemChange($event)"></p-tabMenu>

Setting scrollable property to true enables scrolling if content overflows.

<p-tabMenu [scrollable]="true" [model]="items" [activeItem]="activeItem"></p-tabMenu>

TabMenu supports templating via the item template which gets the menuitem instance and the index.

<p-tabMenu [model]="items" [activeItem]="activeItem">
    <ng-template pTemplate="item" let-item>
        <a class="p-menuitem-link flex justify-content-between align-items-center p-3">
                <span [class]="item.icon"></span>
                <span> {{ item.label }}</span>
                <span *ngIf="item.shortcut" [class]="item.shortcutClass">{{ item.shortcut }}</span>
                <p-badge *ngIf="item.badge" [value]="item.badge" [severity]="item.badgeSeverity"></p-badge>

Following is the list of structural style classes, for theming classes visit theming page.

p-tabmenuContainer element.
p-tabmenu-navList element of headers.
p-tabmenuitemMenuitem element.
p-menuitem-linkLink inside a menuitem.
p-menuitem-textLabel of a menuitem.
p-menuitem-iconIcon of a menuitem.

Screen Reader

TabMenu component uses the menubar role and the value to describe the menu can either be provided with aria-labelledby or aria-label props. Each list item has a presentation role whereas anchor elements have a menuitem role with aria-label referring to the label of the item and aria-disabled defined if the item is disabled.

Keyboard Support

tabAdds focus to the active tab header when focus moves in to the component, if there is already a focused tab header moves the focus out of the component based on the page tab sequence.
enterActivates the focused tab header.
spaceActivates the focused tab header.
right arrowMoves focus to the next header.
left arrowMoves focus to the previous header.
homeMoves focus to the first header.
endMoves focus to the last header.