Astro Components
Type to search documentation.

Tabs

Let readers choose between equivalent examples.

Use Tabs when each panel solves the same task for a different audience: package manager, framework, language, operating system, or output format. Do not use tabs for unrelated content; readers may miss hidden information.

Import

import { TabItem, Tabs } from '@prosefly/astro-components';

Basic Usage

Tabs can contain prose, lists, links, and other MDX content.

<Tabs>
<TabItem label="Preview">
Tabs can contain prose, lists, links, and other MDX content.
</TabItem>
<TabItem label="Code">
```astro
<Tabs>
<TabItem label="Preview">Preview content</TabItem>
<TabItem label="Code">Code content</TabItem>
</Tabs>
```
</TabItem>
</Tabs>

Commands With Copy

Terminal window
pnpm add @prosefly/astro-components

Set copy when every panel contains a code block and readers are likely to copy the active command.

<Tabs copy syncKey="install-command">
<TabItem label="pnpm" icon="simple-icons:pnpm">
```sh
pnpm add @prosefly/astro-components
```
</TabItem>
<TabItem label="npm" icon="simple-icons:npm">
```sh
npm install @prosefly/astro-components
```
</TabItem>
<TabItem label="yarn" icon="simple-icons:yarn">
```sh
yarn add @prosefly/astro-components
```
</TabItem>
</Tabs>

Synced Groups

Use syncKey when the same choices appear more than once on a page. Selecting pnpm in one group will select pnpm in the other group.

Terminal window
pnpm dev
Terminal window
pnpm build
<Tabs syncKey="workflow-command">
<TabItem label="pnpm" icon="simple-icons:pnpm">
```sh
pnpm dev
```
</TabItem>
<TabItem label="npm" icon="simple-icons:npm">
```sh
npm run dev
```
</TabItem>
</Tabs>
<Tabs syncKey="workflow-command">
<TabItem label="pnpm" icon="simple-icons:pnpm">
```sh
pnpm build
```
</TabItem>
<TabItem label="npm" icon="simple-icons:npm">
```sh
npm run build
```
</TabItem>
</Tabs>

Props

ComponentPropTypeNotes
Tabscopyboolean | stringShows a copy button for the active panel.
TabsdefaultValuestringSelects a tab by label or value.
TabssyncKeystringShares selection across groups with matching labels.
TabItemlabelstringRequired visible tab label.
TabItemvaluestringStable internal value.
TabItemiconstringIconify icon shown in the active tab indicator.

Last updated Jul 18, 2026