Overview
Tabs organize content into multiple sections and allow users to navigate between them. Only one tab panel is visible at a time. Tabs are useful when you want to reduce vertical scrolling or separate content into logical groups. Tabs come in both horizontal and vertical orientations, with multiple visual variants to suit different design needs.Installation
Usage
Variants
Fitted Tabs
Fitted tabs expand to fill the width of their container.Vertical Tabs
Inverse Tabs
Controlled Tabs
Use theuseTabState hook to control tab state externally.
Disabled Tab
Props
Tabs
The TabList and TabPanels components.
The ID of the initially selected tab.
Whether tabs are arranged horizontally or vertically.
Changes the visual style of the tabs. Fitted variants make tabs equally fill the container width.
When using the
useTabState hook to control tabs externally, pass the returned state here.Base ID for generating tab and panel IDs.
Overrides the default element name to apply unique styles with the Customization Provider.
TabList
The Tab components to display.
Required accessible label for the tab list. Describes the purpose of the tabs.
Changes each Tab to either equally fit the width of the containing element or hug the contents of its label.
Overrides the default element name to apply unique styles with the Customization Provider.
Tab
The text or content to display in the tab.
Unique identifier for the tab. Used to associate with TabPanel via tabId.
Whether the tab is disabled and cannot be selected.
When an element is disabled, it may still be focusable. Works similarly to readOnly on form elements.
Overrides the default element name to apply unique styles with the Customization Provider.
TabPanels
The TabPanel components to display.
Overrides the default element name to apply unique styles with the Customization Provider.
TabPanel
The content to display when this tab is selected.
The ID of the Tab component this panel pairs with.
Unique identifier for the panel.
Removes the default padding from the TabPanel by setting to ‘space0’.
Overrides the default element name to apply unique styles with the Customization Provider.
Accessibility
- Tabs follow the ARIA Tabs pattern.
- The TabList has a required
aria-labelto describe the purpose of the tabs. - Keyboard navigation:
- Tab: Moves focus into and out of the tab list
- Arrow keys: Move between tabs (Left/Right for horizontal, Up/Down for vertical)
- Home/End: Jump to first/last tab
- Selected tabs have
aria-selected="true". - Each TabPanel is associated with its Tab via
aria-labelledby. - Only the selected panel is rendered in the DOM and marked with
aria-hidden="false". - Disabled tabs are not keyboard navigable and have
aria-disabled="true".
Best Practices
Do
- Use tabs to organize related content into logical groups
- Keep tab labels short and descriptive (1-2 words)
- Use horizontal tabs for most cases
- Provide an
aria-labelon TabList that describes the purpose - Keep the number of tabs reasonable (typically 3-7)
Don’t
- Don’t use tabs for sequential navigation (use a stepper instead)
- Don’t nest tabs within tabs
- Don’t use tabs if users need to see content from multiple tabs simultaneously
- Don’t use tabs as a form of primary navigation