TabMenu

TabMenu is a navigation/command component that displays items as tab headers.


import { TabMenu } from 'primereact/tabmenu';
         

Steps requires a collection of menuitems as its model.


<TabMenu model={items} />
         

In controlled mode, a binding to activeIndex property along with onTabChange event are needed to manage the active item.


<Button onClick={() => setActiveIndex(0)} className="p-button-outlined mb-5" label="Activate 1st" />
<TabMenu model={items} activeIndex={activeIndex} onTabChange={(e) => setActiveIndex(e.index)} />
         

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

NameElement
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.
Accessibility guide documents the specification of this component based on WCAG guidelines, the implementation is in progress.

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

KeyFunction
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.
Visit the API documentation for detailed information about all the properties, events and methods of the component.