Tabs
featurefrom shadcn/ui Essentials
Tabs
AI Usage Rules
Use Tabs to organize content into switchable panels. Keep tab labels short (1-2 words). The defaultValue should match one of the tab values.
Code Template
"use client"
import * as React from "react"
import { Tabs as TabsPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Tabs({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>) {
return <TabsPrimitive.Root data-slot="tabs" className={cn("flex gap-2 flex-col", className)} {...props} />
}
function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>) {
return <TabsPrimitive.List data-slot="tabs-list" className={cn("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-[3px] text-muted-foreground", className)} {...props} />
}
function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
return <TabsPrimitive.Trigger data-slot="tabs-trigger" className={cn("inline-flex items-center justify-center rounded-md px-2 py-1 text-sm font-medium transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm", className)} {...props} />
}
function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>) {
return <TabsPrimitive.Content data-slot="tabs-content" className={cn("flex-1 outline-none", className)} {...props} />
}
export { Tabs, TabsList, TabsTrigger, TabsContent }Props Schema
| Property | Type | Default | Description |
|---|---|---|---|
| tabs | array | — | |
| defaultValue | string | — |
View raw JSON schema
{
"type": "object",
"properties": {
"tabs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
},
"content": {
"type": "string"
}
}
}
},
"defaultValue": {
"type": "string"
}
}
}