Dashboard Overview
Get insights into your application performance and usage.
Total Users
12,345
+12% from last month
Active Sessions
1,234
+5% from last week
Application Settings
Configure your application preferences and behavior.
Receive notifications about important events
Billing Information
Manage your subscription and payment details.
Pro Plan
$29/month
Active
);
}
const examples = [
{
title: 'Profile Settings',
description: 'User profile management with multiple settings sections',
component: () => {
return (
Profile Settings
Manage your profile information and preferences
Profile
Security
Notifications
Preferences
Add an extra layer of security to your account
Receive notifications via email
Receive push notifications on your devices
Receive updates about new features and promotions
Use dark theme across the application
);
},
},
{
title: 'Project Documentation',
description: 'Vertical tabs for navigation with different content sections',
component: () => {
return (
README
API Docs
Examples
Changelog
Project README
Get started with this project in minutes
Installation
npm install my-awesome-package
Quick Start
Import the package and start building amazing things
with just a few lines of code.
API Reference
Complete API documentation and method references
Methods
getData()
Fetches data from the API endpoint
updateData(data)
Updates existing data with new values
Code Examples
Real-world examples and use cases
Basic Usage
{`import { MyComponent } from 'my-package';
function App() {
return ;
}`}
Changelog
Recent updates and version history
v2.1.0
2024-01-15
Added new data visualization components
v2.0.0
2024-01-01
Major version with breaking changes
);
},
},
{
title: 'Content Management',
description: 'Pills variant tabs for content creation and management',
component: () => {
const [activeTab, setActiveTab] = useState('write');
return (
Content Editor
Create and manage your content with our powerful editor
Write
Preview
Settings
Publish
Article Preview
Your article content will appear here as it will be
displayed to readers. This preview shows you exactly how
your formatting and styling will look.
You can switch back to the Write tab to make changes, or
proceed to Settings to configure publication options.
Let readers comment on this article
Show this article prominently on the homepage
Ready to Publish
Review your article details before publishing. Once
published, your article will be visible to all readers.
Status:Draft
Word Count:245 words
Estimated Read Time:
1 minute
);
},
},
{
title: 'Dashboard Analytics',
description: 'Underline variant tabs for data visualization sections',
component: () => {
return (
Analytics Dashboard
Track your application's performance and user engagement
Overview
Users
Revenue
Reports
Total Revenue
$45,231
+20.1% from last month
Active Users
2,350
+10.5% from last month
New Signups
573
+15.3% from last month
Conversion Rate
12.5%
+2.4% from last month
Performance Trends
Chart visualization would go here
User Growth
User growth chart
User Demographics
Demographics breakdown
Revenue Analytics
Revenue charts and analysis
Monthly Report
January 2024 Performance Summary
Custom Reports
Generate custom reports for specific metrics
);
},
},
];
const apiReference = {
title: 'Tabs API Reference',
description: 'Complete API documentation for the Tabs component family.',
props: [
{
name: 'defaultValue',
type: 'string',
description:
'The value of the tab that should be active when initially rendered.',
},
{
name: 'value',
type: 'string',
description: 'The controlled value of the tab to activate.',
},
{
name: 'onValueChange',
type: '(value: string) => void',
description: 'Event handler called when the value changes.',
},
{
name: 'orientation',
type: '"horizontal" | "vertical"',
default: '"horizontal"',
description: 'The orientation of the component.',
},
{
name: 'dir',
type: '"ltr" | "rtl"',
description: 'The reading direction of tabs when applicable.',
},
{
name: 'activationMode',
type: '"automatic" | "manual"',
default: '"automatic"',
description: 'Whether a tab is activated automatically or manually.',
},
{
name: 'className',
type: 'string',
description: 'Additional CSS classes for the tabs container.',
},
{
name: '...props',
type: 'React.ComponentPropsWithoutRef',
description:
'All props from Radix UI Tabs.Root component including asChild, id, etc.',
},
],
examples: [
{
title: 'Basic Usage',
code: `import { Tabs, TabsContent, TabsList, TabsTrigger } from '@kit/ui/tabs';
Tab OneTab TwoContent for tab oneContent for tab two`,
},
{
title: 'Controlled Tabs',
code: `const [activeTab, setActiveTab] = useState('home');
HomeAboutHome contentAbout content`,
},
{
title: 'Vertical Orientation',
code: `ProfileSettings
Profile contentSettings content
`,
},
{
title: 'Full Width Tabs',
code: `OverviewAnalyticsReports
{/* Tab content */}
`,
},
],
};
const usageGuidelines = {
title: 'Tabs Usage Guidelines',
description:
'Best practices for implementing tabs that provide excellent user experience.',
guidelines: [
{
title: 'When to Use Tabs',
items: [
"Organizing related content that doesn't need to be viewed simultaneously",
'Breaking down complex forms or settings into manageable sections',
'Switching between different views of the same data (table vs. chart)',
'Providing different content formats (edit vs. preview)',
'Organizing dashboard sections or feature categories',
],
},
{
title: 'Tab Organization',
items: [
'Order tabs logically: most important or frequently used first',
'Keep tab labels short and descriptive (1-2 words when possible)',
'Use consistent terminology and avoid jargon',
'Limit the number of tabs (5-7 maximum for horizontal, more acceptable for vertical)',
'Group related functionality within the same tab',
],
},
{
title: 'Visual Design',
items: [
'Use icons with labels to improve recognition and scannability',
'Maintain consistent styling across all tabs in an interface',
'Ensure clear visual distinction between active and inactive states',
'Consider the container size when choosing orientation',
'Use appropriate spacing and padding for touch targets',
],
},
{
title: 'Content Strategy',
items: [
"Make each tab's content independent and self-contained",
'Provide clear headings and descriptions within tab content',
'Consider loading states for tabs with dynamic content',
'Maintain context when users switch between tabs',
'Use consistent content structure across similar tabs',
],
},
{
title: 'Accessibility',
items: [
'Tabs automatically include proper ARIA attributes and keyboard navigation',
'Use arrow keys for tab navigation and Enter/Space to activate',
'Provide meaningful labels that describe the content purpose',
'Ensure sufficient color contrast for all tab states',
'Consider users who rely on screen readers for content announcement',
],
},
{
title: 'Responsive Considerations',
items: [
'Consider horizontal scrolling for many tabs on smaller screens',
'Switch to vertical orientation on mobile when appropriate',
'Ensure touch targets are large enough for mobile interaction',
'Use full-width tabs on narrow screens to maximize usability',
'Consider collapsing to an accordion pattern on very small screens',
],
},
],
};
export default function TabsStory() {
const [controls, setControls] = useState({
defaultValue: 'overview',
orientation: 'horizontal' as 'horizontal' | 'vertical',
variant: 'default' as 'default' | 'pills' | 'underline',
size: 'default' as 'sm' | 'default' | 'lg',
fullWidth: false,
className: '',
});
const generateCode = () => {
const tabsListClasses = [
variantClasses[controls.variant],
sizeClasses[controls.size],
controls.fullWidth && controls.orientation === 'horizontal'
? 'w-full'
: '',
controls.orientation === 'vertical' ? 'flex-col h-fit' : '',
]
.filter(Boolean)
.join(' ');
const tabsClassName =
controls.orientation === 'vertical' ? 'flex gap-4' : '';
const contentClassName =
controls.orientation === 'vertical' ? 'flex-1' : 'mt-4';
const triggerClassName = controls.fullWidth ? 'flex-1' : '';
const tabsPropsString = generatePropsString({
defaultValue: controls.defaultValue,
orientation:
controls.orientation !== 'horizontal'
? controls.orientation
: undefined,
className:
[tabsClassName, controls.className].filter(Boolean).join(' ') ||
undefined,
});
const tabsListPropsString = generatePropsString({
className: tabsListClasses || undefined,
});
const tabsTriggerPropsString = generatePropsString({
className: triggerClassName || undefined,
});
const importStatement = generateImportStatement(
['Tabs', 'TabsContent', 'TabsList', 'TabsTrigger'],
'@kit/ui/tabs',
);
const exampleCode = `
Overview
Settings
Billing
Overview content goes here
Settings content goes here
Billing content goes here