close

Tabs/Tab

Tabs and Tab switch between multiple content panes.

Usage

Tab 1
Tab 2
Tab 1 content
index.mdx
import { Tab, Tabs } from '@rspress/core/theme';

<Tabs>
  <Tab label="Tab 1">Tab 1 content</Tab>
  <Tab label="Tab 2">Tab 2 content</Tab>
</Tabs>

Code blocks

Tab 1
Tab 2
src/index.mjs
import foo from 'foo';
import bar from 'bar';
index.mdx
import { Tab, Tabs } from '@rspress/core/theme';

<Tabs>
<Tab label="Tab 1">

```tsx title="src/index.mjs"
import foo from 'foo';
import bar from 'bar';
```

</Tab>
<Tab label="Tab 2">

```tsx title="src/index.cjs"
const foo = require('foo');
const bar = require('bar');
```

</Tab>
</Tabs>

Props

interface TabsProps {
  children: React.ReactNode;
  defaultValue?: string;
  groupId?: string;
  tabPosition?: 'left' | 'center';
}

interface TabProps {
  label: string;
  value?: string;
  children: React.ReactNode;
}

Use defaultValue to preselect a tab (matches value); groupId syncs selection across multiple Tabs; tabPosition sets list alignment.