@zendeskgarden/react-tabs package provides accessible tab components built on WAI-ARIA tab patterns. Tabs can be rendered horizontally (default) or vertically, and support both controlled and uncontrolled selection state.
Installation
Place a
ThemeProvider from @zendeskgarden/react-theming at the root of your React application. All Garden components must be rendered inside a ThemeProvider.Usage
Basic tabs
Tabs.Tab receives an item value that links it to its matching Tabs.TabPanel. The onChange callback receives the item value of the newly selected tab.
Vertical tabs
PassisVertical to the Tabs component to stack the tab list alongside the panels.
Uncontrolled tabs
OmitselectedItem and onChange to let the component manage its own state. The first non-disabled tab is selected by default.
Tabs
The root container component. Provides state context to all childTab, TabList, and TabPanel components.
Props
The
item value of the currently selected tab. When provided, the component operates in controlled mode and you must also provide onChange.Callback fired when the user selects a tab. Receives the
item value of the newly selected tab.Arranges the tab list and panels side by side in a vertical orientation.
Tabs.TabList
Wrapper for the list ofTabs.Tab components. Renders as a <div> with role="tablist".
Tabs.TabList forwards all standard HTMLAttributes<HTMLDivElement> props.
Tabs.Tab
An individual tab trigger. Must be a direct child ofTabs.TabList. Each tab needs a unique item value that matches its corresponding Tabs.TabPanel.
Props
A unique value identifying this tab. Passed to
onChange when the tab is selected and used to match the tab to its TabPanel.Prevents the tab from being selected and removes it from the keyboard navigation order.
Tabs.TabPanel
The content panel associated with a tab. Renders hidden panels withhidden attribute for accessibility; the active panel is visible.
Props
The value that links this panel to its corresponding
Tabs.Tab. Must match the item value on the associated tab.Keyboard navigation
| Key | Behavior |
|---|---|
ArrowLeft / ArrowRight | Move focus between tabs (horizontal orientation) |
ArrowUp / ArrowDown | Move focus between tabs (vertical orientation) |
Home | Move focus to the first tab |
End | Move focus to the last tab |
Enter / Space | Select the focused tab |
Exports
The following are exported from@zendeskgarden/react-tabs:
| Export | Description |
|---|---|
Tabs | Root container with Tabs.Tab, Tabs.TabList, and Tabs.TabPanel subcomponents |