Skip to content

Tabs

A tab list that switches between related panels in place.

Conversations
1,284
Avg. response
1.8 s
Satisfaction
92%
hero.tsx

Usage guidelines

  • Use Tabs when the choice swaps the panel it controls, whatever the control looks like. Use SegmentedControl for a mode or filter applied to content that stays in place, and links for navigation between pages.
  • Give TabsList an accessible name with aria-label or aria-labelledby when the page has more than one tab list or no heading introduces it. Each TabsPanel takes its name from its tab.
  • Place TabsIndicator inside TabsList. It draws the active underline and slides between tabs; tabs do not draw their own. The list has no baseline of its own; add border-b border-divider-subtle when it sits directly above its panels.
  • Keep tab labels short and on one line. Disable a tab that is temporarily unavailable rather than removing it, so the set of sections stays stable.
  • TabsPanel has no padding. Add spacing on the panel so its inset focus ring keeps clear of the content.

Anatomy

tsx
tsx

Examples

Disabled tab

disabled on TabsTab keeps the tab in the list at reduced opacity. Arrow keys still move focus to it, but it cannot be activated.

24 documents, 3 still indexing.
disabled.tsx

Activate on focus

By default the arrow keys only move focus, and Enter or Space activates the focused tab. Set activateOnFocus on TabsList when panels are cheap to render, so moving focus also switches the panel.

client.create_chat_message(inputs={}, query='Hello', user='abc-123')
activate-on-focus.tsx

Controlled value

Control the active tab with value and onValueChange when something outside the tab list changes it, such as a button elsewhere on the page.

The draft has 2 unpublished changes.
controlled.tsx

Keyboard

KeyAction
Right arroworLeft arrowMoves focus to the next or previous tab, wrapping at the ends. Disabled tabs take focus.
HomeorEndMoves focus to the first or last tab.
EnterorSpaceActivates the focused tab and shows its panel.
TabMoves focus from the tab list to the active panel.

API reference

Tabs

Groups a tab list and its corresponding tab panels. Renders a <div> element.

Base UI Tabs.Root docs

Data attributes
AttributeDescription
data-activation-direction

Values: 'left' | 'right' | 'up' | 'down' | 'none'

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

data-orientation

Values: 'horizontal' | 'vertical'

Indicates the orientation of the tabs.

TabsIndicator

Draws an active underline inside TabsList that slides between tabs. Renders a <span> element.

Base UI Tabs.Indicator docs

Data attributes
AttributeDescription
data-activation-direction

Values: 'left' | 'right' | 'up' | 'down' | 'none'

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

data-orientation

Values: 'horizontal' | 'vertical'

Indicates the orientation of the tabs.

CSS variables
VariableDescription
--active-tab-left

Values: number

Indicates the distance on the left side from the parent's container if the tab is active.

--active-tab-right

Values: number

Indicates the distance on the right side from the parent's container if the tab is active.

--active-tab-top

Values: number

Indicates the distance on the top side from the parent's container if the tab is active.

--active-tab-bottom

Values: number

Indicates the distance on the bottom side from the parent's container if the tab is active.

--active-tab-width

Values: number

Indicates the width of the tab if it is active.

--active-tab-height

Values: number

Indicates the height of the tab if it is active.

TabsList

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

Base UI Tabs.List docs

Data attributes
AttributeDescription
data-activation-direction

Values: 'left' | 'right' | 'up' | 'down' | 'none'

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

data-orientation

Values: 'horizontal' | 'vertical'

Indicates the orientation of the tabs.

TabsPanel

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

Base UI Tabs.Panel docs

Data attributes
AttributeDescription
data-index

Indicates the index of the tab panel.

data-activation-direction

Values: 'left' | 'right' | 'up' | 'down' | 'none'

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

data-orientation

Values: 'horizontal' | 'vertical'

Indicates the orientation of the tabs.

data-hidden

Present when the panel is hidden.

data-starting-style

Present when the panel begins animating in.

data-ending-style

Present when the panel is animating out.

TabsTab

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

Base UI Tabs.Tab docs

Data attributes
AttributeDescription
data-activation-direction

Values: 'left' | 'right' | 'up' | 'down' | 'none'

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

data-orientation

Values: 'horizontal' | 'vertical'

Indicates the orientation of the tabs.

data-disabled

Present when the tab is disabled.

data-active

Present when the tab is active.