Skip to contents

Tabs

A component for toggling between related panels on the same page.

View as Markdown

Anatomy

Import the component and assemble its parts:

Anatomy

Examples

Use the render prop and set nativeButton={false} on <Tabs.Tab> to render tabs as anchor elements.

Tabs as links

API reference

Root

Groups the tabs and the corresponding panels. Renders a <div> element.

defaultValueTabs.Tab.Value0
Description

The default value. Use when the component is not controlled. When the value is null, no Tab will be active.

Type
Default
0
valueTabs.Tab.Value
Name
Description

The value of the currently active Tab. Use when the component is controlled. When the value is null, no Tab will be active.

Type
onValueChangefunction
Description

Callback invoked when new value is being set.

Type
orientationTabs.Root.Orientation'horizontal'
Description

The component orientation (layout flow direction).

Type
Default
'horizontal'
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

AttributeDescription
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

Tabs.Root.PropsHide

Re-Export of Root props as TabsRootProps

Tabs.Root.StateHide

Tabs.Root.ChangeEventReasonHide

Tabs.Root.ChangeEventDetailsHide

Tabs.Root.OrientationHide

List

Groups the individual tab buttons. Renders a <div> element.

activateOnFocusbooleanfalse
Description

Whether to automatically change the active tab on arrow key focus. Otherwise, tabs will be activated using Enter or Space key press.

Type
Default
false
loopFocusbooleantrue
Description

Whether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.

Type
Default
true
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

AttributeDescription
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

Tabs.List.PropsHide

Re-Export of List props as TabsListProps

Tabs.List.StateHide

Tab

An individual interactive tab button that toggles the corresponding panel. Renders a <button> element.

value*
Name
Description

The value of the Tab.

nativeButtonbooleantrue
Description

Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).

Type
Default
true
disabledboolean
Description

Whether the Tab is disabled.

If a first Tab on a <Tabs.List> is disabled, it won’t initially be selected. Instead, the next enabled Tab will be selected. However, it does not work like this during server-side rendering, as it is not known during pre-rendering which Tabs are disabled. To work around it, ensure that defaultValue or value on <Tabs.Root> is set to an enabled Tab’s value.

Type
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
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 active tab).

data-active

Present when the tab is active.

AttributeDescription
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 active tab).

data-active

Present when the tab is active.

Tabs.Tab.PropsHide

Re-Export of Tab props as TabsTabProps

Tabs.Tab.StateHide

Tabs.Tab.ValueHide

Tabs.Tab.ActivationDirectionHide

Tabs.Tab.MetadataHide

Tabs.Tab.PositionHide

Tabs.Tab.SizeHide

Indicator

A visual indicator that can be styled to match the position of the currently active tab. Renders a <span> element.

renderBeforeHydrationbooleanfalse
Description

Whether to render itself before React hydrates. This minimizes the time that the indicator isn’t visible after server-side rendering.

Type
Default
false
classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

AttributeDescription
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

--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 height 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.

CSS VariableDescription
--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 height 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.

Tabs.Indicator.PropsHide

Re-Export of Indicator props as TabsIndicatorProps

Tabs.Indicator.StateHide

Panel

A panel displayed when the corresponding tab is active. Renders a <div> element.

value*
Name
Description

The value of the TabPanel. It will be shown when the Tab with the corresponding value is active.

classNamestring | function
Description

CSS class applied to the element, or a function that returns a class based on the component’s state.

Type
styleReact.CSSProperties | function
Name
Type
keepMountedbooleanfalse
Description

Whether to keep the HTML element in the DOM while the panel is hidden.

Type
Default
false
renderReactElement | function
Name
Description

Allows you to replace the component’s HTML element with a different tag, or compose it with another component.

Accepts a ReactElement or a function that returns the element to render.

Type
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

data-hidden

Present when the panel is hidden.

data-index

Indicates the index of the tab panel.

data-starting-style

Present when the panel is animating in.

data-ending-style

Present when the panel is animating out.

AttributeDescription
data-orientation

Indicates the orientation of the tabs.

data-activation-direction

Indicates the direction of the activation (based on the previous active tab).

data-hidden

Present when the panel is hidden.

data-index

Indicates the index of the tab panel.

data-starting-style

Present when the panel is animating in.

data-ending-style

Present when the panel is animating out.

Tabs.Panel.PropsHide

Re-Export of Panel props as TabsPanelProps

Tabs.Panel.StateHide

Tabs.Panel.MetadataHide