Tabs
Tabs organize content into related sections that users can navigate between. The Tab component contains TabItem components that represent individual tab options.
Overview
Tabs provide a way to organize and navigate between related content sections. The Tab component acts as a container for TabItem components, which represent individual tab options. TabItems can be displayed in different states, sizes, and styles to fit various use cases.
All tab styles are built using design tokens, ensuring consistency across themes and hues. Use the interactive playground below to explore TabItem variants, and see the usage examples section for Tab component demonstrations.
Interactive Playground
Use the controls to customize the TabItem and see how it looks in real-time. Toggle between themes and hues to see how tab items adapt to different contexts. Note: This playground shows TabItem variants only. For Tab component variants, see the Usage Examples section.
Anatomy
A TabItem consists of several parts that work together to create a cohesive interactive element.
padding, border-radius (for pill style)flex layout, gap--body-*-text-size--spacing-2002px bottom border (default style only)Variants & States
TabItems come in different sizes, styles, and states to fit various use cases. The Tab component supports different configurations for organizing multiple TabItems.
For a complete matrix of all tab variants, sizes, and states, see the TabItem component in Figma and Tab component in Figma.
Usage Guidelines
- Use tabs to organize related content into distinct sections.
- Keep tab labels concise and descriptive.
- Use the default style for most navigation scenarios.
- Limit the number of tabs to avoid overwhelming users (typically 3-5 tabs).
- Ensure active tab state is clearly visible.
- Use icons to enhance clarity when appropriate.
- Don't use tabs for unrelated content sections.
- Don't use too many tabs (more than 7-8) - consider alternative navigation patterns.
- Don't use vague or ambiguous tab labels.
- Don't disable tabs without explaining why.
- Don't use tabs for hierarchical navigation (use menus instead).
- Don't make tabs too small to tap comfortably on mobile.
Accessibility
- Tabs must be keyboard accessible. Use proper ARIA attributes for tab navigation.
- Provide descriptive labels for screen readers using
aria-labelwhen needed. - Ensure focus states are clearly visible with sufficient contrast.
- Use
disabledattribute for disabled tabs, not just visual styling. - Active tab state should be announced to screen readers.
API Reference
TabItem and Tab component props and types.
TabItemProps
interface TabItemProps {
tabName?: string;
state?: "default" | "active" | "hover" | "disabled";
size?: "sm" | "md";
style?: "default" | "pill" | "side";
placement?: "horizontal" | "vertical";
showStartIcon?: boolean;
showEndIcon?: boolean;
showTabLabel?: boolean;
cornerRadius?: 0 | 1 | 2 | 3 | 4 | 5;
startIcon?: React.ReactNode;
endIcon?: React.ReactNode;
onClick?: () => void;
"aria-label"?: string;
}TabProps
interface TabProps {
size?: "sm" | "md";
itemWidth?: "auto" | "equal";
style?: "default" | "pill" | "side";
placement?: "horizontal";
cornerRadius?: 0 | 1 | 2 | 3 | 4 | 5;
children: React.ReactNode;
"aria-label"?: string;
}TabItem Props
tabNamestringstate"default" | "active" | "hover" | "disabled""default"size"sm" | "md""sm"style"default" | "pill" | "side""default"placement"horizontal" | "vertical""horizontal"showStartIconbooleantrueshowEndIconbooleantrueshowTabLabelbooleantruecornerRadius0 | 1 | 2 | 3 | 4 | 55Tab Props
size"sm" | "md""sm"itemWidth"auto" | "equal""auto"style"default" | "pill" | "side""default"placement"horizontal""horizontal"cornerRadius0 | 1 | 2 | 3 | 4 | 55Usage Examples
Copyable code snippets for common tab use cases.
Default Style
<Tab>
<TabItem>Active</TabItem>
<TabItem>Tab #1</TabItem>
<TabItem>Tab #2</TabItem>
</Tab>Pill Style
<Tab
style="pill"
>
<TabItem>Active</TabItem>
<TabItem>Tab #1</TabItem>
<TabItem>Tab #2</TabItem>
</Tab>Tab with Medium Size
<Tab
size="md"
>
<TabItem>Active</TabItem>
<TabItem>Tab #1</TabItem>
<TabItem>Tab #2</TabItem>
</Tab>Equal Width Items
<Tab
itemWidth="equal"
>
<TabItem>Active</TabItem>
<TabItem>Tab #1</TabItem>
<TabItem>Tab #2</TabItem>
</Tab>Vertical Placement
import { Tab, TabItem } from 'beacon-ui';
import { PageFileIcon } from 'beacon-icons';
<Tab>
<TabItem tabName="Active" state="active" placement="vertical" startIcon={<PageFileIcon size={16} />} />
<TabItem tabName="Tab #1" placement="vertical" startIcon={<PageFileIcon size={16} />} />
<TabItem tabName="Tab #2" placement="vertical" startIcon={<PageFileIcon size={16} />} />
</Tab>Side Style
<Tab
style="side"
>
<TabItem>Active</TabItem>
<TabItem>Tab #1</TabItem>
<TabItem>Tab #2</TabItem>
</Tab>