# Tabs

> Layered content panels with a spring-animated active indicator, nine visual variants, stacked icon layout, and vertical orientation.

Canonical URL: https://taut-ui.com/docs/components/tabs

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs className="w-80 max-w-full items-center" defaultValue="account">
      
      <TabsPanel className="min-h-14 pt-2 text-center" value="account">
        <p className="text-muted-foreground text-sm">
          Manage your account and preferences.
        </p>
      
      <TabsPanel className="min-h-14 pt-2 text-center" value="password">
        <p className="text-muted-foreground text-sm">
          Update your password and security.
        </p>
      
      <TabsPanel className="min-h-14 pt-2 text-center" value="settings">
        <p className="text-muted-foreground text-sm">
          Configure your workspace settings.
        </p>
      
    </Tabs>
  );
}
```

## Installation [#installation]

**CLI**

```bash
npx shadcn@latest add https://taut-ui.com/r/tabs.json
```

**Manual**

- Install the following dependencies:

```bash
npm install @base-ui/react class-variance-authority
```

- Copy and paste the following code into your project.

```tsx title="components/ui/tabs.tsx"
"use client";

import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
import { cva, type VariantProps } from "class-variance-authority";
import type React from "react";
import { cn } from "@/lib/utils";

export const tabsListVariants = cva(
  [
    "group/tabs-list relative z-0 flex items-center justify-center text-muted-foreground",
    "data-[orientation=vertical]:w-fit data-[orientation=vertical]:flex-col",
    "data-stacked:[--tab-h:4rem]",
  ],
  {
    defaultVariants: { variant: "default" },
    variants: {
      variant: {
        circular:
          "w-fit gap-1.5 rounded-full bg-[color-mix(in_oklab,var(--color-background),var(--color-foreground)_6%)] p-1 [--tab-h:2.25rem] [--tab-on:var(--color-primary-foreground)] [--tab-r:calc(infinity*1rem)]",
        clean:
          "w-full [--tab-h:3rem] [--tab-on:var(--color-primary)] [--tab-r:0rem] *:data-[slot=tabs-tab]:flex-1",
        default:
          "w-fit gap-0.5 rounded-xl bg-[color-mix(in_oklab,var(--color-background),var(--color-foreground)_6%)] p-1 [--tab-h:2rem] [--tab-on:var(--color-primary-foreground)] [--tab-r:var(--radius-lg)]",
        dot: "w-full [--tab-h:3rem] [--tab-on:var(--color-primary)] [--tab-r:0rem] data-[orientation=horizontal]:shadow-[inset_0_-0.0625rem_0_var(--color-border)] data-[orientation=vertical]:shadow-[inset_-0.0625rem_0_0_var(--color-border)] *:data-[slot=tabs-tab]:flex-1",
        outline:
          "w-fit gap-1 rounded-full border border-border p-1 [--tab-h:2.25rem] [--tab-on:var(--color-primary-foreground)] [--tab-r:calc(infinity*1rem)]",
        pill: "w-fit gap-1 rounded-full bg-[color-mix(in_oklab,var(--color-background),var(--color-foreground)_6%)] p-1 [--tab-h:2.25rem] [--tab-on:var(--color-primary-foreground)] [--tab-r:calc(infinity*1rem)]",
        primary:
          "w-full [--tab-h:3rem] [--tab-on:var(--color-primary)] [--tab-r:0rem] data-[orientation=horizontal]:shadow-[inset_0_-0.0625rem_0_var(--color-border)] data-[orientation=vertical]:shadow-[inset_-0.0625rem_0_0_var(--color-border)] *:data-[slot=tabs-tab]:flex-1",
        secondary:
          "w-full [--tab-h:3rem] [--tab-on:var(--color-primary)] [--tab-r:0rem] data-[orientation=horizontal]:shadow-[inset_0_-0.0625rem_0_var(--color-border)] data-[orientation=vertical]:shadow-[inset_-0.0625rem_0_0_var(--color-border)] *:data-[slot=tabs-tab]:flex-1",
        underline:
          "w-fit gap-1 [--tab-h:2.5rem] [--tab-on:var(--color-primary)] [--tab-r:0rem] data-[orientation=horizontal]:shadow-[inset_0_-0.0625rem_0_var(--color-border)] data-[orientation=vertical]:shadow-[inset_-0.0625rem_0_0_var(--color-border)]",
      },
    },
  },
);

export type TabsVariant = NonNullable<
  VariantProps<typeof tabsListVariants>["variant"]
>;

export function Tabs({
  className,
  ...props
}: TabsPrimitive.Root.Props): React.ReactElement {
  return (
    <TabsPrimitive.Root
      className={cn(
        "flex flex-col gap-2 data-[orientation=vertical]:flex-row data-[orientation=vertical]:gap-4",
        className,
      )}
      data-slot="tabs"
      {...props}
    />
  );
}

export interface TabsListProps extends TabsPrimitive.List.Props {
  variant?: TabsVariant;
  stacked?: boolean;
}

export function TabsList({
  variant = "default",
  stacked = false,
  className,
  children,
  ...props
}: TabsListProps): React.ReactElement {
  return (
    <TabsPrimitive.List
      className={cn(tabsListVariants({ variant }), className)}
      data-slot="tabs-list"
      data-stacked={stacked ? "" : undefined}
      data-variant={variant}
      {...props}
    >
      {children}
      <TabsPrimitive.Indicator
        className={cn(
          "absolute bottom-0 left-0 duration-200 [transition-property:width,height,translate] [transition-timing-function:linear(0,0.5_8%,0.9_20%,1.02_34%,1_60%,1)] motion-reduce:transition-none",
          (variant === "default" ||
            variant === "pill" ||
            variant === "outline") &&
            "-z-1 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) -translate-y-(--active-tab-bottom) rounded-(--tab-r) bg-primary shadow-xs",
          variant === "circular" &&
            "-z-1 h-(--active-tab-height) w-(--active-tab-height) translate-x-[calc(var(--active-tab-left)+(var(--active-tab-width)-var(--active-tab-height))/2)] -translate-y-(--active-tab-bottom) rounded-full bg-primary shadow-xs",
          (variant === "primary" || variant === "clean") &&
            "z-10 rounded-full bg-primary data-[orientation=vertical]:right-0 data-[orientation=vertical]:left-auto data-[orientation=horizontal]:h-0.75 data-[orientation=vertical]:h-[calc(var(--active-tab-height)*0.5)] data-[orientation=horizontal]:w-[min(3rem,calc(var(--active-tab-width)*0.6))] data-[orientation=vertical]:w-0.75 data-[orientation=horizontal]:translate-x-[calc(var(--active-tab-left)+(var(--active-tab-width)-min(3rem,calc(var(--active-tab-width)*0.6)))/2)] data-[orientation=horizontal]:-translate-y-(--active-tab-bottom) data-[orientation=vertical]:-translate-y-[calc(var(--active-tab-bottom)+var(--active-tab-height)*0.25)]",
          (variant === "secondary" || variant === "underline") &&
            "z-10 bg-primary data-[orientation=vertical]:right-0 data-[orientation=vertical]:left-auto data-[orientation=horizontal]:h-0.5 data-[orientation=vertical]:h-(--active-tab-height) data-[orientation=horizontal]:w-(--active-tab-width) data-[orientation=vertical]:w-0.5 data-[orientation=horizontal]:translate-x-(--active-tab-left) data-[orientation=horizontal]:-translate-y-(--active-tab-bottom) data-[orientation=vertical]:-translate-y-(--active-tab-bottom)",
          variant === "dot" &&
            "z-10 size-1.5 rounded-full bg-primary data-[orientation=vertical]:right-1.5 data-[orientation=vertical]:left-auto data-[orientation=horizontal]:translate-x-[calc(var(--active-tab-left)+(var(--active-tab-width)-0.375rem)/2)] data-[orientation=horizontal]:-translate-y-1.5 data-[orientation=vertical]:-translate-y-[calc(var(--active-tab-bottom)+(var(--active-tab-height)-0.375rem)/2)]",
        )}
        data-slot="tab-indicator"
      />
    </TabsPrimitive.List>
  );
}

export function TabsTab({
  className,
  ...props
}: TabsPrimitive.Tab.Props): React.ReactElement {
  return (
    <TabsPrimitive.Tab
      className={cn(
        "relative z-1 flex h-(--tab-h) shrink-0 cursor-pointer select-none items-center justify-center gap-2 whitespace-nowrap rounded-(--tab-r) px-3.5 font-medium text-muted-foreground text-sm leading-5 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset data-disabled:pointer-events-none data-active:text-(--tab-on,var(--color-primary-foreground)) data-disabled:opacity-38 data-active:hover:text-(--tab-on,var(--color-primary-foreground))",
        "data-[orientation=vertical]:w-full data-[orientation=vertical]:justify-start",
        "group-data-[variant=circular]/tabs-list:size-(--tab-h) group-data-[variant=circular]/tabs-list:px-0",
        "group-data-stacked/tabs-list:flex-col group-data-stacked/tabs-list:gap-1",
        "[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
        className,
      )}
      data-slot="tabs-tab"
      {...props}
    />
  );
}

export function TabsPanel({
  className,
  ...props
}: TabsPrimitive.Panel.Props): React.ReactElement {
  return (
    <TabsPrimitive.Panel
      className={cn("flex-1 outline-none", className)}
      data-slot="tabs-content"
      {...props}
    />
  );
}

export { TabsPrimitive, TabsTab as TabsTrigger, TabsPanel as TabsContent };
```

- Update the import paths to match your project setup.

## Usage [#usage]

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs"
```

```tsx
<Tabs defaultValue="account">
  
  **Account**
Account settings.
  **Password**
Password settings.
</Tabs>
```

## Examples [#examples]

### Pill [#pill]

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs className="w-80 max-w-full items-center" defaultValue="overview">
      <TabsList variant="pill">
        <TabsTab value="overview">Overview</TabsTab>
        <TabsTab value="analytics">Analytics</TabsTab>
        <TabsTab value="reports">Reports</TabsTab>
      </TabsList>
      <TabsPanel className="min-h-14 pt-2 text-center" value="overview">
        <p className="text-muted-foreground text-sm">
          Summary of workspace activity and metrics.
        </p>
      
      <TabsPanel className="min-h-14 pt-2 text-center" value="analytics">
        <p className="text-muted-foreground text-sm">
          Traffic trends, funnels, and retention.
        </p>
      
      <TabsPanel className="min-h-14 pt-2 text-center" value="reports">
        <p className="text-muted-foreground text-sm">
          Monthly exports and scheduled summaries.
        </p>
      
    </Tabs>
  );
}
```

### Underline [#underline]

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs className="w-80 max-w-full items-center" defaultValue="general">
      <TabsList variant="underline">
        <TabsTab value="general">General</TabsTab>
        <TabsTab value="billing">Billing</TabsTab>
        <TabsTab value="team">Team</TabsTab>
      </TabsList>
      <TabsPanel className="min-h-14 pt-3 text-center" value="general">
        <p className="text-muted-foreground text-sm">
          Update workspace name, logo, and locale.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="billing">
        <p className="text-muted-foreground text-sm">
          View invoices, cards, and usage limits.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="team">
        <p className="text-muted-foreground text-sm">
          Manage roles, access, and invitations.
        </p>
      
    </Tabs>
  );
}
```

### Primary Stacked [#primary-stacked]

```tsx
import { BookmarkIcon, CompassIcon, FlameIcon } from "lucide-react";
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs className="w-80 max-w-full" defaultValue="explore">
      <TabsList stacked variant="primary">
        <TabsTab value="explore">
          <CompassIcon />
          Explore
        </TabsTab>
        <TabsTab value="trending">
          <FlameIcon />
          Trending
        </TabsTab>
        <TabsTab value="saved">
          <BookmarkIcon />
          Saved
        </TabsTab>
      </TabsList>
      <TabsPanel className="min-h-14 pt-3 text-center" value="explore">
        <p className="text-muted-foreground text-sm">
          Curated collections and new releases.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="trending">
        <p className="text-muted-foreground text-sm">
          Most popular picks across the community.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="saved">
        <p className="text-muted-foreground text-sm">
          Bookmarked items from your recent activity.
        </p>
      
    </Tabs>
  );
}
```

### Dot [#dot]

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs className="w-72 max-w-full" defaultValue="all">
      <TabsList variant="dot">
        <TabsTab value="all">All</TabsTab>
        <TabsTab value="unread">Unread</TabsTab>
        <TabsTab value="archived">Archived</TabsTab>
      </TabsList>
      <TabsPanel className="min-h-14 pt-3 text-center" value="all">
        <p className="text-muted-foreground text-sm">
          Showing all 24 conversations.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="unread">
        <p className="text-muted-foreground text-sm">
          3 unread messages waiting for review.
        </p>
      
      <TabsPanel className="min-h-14 pt-3 text-center" value="archived">
        <p className="text-muted-foreground text-sm">
          Archived threads kept for 90 days.
        </p>
      
    </Tabs>
  );
}
```

### Circular [#circular]

```tsx
import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
import { Tabs, TabsList, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs defaultValue="system">
      <TabsList variant="circular">
        <TabsTab aria-label="Light theme" value="light">
          <SunIcon />
        </TabsTab>
        <TabsTab aria-label="Dark theme" value="dark">
          <MoonIcon />
        </TabsTab>
        <TabsTab aria-label="System theme" value="system">
          <MonitorIcon />
        </TabsTab>
      </TabsList>
    </Tabs>
  );
}
```

### Vertical [#vertical]

```tsx
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/ui/tabs";

export default function Particle() {
  return (
    <Tabs
      className="w-80 max-w-full"
      defaultValue="profile"
      orientation="vertical"
    >
      <TabsList variant="underline">
        <TabsTab value="profile">Profile</TabsTab>
        <TabsTab value="security">Security</TabsTab>
        <TabsTab value="api">API Keys</TabsTab>
      </TabsList>
      <TabsPanel className="py-1" value="profile">
        <p className="text-muted-foreground text-sm">
          Edit your display name, avatar, and public bio.
        </p>
      
      <TabsPanel className="py-1" value="security">
        <p className="text-muted-foreground text-sm">
          Configure two-factor auth and recovery codes.
        </p>
      
      <TabsPanel className="py-1" value="api">
        <p className="text-muted-foreground text-sm">
          Create and revoke personal access tokens.
        </p>
      
    </Tabs>
  );
}
```

## API Reference [#api-reference]

### Tabs [#tabs]

Wraps Base UI `Tabs.Root`. Manages active tab state and layout orientation.

| Prop            | Type                         | Default        | Description                                |
| --------------- | ---------------------------- | -------------- | ------------------------------------------ |
| `value`         | `unknown`                    | -              | Controlled active tab value                |
| `defaultValue`  | `unknown`                    | -              | Initial uncontrolled active tab value      |
| `onValueChange` | `(value: unknown) => void`   | -              | Called when the active tab changes         |
| `orientation`   | `"horizontal" \| "vertical"` | `"horizontal"` | Layout direction and arrow-key navigation  |
| `className`     | `string`                     | -              | Additional CSS classes                     |
| `...props`      | Base UI Tabs Root props      | -              | All other Tabs Root props are supported    |

### TabsList [#tabslist]

Container for `TabsTab` triggers with a built-in spring-animated `Tabs.Indicator`.

| Prop        | Type                                                                                                      | Default     | Description                                       |
| ----------- | --------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------- |
| `variant`   | `"default" \| "pill" \| "outline" \| "circular" \| "primary" \| "secondary" \| "underline" \| "clean" \| "dot"` | `"default"` | Indicator and surface style preset                |
| `stacked`   | `boolean`                                                                                                 | `false`     | Stacks icon above label vertically inside each tab |
| `className` | `string`                                                                                                  | -           | Additional CSS classes                            |
| `...props`  | Base UI Tabs List props                                                                                   | -           | All standard tabs list props                      |

### TabsTab / TabsTrigger [#tabstab--tabstrigger]

Interactive tab button associated with a `TabsPanel` via `value`.

| Prop        | Type                    | Default | Description                           |
| ----------- | ----------------------- | ------- | ------------------------------------- |
| `value`     | `unknown`               | -       | Identifier matching a `TabsPanel`     |
| `disabled`  | `boolean`               | `false` | Disables interaction and dims the tab |
| `className` | `string`                | -       | Additional CSS classes                |
| `...props`  | Base UI Tabs Tab props  | -       | All standard tab attributes           |

### TabsPanel / TabsContent [#tabspanel--tabscontent]

Content panel displayed when its `value` matches the active tab.

| Prop        | Type                     | Description                    |
| ----------- | ------------------------ | ------------------------------ |
| `value`     | `unknown`                | Identifier matching a `TabsTab` |
| `className` | `string`                 | Additional CSS classes         |
| `...props`  | Base UI Tabs Panel props | All standard panel attributes  |
