TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
Tabs component organizes related-but-alternative content — such as code snippets for different package managers, operating systems, or programming languages — into a compact, interactive tab strip. Each tab panel is rendered in the DOM for SEO purposes but hidden with CSS when not selected. Individual panels are exposed via Tabs.Tab.
Import
Props
<Tabs>
| Prop | Type | Default | Description |
|---|---|---|---|
items | string[] | TabObjectItem[] | — | Required. The ordered list of tab labels. Pass a { label, disabled: true } object to disable a specific tab. |
defaultIndex | number | 0 | The zero-based index of the tab that is selected on first render. |
storageKey | string | — | When provided, the selected tab index is persisted to localStorage under this key and synced across all <Tabs> instances on the page sharing the same key. |
selectedIndex | number | — | Controlled selected index. |
onChange | (index: number) => void | — | Callback fired when the user changes the selected tab. |
className | string | — | CSS class applied to the tab list container. |
tabClassName | string | — | CSS class applied to each individual tab button. |
<Tabs.Tab>
Each <Tabs.Tab> corresponds — in order — to the label at the same index in the parent’s items array.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The content displayed when this tab is active. Supports full MDX. |
Usage
Basic Tabs
Setting a Default Tab
UsedefaultIndex to start on a tab other than the first. The index is zero-based, so defaultIndex={1} selects the second tab.
Syncing Tabs Across the Page
When multiple<Tabs> components on the same page share a storageKey, selecting a tab in one automatically selects the matching index in all others. The selection is also persisted across page reloads via localStorage.
Disabling a Tab
Pass a{ label, disabled: true } object instead of a plain string to disable a specific tab.
Tabs with Code Blocks
Tab panels support full MDX, including fenced code blocks with syntax highlighting. Use four backticks for the outer fence when your content contains triple-backtick code blocks:All tab panels are present in the rendered HTML and are discovered by Pagefind and other crawlers. Only the inactive panels are hidden with CSS, so your content remains fully indexable.