Lotus
Type to search documentation.

Tabs

Present parallel examples as one selectable set of tab panels.

Use Tabs when readers need to switch between equivalent examples, such as package managers, frameworks, output formats, or preview/code views.

Import

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

Basic Usage

The syntax follows Starlight: place one or more TabItem components directly inside Tabs.

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

  • Keep each panel focused on the same task.
  • Use short labels so the tab list stays compact on mobile.
<Tabs>
<TabItem label="Preview">
Preview content
</TabItem>
<TabItem label="Code">
Code content
</TabItem>
</Tabs>

With Icons

Add icon to a TabItem with any Iconify icon name. When a group has icons, the active tab icon appears at the start of the tab header.

Terminal window
npm install @prosefly/astro-components
<Tabs defaultValue="npm" syncKey="package-manager">
<TabItem label="pnpm" icon="simple-icons:pnpm">
```sh
pnpm install @prosefly/astro-components
```
</TabItem>
<TabItem label="npm" icon="simple-icons:npm">
```sh
npm install @prosefly/astro-components
```
</TabItem>
</Tabs>

Copy Code

Set copy on Tabs when each panel contains a code block and the active panel should be copyable from the tab header.

Terminal window
pnpm add @prosefly/astro-components

The copy button reads the first code block in the active panel.

Synced Groups

Groups with the same syncKey share the selected label. This is useful for package manager examples repeated across a page.

Terminal window
pnpm dev
Terminal window
pnpm build

Use matching labels across synced groups. syncKey stores the selected label in localStorage, so the reader’s choice can persist across navigation.

Custom Values

Use value when a tab needs a stable internal value that differs from its visible label. defaultValue can match either label or value.

export const defineTheme = () => ({ name: 'Lotus' });

Props

Tabs

PropTypeDefaultNotes
copyboolean | stringfalseShows a copy button for the first code block in the active panel.
defaultValuestringfirst tabInitial active tab. Matches either TabItem.label or TabItem.value.
syncKeystringoptionalSyncs the active label across tab groups with the same key.

TabItem

PropTypeDefaultNotes
labelstringrequiredVisible tab label. Also used for syncing when value is omitted.
valuestringlabelStable value for defaultValue and internal tab state.
iconstringoptionalIconify icon name shown as the active panel icon.

Syntax Rules

  • Tabs must contain only direct TabItem children.
  • Each TabItem must have a label.
  • Put Markdown content inside each TabItem; do not put loose Markdown between tab items.
  • Use concise labels so the tab list remains easy to scan on small screens.

Last updated Jul 18, 2026

Contributors