Skip to main content

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

Manage your account settings and preferences.
<primitives:tabs.root>
    <primitives:tabs.list>
        <primitives:tabs.trigger />
        <primitives:tabs.indicator />
    </primitives:tabs.list>
    <primitives:tabs.content />
</primitives:tabs.root>
typo3 ui:add tabs

Read more about installing Components and Primitives.

Display tabs in a vertical layout.

Manage your account settings and preferences.

Disable specific tabs to prevent interaction.

First tab content.

Require pressing Enter or Space to activate tabs instead of activating on focus.

Press Enter to switch tabs.

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

Provides shared tabs state and wraps the tab list and panels. Renders a <div> element.

NameDescriptionRequiredDefault
loopFocusboolean
Whether the keyboard navigation will loop from last tab to first, and vice versa.
No
true
defaultValuestring
The initial selected tab value when rendered. Use when you don't need to control the selected tab value.
No
-
orientationEnum\Orientation
The orientation of the tabs.
No
Horizontal
activationModeEnum\TabsActivationMode
The activation mode of the tabs.
No
Automatic
virtualFocusboolean
Whether the tabs use virtual focus instead of a roving tabindex. Triggers then receive no DOM focus: arrow keys only move the focused value and every trigger and panel stays out of the tab order. Useful when the tabs live inside another widget that manages focus, like a combobox.
No
false
deselectableboolean
Whether the active tab can be deselected when clicking on it.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-tabs-root<uid>
data-orientationThe orientation of the tabs
data-focusPresent when focused

Groups the tab triggers. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-tabs-list<uid>
data-focusPresent when focused
data-orientationThe orientation of the list

Activates a tab and focuses its panel. Renders a <button> element.

NameDescriptionRequiredDefault
valuestring
The value of the tab.
Yes
-
disabledboolean
Whether the tab is disabled.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-tabs-trigger<uid>
data-orientationThe orientation of the trigger
data-disabledPresent when disabled
data-valueThe value of the item
data-selectedPresent when selected
data-focusPresent when focused
data-ssrPresent when not rendered in the browser. Useful for ssr styling

Displays the active tab indicator. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-tabs-indicator<uid>
data-orientationThe orientation of the indicator

Displays the panel content for a tab. Renders a <div> element.

NameDescriptionRequiredDefault
valuestring
The value of the tab.
Yes
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-tabs-content<uid>
data-selectedPresent when selected
data-orientationThe orientation of the content
NameTypeDescription
valuestring | nullThe current value of the tabs.
focusedValuestring | nullThe value of the tab that is currently focused.
setValue(value: string) => voidSets the value of the tabs.
clearValueVoidFunctionClears the value of the tabs.
setIndicatorRect(value: string) => voidSets the indicator rect to the tab with the given value
syncTabIndexVoidFunctionSynchronizes the tab index of the content element. Useful when rendering tabs within a select or combobox
focusVoidFunctionSet focus on the selected tab trigger
selectNext(fromValue?: string) => voidSelects the next tab
selectPrev(fromValue?: string) => voidSelects the previous tab
getTriggerState(props: TriggerProps) => TriggerStateReturns the state of the trigger with the given props
getContentState(props: ContentProps) => ContentStateReturns the state of the content with the given props
KeyDescription
TabWhen focus moves onto the tabs, focuses the active trigger. When a trigger is focused, moves focus to the active content.
ArrowDownMoves focus to the next trigger in vertical orientation and activates its associated content.
ArrowRightMoves focus to the next trigger in horizontal orientation and activates its associated content.
ArrowUpMoves focus to the previous trigger in vertical orientation and activates its associated content.
ArrowLeftMoves focus to the previous trigger in horizontal orientation and activates its associated content.
HomeMoves focus to the first trigger and activates its associated content.
EndMoves focus to the last trigger and activates its associated content.
EnterSpaceIn manual mode, when a trigger is focused, moves focus to its associated content.