Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Message
- Message Scroller
- Native Select
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
- Typography
AI Elements
Get Started
@shadcn/react
@shadcn/helpers
Utilities
Overview
Analytics
Reports
Settings
Overview
View your key metrics and recent project activity. Track progress across all your active projects.
You have 12 active projects and 3 pending tasks.
import {
Card,
CardContent,import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ui/tabs"
export function TabsDemo() {
return (
<Tabs defaultSelectedKey="overview" className="w-[400px]">
<TabsList>
<TabsTrigger id="overview">Overview</TabsTrigger>
<TabsTrigger id="analytics">Analytics</TabsTrigger>
<TabsTrigger id="reports">Reports</TabsTrigger>
<TabsTrigger id="settings">Settings</TabsTrigger>
</TabsList>
<TabsContent id="overview">
<Card>
<CardHeader>
<CardTitle>Overview</CardTitle>
<CardDescription>
View your key metrics and recent project activity. Track progress
across all your active projects.
</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
You have 12 active projects and 3 pending tasks.
</CardContent>
</Card>
</TabsContent>
<TabsContent id="analytics">
<Card>
<CardHeader>
<CardTitle>Analytics</CardTitle>
<CardDescription>
Track performance and user engagement metrics. Monitor trends and
identify growth opportunities.
</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
Page views are up 25% compared to last month.
</CardContent>
</Card>
</TabsContent>
<TabsContent id="reports">
<Card>
<CardHeader>
<CardTitle>Reports</CardTitle>
<CardDescription>
Generate and download your detailed reports. Export data in
multiple formats for analysis.
</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
You have 5 reports ready and available to export.
</CardContent>
</Card>
</TabsContent>
<TabsContent id="settings">
<Card>
<CardHeader>
<CardTitle>Settings</CardTitle>
<CardDescription>
Manage your account preferences and options. Customize your
experience to fit your needs.
</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
Configure notifications, security, and themes.
</CardContent>
</Card>
</TabsContent>
</Tabs>
)
}
Installation#
pnpm dlx shadcn@latest add tabs
Install the following dependencies:
pnpm add react-aria-components
Copy and paste the following code into your project.
"use client"
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import {
TabList as TabListPrimitive,
TabPanel as TabPanelPrimitive,
Tab as TabPrimitive,
Tabs as TabsPrimitive,
} from "react-aria-components"
function Tabs({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive>) {
return (
<TabsPrimitive
data-slot="tabs"
className={cn(
"group/tabs flex gap-2 data-horizontal:flex-col",
className
)}
{...props}
/>
)
}
const tabsListVariants = cva(
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
{
variants: {
variant: {
default: "bg-muted",
line: "gap-1 bg-transparent",
},
},
defaultVariants: {
variant: "default",
},
}
)
function TabsList({
className,
variant = "default",
...props
}: React.ComponentProps<typeof TabListPrimitive> &
VariantProps<typeof tabsListVariants>) {
return (
<TabListPrimitive
data-slot="tabs-list"
data-variant={variant}
className={cn(tabsListVariants({ variant }), className)}
{...props}
/>
)
}
function TabsTrigger({
className,
...props
}: React.ComponentProps<typeof TabPrimitive>) {
return (
<TabPrimitive
data-slot="tabs-trigger"
className={cn(
"relative inline-flex h-[calc(100%-1px)] flex-1 cursor-default items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-selected:shadow-sm group-data-[variant=line]/tabs-list:data-selected:shadow-none group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-selected:bg-transparent dark:group-data-[variant=line]/tabs-list:data-selected:border-transparent dark:group-data-[variant=line]/tabs-list:data-selected:bg-transparent",
"data-selected:bg-background data-selected:text-foreground dark:data-selected:border-input dark:data-selected:bg-input/30 dark:data-selected:text-foreground",
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-selected:after:opacity-100",
className
)}
{...props}
/>
)
}
function TabsContent({
className,
...props
}: React.ComponentProps<typeof TabPanelPrimitive>) {
return (
<TabPanelPrimitive
data-slot="tabs-content"
className={cn("flex-1 text-sm outline-none", className)}
{...props}
/>
)
}
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
Update the import paths to match your project setup.
Usage#
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"<Tabs defaultSelectedKey="account" className="w-[400px]">
<TabsList>
<TabsTrigger id="account">Account</TabsTrigger>
<TabsTrigger id="password">Password</TabsTrigger>
</TabsList>
<TabsContent id="account">Make changes to your account here.</TabsContent>
<TabsContent id="password">Change your password here.</TabsContent>
</Tabs>Composition#
Use the following composition to build Tabs:
Tabs
├── TabsList
│ ├── TabsTrigger
│ └── TabsTrigger
├── TabsContent
└── TabsContentLine#
Use the variant="line" prop on TabsList for a line style.
Overview
Analytics
Reports
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsLine() {import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsLine() {
return (
<Tabs defaultSelectedKey="overview">
<TabsList variant="line">
<TabsTrigger id="overview">Overview</TabsTrigger>
<TabsTrigger id="analytics">Analytics</TabsTrigger>
<TabsTrigger id="reports">Reports</TabsTrigger>
</TabsList>
</Tabs>
)
}
Vertical#
Use orientation="vertical" for vertical tabs.
Account
Password
Notifications
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsVertical() {import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsVertical() {
return (
<Tabs defaultSelectedKey="account" orientation="vertical">
<TabsList>
<TabsTrigger id="account">Account</TabsTrigger>
<TabsTrigger id="password">Password</TabsTrigger>
<TabsTrigger id="notifications">Notifications</TabsTrigger>
</TabsList>
</Tabs>
)
}
Disabled#
Home
Disabled
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsDisabled() {import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsDisabled() {
return (
<Tabs defaultSelectedKey="home">
<TabsList>
<TabsTrigger id="home">Home</TabsTrigger>
<TabsTrigger id="settings" isDisabled>
Disabled
</TabsTrigger>
</TabsList>
</Tabs>
)
}
Icons#
Preview
Code
import { AppWindowIcon, CodeIcon } from "lucide-react"
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"import { AppWindowIcon, CodeIcon } from "lucide-react"
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
export function TabsIcons() {
return (
<Tabs defaultSelectedKey="preview">
<TabsList>
<TabsTrigger id="preview">
<AppWindowIcon />
Preview
</TabsTrigger>
<TabsTrigger id="code">
<CodeIcon />
Code
</TabsTrigger>
</TabsList>
</Tabs>
)
}
RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
نظرة عامة
التحليلات
التقارير
الإعدادات
نظرة عامة
عرض مقاييسك الرئيسية وأنشطة المشروع الأخيرة. تتبع التقدم عبر جميع مشاريعك النشطة.
لديك ١٢ مشروعًا نشطًا و٣ مهام معلقة.
"use client"
import * as React from "react"// You will notice this example uses dir and data-lang attributes. // This is because this site is not RTL by default. // In your application, you won't need these.// See the RTL guide for more information.
"use client"
import * as React from "react"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/components/ui/tabs"
const translations: Translations = {
en: {
dir: "ltr",
values: {
overview: "Overview",
analytics: "Analytics",
reports: "Reports",
settings: "Settings",
overviewTitle: "Overview",
overviewDesc:
"View your key metrics and recent project activity. Track progress across all your active projects.",
overviewContent: "You have 12 active projects and 3 pending tasks.",
analyticsTitle: "Analytics",
analyticsDesc:
"Track performance and user engagement metrics. Monitor trends and identify growth opportunities.",
analyticsContent: "Page views are up 25% compared to last month.",
reportsTitle: "Reports",
reportsDesc:
"Generate and download your detailed reports. Export data in multiple formats for analysis.",
reportsContent: "You have 5 reports ready and available to export.",
settingsTitle: "Settings",
settingsDesc:
"Manage your account preferences and options. Customize your experience to fit your needs.",
settingsContent: "Configure notifications, security, and themes.",
},
},
ar: {
dir: "rtl",
values: {
overview: "نظرة عامة",
analytics: "التحليلات",
reports: "التقارير",
settings: "الإعدادات",
overviewTitle: "نظرة عامة",
overviewDesc:
"عرض مقاييسك الرئيسية وأنشطة المشروع الأخيرة. تتبع التقدم عبر جميع مشاريعك النشطة.",
overviewContent: "لديك ١٢ مشروعًا نشطًا و٣ مهام معلقة.",
analyticsTitle: "التحليلات",
analyticsDesc:
"تتبع مقاييس الأداء ومشاركة المستخدمين. راقب الاتجاهات وحدد فرص النمو.",
analyticsContent: "زادت مشاهدات الصفحة بنسبة ٢٥٪ مقارنة بالشهر الماضي.",
reportsTitle: "التقارير",
reportsDesc:
"إنشاء وتنزيل تقاريرك التفصيلية. تصدير البيانات بتنسيقات متعددة للتحليل.",
reportsContent: "لديك ٥ تقارير جاهزة ومتاحة للتصدير.",
settingsTitle: "الإعدادات",
settingsDesc:
"إدارة تفضيلات حسابك وخياراته. تخصيص تجربتك لتناسب احتياجاتك.",
settingsContent: "تكوين الإشعارات والأمان والسمات.",
},
},
he: {
dir: "rtl",
values: {
overview: "סקירה כללית",
analytics: "אנליטיקה",
reports: "דוחות",
settings: "הגדרות",
overviewTitle: "סקירה כללית",
overviewDesc:
"הצג את המדדים העיקריים שלך ופעילות הפרויקט האחרונה. עקוב אחר התקדמות בכל הפרויקטים הפעילים שלך.",
overviewContent: "יש לך 12 פרויקטים פעילים ו-3 משימות ממתינות.",
analyticsTitle: "אנליטיקה",
analyticsDesc:
"עקוב אחר ביצועים ומדדי מעורבות משתמשים. עקוב אחר מגמות וזהה הזדמנויות צמיחה.",
analyticsContent: "צפיות בדף עלו ב-25% בהשוואה לחודש שעבר.",
reportsTitle: "דוחות",
reportsDesc:
"צור והורד את הדוחות המפורטים שלך. ייצא נתונים בפורמטים מרובים לניתוח.",
reportsContent: "יש לך 5 דוחות מוכנים וזמינים לייצוא.",
settingsTitle: "הגדרות",
settingsDesc:
"נהל את העדפות החשבון והאפשרויות שלך. התאם אישית את החוויה שלך כך שתתאים לצרכים שלך.",
settingsContent: "הגדר התראות, אבטחה וערכות נושא.",
},
},
}
export function TabsRtl() {
const { dir, t } = useTranslation(translations, "ar")
return (
<Tabs defaultSelectedKey="overview" className="w-full max-w-sm" dir={dir}>
<TabsList dir={dir}>
<TabsTrigger id="overview">{t.overview}</TabsTrigger>
<TabsTrigger id="analytics">{t.analytics}</TabsTrigger>
<TabsTrigger id="reports">{t.reports}</TabsTrigger>
<TabsTrigger id="settings">{t.settings}</TabsTrigger>
</TabsList>
<TabsContent id="overview">
<Card dir={dir}>
<CardHeader>
<CardTitle>{t.overviewTitle}</CardTitle>
<CardDescription>{t.overviewDesc}</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
{t.overviewContent}
</CardContent>
</Card>
</TabsContent>
<TabsContent id="analytics">
<Card dir={dir}>
<CardHeader>
<CardTitle>{t.analyticsTitle}</CardTitle>
<CardDescription>{t.analyticsDesc}</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
{t.analyticsContent}
</CardContent>
</Card>
</TabsContent>
<TabsContent id="reports">
<Card dir={dir}>
<CardHeader>
<CardTitle>{t.reportsTitle}</CardTitle>
<CardDescription>{t.reportsDesc}</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
{t.reportsContent}
</CardContent>
</Card>
</TabsContent>
<TabsContent id="settings">
<Card dir={dir}>
<CardHeader>
<CardTitle>{t.settingsTitle}</CardTitle>
<CardDescription>{t.settingsDesc}</CardDescription>
</CardHeader>
<CardContent className="text-sm text-muted-foreground">
{t.settingsContent}
</CardContent>
</Card>
</TabsContent>
</Tabs>
)
}
API Reference#
See the React Aria Tabs documentation.
Deploy your shadcn/ui app on Vercel
Trusted by OpenAI, Sonos, Adobe, and more.
Vercel provides tools and infrastructure to deploy apps and features at scale.
Deploy to Vercel