Tabs
A component for toggling between related panels on the same page.
API reference
Import the component and assemble its parts:
import { Tabs } from '@base-ui-components/react/tabs';
<Tabs.Root>
<Tabs.List>
<Tabs.Tab />
<Tabs.Indicator />
</Tabs.List>
<Tabs.Panel />
</Tabs.Root>Root
Groups the tabs and the corresponding panels.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
defaultValue |
|
| |
value |
|
| |
onValueChange |
|
| |
orientation |
|
| |
className |
|
| |
render |
|
|
| Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the tabs. | |
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
List
Groups the individual tab buttons.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
activateOnFocus |
|
| |
loop |
|
| |
className |
|
| |
render |
|
|
| Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the tabs. | |
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
Tab
An individual interactive tab button that toggles the corresponding panel.
Renders a <button> element.
| Prop | Type | Default | |
|---|---|---|---|
value |
|
| |
className |
|
| |
render |
|
|
| Attribute | Description | |
|---|---|---|
data-selected | Present when the tab is selected. | |
data-highlighted | Present when the tab is highlighted. | |
data-orientation | Indicates the orientation of the tabs. | |
data-disabled | Present when the tab is disabled. | |
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
Indicator
A visual indicator that can be styled to match the position of the currently active tab.
Renders a <span> element.
| Prop | Type | Default | |
|---|---|---|---|
renderBeforeHydration |
|
| |
className |
|
| |
render |
|
|
| Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the tabs. | |
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
| CSS Variable | Description | |
|---|---|---|
--active-tab-bottom | Indicates the distance on the bottom side from the parent's container if the tab is active. | |
--active-tab-height | Indicates the width of the tab if it is active. | |
--active-tab-left | Indicates the distance on the left side from the parent's container if the tab is active. | |
--active-tab-right | Indicates the distance on the right side from the parent's container if the tab is active. | |
--active-tab-top | Indicates the distance on the top side from the parent's container if the tab is active. | |
--active-tab-width | Indicates the width of the tab if it is active. | |
Panel
A panel displayed when the corresponding tab is active.
Renders a <div> element.
| Prop | Type | Default | |
|---|---|---|---|
value |
|
| |
className |
|
| |
keepMounted |
|
| |
render |
|
|
| Attribute | Description | |
|---|---|---|
data-orientation | Indicates the orientation of the tabs. | |
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-hidden | Present when the panel is hidden. | |
data-index | Indicates the index of the tab panel. | |