Tabs
Organize content into tabbed sections with smooth transitions and keyboard navigation support.
Basic Usage
Project Overview
This tab contains general information about the project, including its goals, timeline, and key stakeholders. You can provide a high-level summary here.
import { Tabs, Tab } from '@akitectio/aki-ui'
function BasicTabs() {
return (
<Tabs>
<Tab label="Overview">
<div className="p-4">
<h3>Project Overview</h3>
<p>General information about the project...</p>
</div>
</Tab>
<Tab label="Details">
<div className="p-4">
<h3>Project Details</h3>
<p>Detailed information...</p>
</div>
</Tab>
<Tab label="Settings">
<div className="p-4">
<h3>Project Settings</h3>
<p>Configuration options...</p>
</div>
</Tab>
</Tabs>
)
}
Controlled Tabs
Dashboard
Current active tab: 0
📊 Welcome to the dashboard! Here you can view analytics and key metrics.
import { useState } from 'react'
import { Tabs, Tab } from '@akitectio/aki-ui'
function ControlledTabs() {
const [activeTab, setActiveTab] = useState(0)
return (
<div>
<div className="flex gap-2 mb-4">
<button onClick={() => setActiveTab(0)}>
Go to First Tab
</button>
<button onClick={() => setActiveTab(2)}>
Go to Last Tab
</button>
</div>
<Tabs activeIndex={activeTab} onChange={setActiveTab}>
<Tab label="Dashboard">
<div>Dashboard content...</div>
</Tab>
<Tab label="Analytics">
<div>Analytics content...</div>
</Tab>
<Tab label="Reports">
<div>Reports content...</div>
</Tab>
</Tabs>
</div>
)
}
Tabs with Icons
Home
Welcome to the home page! This is your starting point for navigating through the application.
<Tabs>
<Tab label="Home" icon={<span>🏠</span>}>
<div className="p-4">
<h3>Home</h3>
<p>Welcome to the home page...</p>
</div>
</Tab>
<Tab label="Profile" icon={<span>👤</span>}>
<div className="p-4">
<h3>User Profile</h3>
<p>Manage your personal information...</p>
</div>
</Tab>
<Tab label="Messages" icon={<span>💬</span>}>
<div className="p-4">
<h3>Messages</h3>
<p>View and manage your messages...</p>
</div>
</Tab>
<Tab label="Settings" icon={<span>⚙️</span>}>
<div className="p-4">
<h3>Settings</h3>
<p>Configure application settings...</p>
</div>
</Tab>
</Tabs>
Disabled Tabs
Available Feature
This feature is currently available and fully functional.
<Tabs>
<Tab label="Available">
<div>This feature is available...</div>
</Tab>
<Tab label="Coming Soon" disabled>
<div>This feature is coming soon...</div>
</Tab>
<Tab label="Beta" icon={<span>⚠️</span>}>
<div>This feature is in beta...</div>
</Tab>
<Tab label="Premium" disabled>
<div>Premium feature...</div>
</Tab>
</Tabs>
Tab Orientations
Horizontal (Default)
Horizontal tab content 1
Vertical
Dashboard
Vertical dashboard content with more space.
{/* Horizontal Tabs (Default) */}
<Tabs orientation="horizontal">
<Tab label="Tab 1">Content 1</Tab>
<Tab label="Tab 2">Content 2</Tab>
<Tab label="Tab 3">Content 3</Tab>
</Tabs>
{/* Vertical Tabs */}
<Tabs orientation="vertical">
<Tab label="Dashboard">Dashboard content</Tab>
<Tab label="Analytics">Analytics content</Tab>
<Tab label="Settings">Settings content</Tab>
</Tabs>
API Reference
Tabs Props
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactElement<TabProps>[] | - | The tabs to be rendered |
defaultIndex | number | 0 | The index of the initially active tab |
activeIndex | number | - | The currently active tab index (controlled) |
onChange | (index: number) => void | - | Called when the active tab changes |
orientation | 'horizontal' | 'vertical' | 'horizontal' | The orientation of the tabs |
variant | 'default' | 'bordered' | 'pills' | 'default' | The visual style of the tabs |
size | 'sm' | 'md' | 'lg' | 'md' | The size of the tabs |
Tab Props
Prop | Type | Default | Description |
---|---|---|---|
label | React.ReactNode | - | The tab's label |
children | React.ReactNode | - | The tab's content |
disabled | boolean | false | Whether the tab is disabled |
icon | React.ReactNode | - | Custom icon to display before the label |
id | string | - | ID for the tab |
Accessibility
- ✅ Full keyboard navigation support
- ✅ Screen reader compatible with proper ARIA attributes
- ✅ Focus management within tab panels
- ✅ Proper tab list and tab panel relationships
- ✅ High contrast mode support
Keyboard Navigation
- Arrow keys - Navigate between tabs
- Home - Go to first tab
- End - Go to last tab
- Enter/Space - Activate focused tab
- Tab - Move focus to tab panel content
ARIA Attributes
role="tablist"
- Identifies the tab containerrole="tab"
- Identifies each tab elementrole="tabpanel"
- Identifies each tab panelaria-selected
- Indicates which tab is selectedaria-controls
- Links tabs to their panelsaria-labelledby
- Links panels to their tabs
Best Practices
✅ Do
- Use clear and concise tab labels
- Keep the number of tabs manageable (typically 3-7)
- Group related content logically
- Use icons to help users identify content quickly
- Provide default content for the first tab
- Use consistent content structure across tabs
❌ Don't
- Use tabs for sequential processes (use steps instead)
- Nest tabs within tabs
- Use tabs when content needs to be compared side-by-side
- Make tab labels too long or ambiguous
- Use disabled tabs without clear reasons
- Change tab content dynamically in confusing ways
Common Use Cases
📊 Dashboard Sections
Organize different views of data and analytics
- Overview, Analytics, Reports, Settings
- Different time periods or data sources
- Various chart types and visualizations
👤 User Profile
Separate different aspects of user information
- Personal Info, Account Settings, Privacy
- Activity History, Preferences, Notifications
- Security, Billing, Connected Apps
📝 Form Sections
Break long forms into manageable sections
- Basic Info, Contact Details, Preferences
- Step-by-step form completion
- Optional and required information
📖 Documentation
Organize different types of documentation
- API Reference, Guides, Examples
- Getting Started, Advanced Topics, FAQ
- Different programming languages or frameworks