Installation
Run the following command:
Update your imports:import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
Usage
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
export default function Home() {
return (
<Tabs defaultValue="account" className="w-[400px]">
<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>
);
}
Props
Tabs
Prop | Type | Default | Description |
---|---|---|---|
variant | default | underline | pill | rounded | folder | default | Style variant of the tabs |
Radix UI Props
The Tabs components are built on Radix UI's Tabs primitive and support all their props:
Tabs Root Props
defaultValue
: string - The value of the tab that should be active when initially renderedvalue
: string - The controlled value of the currently active tabonValueChange
: (value: string) => void - Event handler called when the value changesorientation
: 'horizontal' | 'vertical' - The orientation of the tabsdir
: 'ltr' | 'rtl' - The reading directionactivationMode
: 'automatic' | 'manual' - Whether to auto-activate tabs on focus
TabsList Props
- Standard Radix UI TabsList props
TabsTrigger Props
value
: string (required) - A unique value for the tabdisabled
: boolean - When true, prevents the user from interacting with the tab
TabsContent Props
value
: string (required) - A unique value that associates the content with a triggerforceMount
: boolean - Force mounting when more control is needed
Additionally, all components support relevant HTML attributes and event handlers appropriate to their element type.