Tabs
updatedPanels switched by a row or column of tabs, with an indicator that slides to the active one.
Open Props in the corner of the example to switch the list's variant and size.
color on TabsList paints the line under the active tab, in Button's colours or your own. The line takes the colour's text shade, so a thin warning line still shows on the page. primary is the default; neutral gives the black underline of shadcn's tabs. The tab labels stay in the text colours, so a bar of coloured labels doesn't compete with the content. The pill indicator is a raised surface rather than a colour, so it ignores color; its fill is --tabs-pill, the page background in the light theme and a lighter wash under .dark.
size goes from xs (28px) to xl (48px) and scales padding, text and icons with it.
Installation
Usage
<script setup lang="ts">
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
</script>
<template>
<Tabs default-value="account">
<TabsList>
<TabsTrigger value="account">Account</TabsTrigger>
<TabsTrigger value="password">Password</TabsTrigger>
</TabsList>
<TabsContent value="account">Account settings.</TabsContent>
<TabsContent value="password">Password settings.</TabsContent>
</Tabs>
</template>
Tabs is Reka UI's tabs with kappa-ui's styles. TabsList sets the look — variant, color and size — and draws the indicator, which slides to the active tab. The indicator is measured after the page loads, so in server-rendered HTML the active tab is marked by its text colour until then.
Examples
Line
variant="line" drops the track and underlines the active tab.
The list is only as wide as its tabs; give it w-full to run the divider under the full width.
Vertical
With orientation="vertical" on Tabs, the list becomes a column beside the panels, and the up and down arrow keys move between tabs.
With icons
An icon before the label takes the size's icon size.
Keep inactive panels mounted
By default a hidden panel's content is removed from the page. With :unmount-on-hide="false" it stays mounted and hidden, so a form keeps what was typed into it.
API Reference
Every part accepts class, merged over its base classes.
Tabs
| Prop | Default | Type and description |
|---|---|---|
| defaultValue | — | StringOrNumberThe tab selected at first when |
| orientation | "horizontal" | DataOrientation
|
| dir | — | DirectionReading direction. Inherits from a surrounding |
| activationMode | "automatic" | "automatic" | "manual"
|
| modelValue | — | StringOrNumberThe selected tab's value, bound with |
| unmountOnHide | true | booleanRemoves a panel's content from the DOM while its tab is not selected. Turn it off to keep panels mounted, and their state, while hidden. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Event | Payload and description |
|---|---|
| update:modelValue | [payload: StringOrNumber]Fires when another tab is selected. |
| Slot | Scope and description |
|---|---|
| default | { modelValue: string | number | undefined; }The list and the panels. Receives |
TabsList
| Prop | Default | Type and description |
|---|---|---|
| loop | true | booleanArrow keys wrap from the last tab to the first and back. |
| asChild | — | booleanNot useful here: the list always adds the indicator after its content, so it never has a single child to merge onto. |
| as | — | AsTag | ComponentThe element or component to render. |
| variant | "pill" | NonNullable<"pill" | "line" | null | undefined>
|
| color | "primary" | TabsColor | (string & {})Colour role of the |
| size | "md" | TabsSizeTab height, from 28px for |
| Slot | Scope and description |
|---|---|
| default | {}The triggers. The indicator is added after them. |
TabsTrigger
| Prop | Default | Type and description |
|---|---|---|
| value* | — | StringOrNumberThe value that selects this tab and its panel. |
| disabled | — | booleanSkips the tab for arrow keys and ignores clicks. |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}The label, optionally with an icon. |
TabsContent
| Prop | Default | Type and description |
|---|---|---|
| value* | — | StringOrNumberThe tab value this panel belongs to. |
| forceMount | — | booleanKeeps this panel mounted whatever |
| asChild | — | booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it. |
| as | — | AsTag | ComponentThe element or component to render. |
| Slot | Scope and description |
|---|---|
| default | {}The panel's content. |
Props
- defaultValue
StringOrNumberThe tab selected at first whenv-modelis not used.- orientation
"horizontal" DataOrientationhorizontallays the list out in a row above the panels,verticalin a column beside them. Arrow keys follow the orientation.- dir
DirectionReading direction. Inherits from a surroundingConfigProviderwhen not set. Otherwiseltr.- activationMode
"automatic" "automatic" | "manual"automaticselects a tab as soon as it gets focus;manualwaits for Enter or Space.- modelValue
StringOrNumberThe selected tab's value, bound withv-model.- unmountOnHide
true booleanRemoves a panel's content from the DOM while its tab is not selected. Turn it off to keep panels mounted, and their state, while hidden.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Emits
- update:modelValue
[payload: StringOrNumber]Fires when another tab is selected.
Slots
- default
{ modelValue: string | number | undefined; }The list and the panels. ReceivesmodelValue.
Props
- loop
true booleanArrow keys wrap from the last tab to the first and back.- asChild
booleanNot useful here: the list always adds the indicator after its content, so it never has a single child to merge onto.- as
AsTag | ComponentThe element or component to render.- variant
"pill" NonNullable<"pill" | "line" | null | undefined>pillputs the tabs on a filled track with a raised thumb under the active one;lineunderlines the active tab.- color
"primary" TabsColor | (string & {})Colour role of thelineunderline. Any other name picks up a colour you declare on[data-slot][data-color="<name>"]. Thepillthumb is a surface and ignores it.- size
"md" TabsSizeTab height, from 28px forxsto 48px forxl, with matching padding, text and icon size.
Slots
- default
{}The triggers. The indicator is added after them.
Props
- value*
StringOrNumberThe value that selects this tab and its panel.- disabled
booleanSkips the tab for arrow keys and ignores clicks.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The label, optionally with an icon.
Props
- value*
StringOrNumberThe tab value this panel belongs to.- forceMount
booleanKeeps this panel mounted whateverunmountOnHidesays, for animating it with an external library.- asChild
booleanRender the single child instead of a wrapper, merging this part's attributes and classes onto it.- as
AsTag | ComponentThe element or component to render.
Slots
- default
{}The panel's content.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| tabs | data-orientation | The root. |
| tabs-list | data-variant, data-color, data-size, data-orientation, aria-orientation | The row or column of tabs. |
| tabs-indicator | — | The pill or line under the active tab. |
| tabs-trigger | data-state, data-disabled, data-orientation | A tab. |
| tabs-content | data-state, data-orientation | A panel. |
Accessibility
The list is a tablist, each trigger a tab, each panel a tabpanel labelled by its tab.
| Key | Action |
|---|---|
| Tab | Moves focus to the active tab, then into its panel. |
| → ← | In a horizontal list, moves to the next or previous tab, skipping disabled ones and wrapping around. In right-to-left they swap. |
| ↓ ↑ | The same in a vertical list. |
| Home / End | Moves to the first or last tab. |
| Enter / Space | Selects the focused tab when activation-mode is manual. |