Documentation

Tabs

Composable tabs with animated pill and underline styles, keyboard navigation, and custom content.

Pill

High-level summary.

Underline

All issues in this project.

Installation

Initialize your project once, then add Tabs. The CLI copies the source and installs its dependencies.

bunx knot-ui initbunx knot-ui add tabs

Usage

tsxapp/page.tsx
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";

export default function Example() {
  return (
    <Tabs defaultValue="overview" variant="pill">
      <TabsList aria-label="Account sections">
        <TabsTrigger value="overview">Overview</TabsTrigger>
        <TabsTrigger value="activity">Activity</TabsTrigger>
        <TabsTrigger value="settings">Settings</TabsTrigger>
      </TabsList>
      <TabsContent value="overview" className="text-sm text-muted-foreground">
        High-level summary.
      </TabsContent>
      <TabsContent value="activity" className="text-sm text-muted-foreground">
        Recent events.
      </TabsContent>
      <TabsContent value="settings" className="text-sm text-muted-foreground">
        Preferences.
      </TabsContent>
    </Tabs>
  );
}

Each trigger and its content share the same value. Start on an enabled tab with defaultValue, or control selection with value and onValueChange.

Customization

Every part accepts className and native element properties. Use variant="underline" for an underline indicator, disable individual triggers with disabled, or use orientation="vertical" for a vertical tab list.

Arrow keys move between enabled tabs. Home and End select the first and last enabled tabs. Inactive panels stay mounted so form inputs and other local state are preserved.

tsxapp/account.tsx
"use client";

import { useState } from "react";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";

export default function Example() {
  const [tab, setTab] = useState("overview");

  return (
    <Tabs value={tab} onValueChange={setTab} variant="underline">
      <TabsList aria-label="Account sections">
        <TabsTrigger value="overview">Overview</TabsTrigger>
        <TabsTrigger value="settings">Settings</TabsTrigger>
        <TabsTrigger value="billing" disabled>Billing</TabsTrigger>
      </TabsList>
      <TabsContent value="overview">High-level summary.</TabsContent>
      <TabsContent value="settings">Preferences.</TabsContent>
      <TabsContent value="billing">Coming soon.</TabsContent>
    </Tabs>
  );
}

Tabs props

Component properties
PropTypeDefaultDescription
defaultValuestring—The initial tab. Required when value is not provided.
valuestring—The selected tab when controlling state externally.
onValueChange(value: string) => void—Called when a different tab is selected.
variant"pill" | "underline""pill"The list and indicator style.
orientation"horizontal" | "vertical""horizontal"The list direction and arrow key behavior.
classNamestring—Tailwind classes for the root. Each child part also accepts className.

TabsList

Wrap triggers in TabsList. Give it an aria-label or aria-labelledby so the tab group has an accessible name. Native div properties and refs are supported.

TabsTrigger

Component properties
PropTypeDefaultDescription
valuestringRequiredA unique value matching a TabsContent panel.
disabledbooleanfalsePrevents selection and skips this trigger during keyboard navigation.
classNamestring—Custom spacing, colors, or typography. Use data-state for active styling.

TabsContent

Component properties
PropTypeDefaultDescription
valuestringRequiredThe value of the trigger that shows this panel.
childrenReactNode—Any JSX content, including forms and other components.
classNamestring—Classes for the panel. Inactive panels remain hidden.