Tabs
A component for toggling between related panels on the same page.
API reference
Import the component and place its parts the following way:
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 | |
---|---|---|---|
className | string | (state) => string | undefined | |
defaultValue | any | 0 | |
onValueChange | (value, event) => void | undefined | |
orientation | 'horizontal' | 'vertical' | 'horizontal' | |
render | | React.ReactElement | undefined | |
value | any | undefined |
Attribute | Description | |
---|---|---|
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-orientation | Indicates the orientation of the tabs. |
List
Groups the individual tab buttons.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
activateOnFocus | boolean | true | |
className | string | (state) => string | undefined | |
loop | boolean | true | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-orientation | Indicates the orientation of the tabs. |
Tab
An individual interactive tab button that toggles the corresponding panel.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined | |
value | any | undefined |
Attribute | Description | |
---|---|---|
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-disabled | Present when the tab is disabled. | |
data-highlighted | Present when the tab is highlighted. | |
data-orientation | Indicates the orientation of the tabs. | |
data-selected | Present when the tab is selected. |
Indicator
A visual indicator that can be styled to match the position of the currently active tab.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined | |
renderBeforeHydration | boolean | false |
Attribute | Description | |
---|---|---|
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-orientation | Indicates the orientation of the tabs. |
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 | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined | |
value | any | undefined |
Attribute | Description | |
---|---|---|
data-activation-direction | Indicates the direction of the activation (based on the previous selected tab). | |
data-hidden | Present when the panel is hidden. | |
data-orientation | Indicates the orientation of the tabs. |