Skip to main content

Tabs

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

Manage your account settings and preferences.

Features

Installation

typo3 ui:add tabs

Read more about installing Components and Primitives.

Examples

Vertical Orientation

Display tabs in a vertical layout.

Manage your account settings and preferences.

Disabled Tabs

Disable specific tabs to prevent interaction.

First tab content.

Manual Activation

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

Press Enter to switch tabs.

API Reference

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.

tabs.root

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
compositeboolean
Whether the tab is composite.
No
true
deselectableboolean
Whether the active tab can be deselected when clicking on it.
No
-

Rendered data attributes

AttributeDescription
data-scopetabs
data-partroot
data-orientationThe orientation of the tabs
data-focusPresent when focused

tabs.list

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

Rendered data attributes

AttributeDescription
data-scopetabs
data-partlist
data-focusPresent when focused
data-orientationThe orientation of the list

tabs.trigger

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
-

Rendered data attributes

AttributeDescription
data-scopetabs
data-parttrigger
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

tabs.indicator

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

Rendered data attributes

AttributeDescription
data-scopetabs
data-partindicator
data-orientationThe orientation of the indicator

tabs.content

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

NameDescriptionRequiredDefault
valuestring
The value of the tab.
Yes
-

Rendered data attributes

AttributeDescription
data-scopetabs
data-partcontent
data-selectedPresent when selected
data-orientationThe orientation of the content

Machine JavaScript API

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

Accessibility

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.

Anatomy

<primitives:tabs.root>
    <primitives:tabs.list>
        <primitives:tabs.trigger />
        <primitives:tabs.indicator />
    </primitives:tabs.list>
    <primitives:tabs.content />
</primitives:tabs.root>