Tabs
React Tabs components are used to organize related content into separate panels that share the same context. They are commonly used in dashboards, settings pages, profile views, and any interface where users need to switch between sections without leaving the page.
This Tabs component is built with React and styled using Tailwind CSS. It supports multiple visual variants, icons, badges, and vertical or horizontal layouts while keeping tab behavior accessible and predictable.
Overview
Get a high-level view of your dashboard metrics and key performance indicators.
Analytics
Deep dive into your data with detailed analytics and insights.
Reports
Generate and view comprehensive reports for your business.
Settings
Configure your preferences and account settings.
Installation
Install the component using the Tailgrids CLI.
npx @tailgrids/cli add tabsAnatomy
Import the tab parts and compose them to build the layout.
import { TabRoot, TabList, TabTrigger, TabContent } from "@/registry/core/tabs";
export default TabsExample = () => (
<TabRoot defaultValue="tab1">
<TabList>
<TabTrigger value="tab1" />
<TabTrigger value="tab2" />
</TabList>
<TabContent value="tab1" />
<TabContent value="tab2" />
</TabRoot>
);Usage
Import the components and use the default variant to create a standard tabbed interface.
import { TabContent, TabList, TabRoot, TabTrigger } from "@/registry/core/tabs";
export default function TabsExample() {
return (
<TabRoot defaultValue="overview">
<TabList>
<TabTrigger value="overview">Overview</TabTrigger>
<TabTrigger value="analytics">Analytics</TabTrigger>
<TabTrigger value="reports">Reports</TabTrigger>
</TabList>
<TabContent value="overview">
<p>Overview content goes here.</p>
</TabContent>
<TabContent value="analytics">
<p>Analytics content goes here.</p>
</TabContent>
<TabContent value="reports">
<p>Reports content goes here.</p>
</TabContent>
</TabRoot>
);
}Note: Only one tab panel is visible at a time. The defaultValue prop sets the initially active tab.
Examples
Variants
Use the variant prop to control the visual style of the tab list. Supported values are default and minimal.
Welcome to your home dashboard. Here you can see recent activities.
Manage your personal information and profile settings here.
Check your inbox for new messages and notifications.
With Icons
You can pass an icon prop to the TabTrigger to display an icon before the tab label.
Access your main dashboard and summary.
View detailed charts and performance metrics.
Download and review your monthly reports.
Adjust your system preferences and configurations.
Note: Icons are automatically sized to 20px (1.25rem).
With Badges
Use the badge prop on TabTrigger to display a notification count or status indicator next to the label.
You have 12 new messages in your inbox.
You have 3 draft messages waiting to be sent.
View history of all messages you have previously sent.
Note: Badges use the Badge component with primary color.
Horizontal Direction
Set the direction prop to horizontal on TabRoot to stack the tab list and content vertically, with tabs arranged horizontally.
Team Management
Manage your team members, roles, and permissions. Add new members or update existing ones.
Team Analytics
View team performance metrics, activity logs, and productivity insights.
Team Settings
Configure team-wide settings, notifications, and integrations.
Note: Horizontal direction is responsive and wraps on small screens. The tab list scrolls horizontally if tabs overflow.
Custom
You can customize the tab appearance using standard Tailwind CSS classes.
Overview
Your performance metrics for this week
Updated the design files for the new project.
Can we reschedule our meeting to tomorrow?
Project deployment was successful!
Account Settings
Manage your account preferences
API Reference
TabRoot
The root container for tabs. Extends div element props.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string | - | Initially active tab (required) |
variant | 'default', 'minimal' | 'default' | Visual style variant |
direction | 'vertical', 'horizontal' | 'vertical' | Layout direction |
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Tab components |
TabList
Container for tab triggers. Extends div element props.
| Prop | Type | Description |
|---|---|---|
className | string | Additional CSS classes |
children | React.ReactNode | TabTrigger components |
TabTrigger
Individual tab button. Extends button element props.
| Prop | Type | Description |
|---|---|---|
value | string | Unique tab identifier (required) |
icon | React.ReactNode | Optional icon before text |
badge | string | number | Optional badge after text |
className | string | Additional CSS classes |
children | React.ReactNode | Tab label content |
| Data Attribute | Values | Description |
|---|---|---|
data-active | "true", "false" | Indicates whether the tab is currently active. |
TabContent
Content panel for each tab. Extends div element props.
| Prop | Type | Description |
|---|---|---|
value | string | Tab identifier matching trigger (required) |
className | string | Additional CSS classes |
children | React.ReactNode | Panel content |
Accessibility
- Uses proper ARIA attributes (
role="tab",role="tabpanel",aria-selected,aria-controls,aria-labelledby) - Keyboard accessible with standard tab navigation
- Active tab is clearly indicated with visual styling
- Content panels are properly associated with their triggers
- Hidden content uses
hiddenattribute for screen readers - Auto-generated unique IDs ensure proper associations