GitHub

Tabs

A set of layered sections of content—known as tab panels—that are displayed one at a time.

Loading example…

Installation

pnpm dlx shadcn@latest add @sui/tabs

Install with the shadcn CLI or use the shared @workspace/ui package. Follow the installation guide to configure the registry, load styles, and choose import aliases.

Usage

import { Tabs, TabsContent, TabsList, TabsTrigger } from "@workspace/ui/components/tabs"
<Tabs defaultValue="account" className="w-[400px] max-w-full">
  <TabsList>
    <TabsTrigger value="account">Account</TabsTrigger>
    <TabsTrigger value="password">Password</TabsTrigger>
  </TabsList>
  <TabsContent value="account">Make changes to your account here.</TabsContent>
  <TabsContent value="password">Change your password here.</TabsContent>
</Tabs>

Composition

Use the following composition to build Tabs:

Tabs
├── TabsList
│   ├── TabsTrigger
│   └── TabsTrigger
├── TabsContent
└── TabsContent

Line

Use the variant="line" prop on TabsList for a line style.

Loading example…

Segment

Use the variant="segment" prop on TabsList for a compact segmented control. Use wrapperClassName="w-full" to fill the available width.

Loading example…

Ghost

Use variant="ghost" on TabsList for the pill indicator without the muted track. It works in a row and, with orientation="vertical", in a side column.

Loading example…

Overflow

Tab lists scroll automatically when they exceed the available space. Arrow controls and faded edges indicate more tabs. Selected and focused tabs scroll into view within the list, including vertical and RTL layouts.

Loading example…

Vertical

Use orientation="vertical" for vertical tabs.

Loading example…

Disabled

Loading example…

Icons

Loading example…

Pass icons through icon and set icons="selected" on Tabs to show an icon only on the selected tab. It springs open beside the label while the indicator glides over, and folds away on the tab left behind.

Loading example…

RTL

To enable RTL support in shadcn/ui, see the RTL configuration guide.

Loading example…

Animation

The selected indicator springs between tabs without overshooting the list edges; its first placement lands in place. In the default and segment variants, each label has a second copy in primary-foreground, clipped to wherever the indicator overlaps it, so the label colour changes exactly at the indicator's edge during a glide. Panels use a 250ms easing. Content fades in from an 8px offset on the side of the newly selected tab: left or right for horizontal tabs, up or down for vertical tabs. Base UI derives the direction from the actual tab positions, including RTL. The initial panel appears without an entrance animation; inactive panels leave the layout immediately and cannot receive focus. Reduced motion makes the indicator jump to its new tab, shows and hides icons in place, and disables the panel transition and offset. Selected tabs use the theme's primary and primary-foreground colors; the line variant uses primary for its indicator and selected label.

Use indicatorClassName on TabsList to customize the indicator and wrapperClassName for the outer container's layout. className, ref, and render continue to apply to the Base UI list. TabsContent retains Base UI's keepMounted behavior.

API Reference

Also accepts feedback for opt-in haptics and sound; see Feedback.

See the Base UI Tabs documentation.