Tabs
Switch between different views
Source
LLM docs
Docs
PackageIcon
Usage
Controlled Tabs
To control the Tabs state, use value and onChange props:
Uncontrolled Tabs
If you do not need to subscribe to Tabs state changes, use defaultValue:
Change colors
To change the colors of all tabs, set color on the Tabs component; to change the color of an individual tab,
set color on Tabs.Tab.
Tabs position
To display a tab on the opposite side, set margin-left: auto with the ml="auto" prop or with className:
Inverted tabs
To make tabs inverted, place Tabs.Panel components before Tabs.List and add the inverted prop to the Tabs component:
Vertical tabs placement
To change the placement of Tabs.List in vertical orientation, set the placement prop:
Custom variants
Example of custom variant with FloatingIndicator:
Disabled tabs
Set the disabled prop on the Tabs.Tab component to disable a tab.
Disabled tabs cannot be activated with the mouse or keyboard, and they will be skipped when the user navigates with arrow keys:
Activation mode
By default, tabs are activated when the user presses arrow keys or Home/End keys.
To disable that, set activateTabWithKeyboard={false} on the Tabs component:
Tab deactivation
By default, the active tab cannot be deactivated. To allow that, set allowTabDeactivation on the Tabs component:
Unmount inactive tabs
By default, inactive Tabs.Panel will stay mounted; to unmount inactive tabs, set keepMounted={false} on Tabs.
This is useful when you want to render components that impact performance inside Tabs.Panel. Note that
components that are rendered inside Tabs.Panel will reset their state on each mount (tab change).
Get tab control ref
Usage with react-router
Usage with Next.js router
Styles API
Tabs supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.
Component Styles API
Hover over selectors to highlight corresponding elements
Example of Styles API usage to customize tab styles:
Example with Scroller
Use Scroller component to make the tabs list scrollable when there are too many tabs to fit in the available space:
Accessibility
The Tabs component follows WAI-ARIA recommendations on accessibility.
If you use Tabs.Tab without text content, for example, only with an icon, then set aria-label
or use the VisuallyHidden component:
To set the tabs list label, set aria-label on the Tabs.List component; it will be announced by screen reader: