apps/docs/content/docs/react/components/(navigation)/tabs.mdx
import { Tabs } from '@heroui/react';
<ComponentPreview isBgSolid name="tabs-basic" />
Import the Tabs component and access all parts using dot notation.
import { Tabs } from '@heroui/react';
export default () => (
<Tabs>
<Tabs.ListContainer>
<Tabs.List aria-label="Options">
<Tabs.Tab>
<Tabs.Separator />
<Tabs.Indicator />
</Tabs.Tab>
</Tabs.List>
</Tabs.ListContainer>
<Tabs.Panel/>
</Tabs>
)
<ComponentPreview isBgSolid name="tabs-vertical" />
<ComponentPreview isBgSolid name="tabs-disabled" />
Add <Tabs.Separator /> inside each <Tabs.Tab> (except the first) to display separator lines between tabs.
<ComponentPreview isBgSolid name="tabs-with-separator" />
<ComponentPreview isBgSolid name="tabs-custom-styles" />
<ComponentPreview isBgSolid name="tabs-secondary" />
<ComponentPreview isBgSolid name="tabs-secondary-vertical" />
<RelatedShowcases component="Tabs" /> <RelatedComponents component="tabs" /><ComponentPreview name="tabs-custom-render-function" />
<CollapsibleCode lang="tsx" code={` import { Tabs } from '@heroui/react';
function CustomTabs() { return ( <Tabs className="w-full max-w-lg text-center"> <Tabs.ListContainer> <Tabs.List aria-label="Options" className="*:data-[selected=true]:text-accent-foreground w-fit *:h-6 *:w-fit *:px-3 *:text-sm *:font-normal" > <Tabs.Tab id="daily">Daily<Tabs.Indicator /></Tabs.Tab> <Tabs.Tab id="weekly">Weekly<Tabs.Indicator /></Tabs.Tab> <Tabs.Tab id="bi-weekly">Bi-Weekly<Tabs.Indicator /></Tabs.Tab> <Tabs.Tab id="monthly">Monthly<Tabs.Indicator /></Tabs.Tab> </Tabs.List> </Tabs.ListContainer> <Tabs.Panel className="px-4" id="daily"> <h3 className="mb-2 font-semibold">Daily</h3> <p className="text-sm text-gray-600">Manage your daily tasks and goals.</p> </Tabs.Panel> <Tabs.Panel className="px-4" id="weekly"> <h3 className="mb-2 font-semibold">Weekly</h3> <p className="text-sm text-gray-600">Manage your weekly tasks and goals.</p> </Tabs.Panel> <Tabs.Panel className="px-4" id="bi-weekly"> <h3 className="mb-2 font-semibold">Bi-Weekly</h3> <p className="text-sm text-gray-600">Manage your bi-weekly tasks and goals.</p> </Tabs.Panel> <Tabs.Panel className="px-4" id="monthly"> <h3 className="mb-2 font-semibold">Monthly</h3> <p className="text-sm text-gray-600">Manage your monthly tasks and goals.</p> </Tabs.Panel> </Tabs> ); } `} />
The Tabs component uses these CSS classes:
.tabs - Base tabs container.tabs__list-container - Tab list container wrapper.tabs__list - Tab list container.tabs__tab - Individual tab button.tabs__separator - Separator between tabs.tabs__panel - Tab panel content.tabs__indicator - Tab indicator.tabs[data-orientation="horizontal"] - Horizontal tab layout (default).tabs[data-orientation="vertical"] - Vertical tab layout.tabs--secondary - Secondary variant with underline indicatorThe component supports both CSS pseudo-classes and data attributes:
[aria-selected="true"]:hover or [data-hovered="true"]:focus-visible or [data-focus-visible="true"][aria-disabled="true"]| Prop | Type | Default | Description |
|---|---|---|---|
variant | "primary" | "secondary" | "primary" | Visual style variant. Primary uses a filled indicator, secondary uses an underline indicator |
orientation | "horizontal" | "vertical" | "horizontal" | Tab layout orientation |
selectedKey | string | - | Controlled selected tab key |
defaultSelectedKey | string | - | Default selected tab key |
onSelectionChange | (key: Key) => void | - | Selection change handler |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, TabsRenderProps> | - | Overrides the default DOM element with a custom render function. |
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | - | Accessibility label for tab list |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, TabListRenderProps> | - | Overrides the default DOM element with a custom render function. |
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | - | Unique tab identifier |
isDisabled | boolean | false | Whether tab is disabled |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, TabRenderProps> | - | Overrides the default DOM element with a custom render function. |
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | - | Panel identifier matching tab id |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, TabPanelRenderProps> | - | Overrides the default DOM element with a custom render function. |