Tabs

An animated tab switcher component with fluid spring layout indicators.

Loading component...

Installation

Install using the CLI:

bash
bunx knot-ui add tabs

Or copy the source code manually from the Code tab above.

Usage

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

export default function Example() {
  return (
    <Tabs defaultValue="account" variant="pill">
      <TabsList>
        <TabsTrigger value="account">Account</TabsTrigger>
        <TabsTrigger value="password">Password</TabsTrigger>
      </TabsList>
      <TabsContent value="account">
        <p>Make changes to your account here.</p>
      </TabsContent>
      <TabsContent value="password">
        <p>Change your password here.</p>
      </TabsContent>
    </Tabs>
  );
}

Props

Tabs

PropTypeDefaultDescription
defaultValuestring""The value of the tab that should be active initially
valuestringundefinedThe controlled value of the active tab
onValueChange(value: string) => voidundefinedCallback fired when the active tab changes
variant"pill" | "segment" | "underline""pill"Visual indicator style variant

TabsTrigger

PropTypeDefaultDescription
valuestringrequiredA unique value identifying the tab
indicatorClassNamestringundefinedCustom styling for the sliding active indicator