--- id: tab sidebar_label: 'Tab' sidebar_position: 1 --- # Tabs A flexible Tabs component built on React Aria's `Tabs` component with consistent styling and accessibility features. ## Props | Prop | Type | Default | Description | | ------- | ----------- | ------- | ---------------------------- | | `items` | `TabItem[]` | [] | Array of tab items to render | ### TabItem | Property | Type | Required | Description | | ------------ | ----------------- | -------- | ------------------------------------- | | `id` | `string` | Yes | Unique identifier for the tab | | `title` | `React.ReactNode` | Yes | Tab label text or content | | `content` | `React.ReactNode` | Yes | Content to display in the tab panel | | `icon` | `React.ReactNode` | No | Optional icon to display before title | | `isDisabled` | `boolean` | No | Whether the tab is disabled | Extends all [React Aria TabsProps](https://react-spectrum.adobe.com/react-aria/Tabs.html#tabs-1). ## Usage Examples ### Basic usage ```tsx live Content for Tab 1 }, { id: 'tab2', title: 'Tab 2', content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ``` ### Vertical Tabs ```tsx live Content for Tab 1 }, { id: 'tab2', title: 'Tab 2', content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ``` ### Tab with icon ```tsx live Content for Tab 1, icon: }, { id: 'tab2', title: 'Tab 2', content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ``` ### Controlled tabs ```tsx live function ControlledTabsExample() { const [selectedTabId, setSelectedTabId] = useState('tab1'); return ( <> current selected tab: {selectedTabId} Content for Tab 1 }, { id: 'tab2', title: 'Tab 2', content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ); } ``` ### Disabled Tabs ```tsx live Content for Tab 1 }, { id: 'tab2', title: 'Tab 2', content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ``` ### Disable Items ```tsx live Content for Tab 1 }, { id: 'tab2', title: 'Tab 2', isDisabled: true, content:
Content for Tab 2
}, { id: 'tab3', title: 'Tab 3', content:
Content for Tab 3
}, ]} /> ``` ## Styling ### CSS Variables The component uses the following CSS variables for theming: - `--color-bg`: Tabs background color - `--color-font`: Tabs text color - `--hl-xs`: Highlight for hover/selected - `--hl-sm`: Standard border color You can customize these variables in your CSS to theme the tabs appearance.