Skip to content

Tabs

Learn how to create tabbed interfaces in Starlight to group equivalent information.

To create a tabbed interface use the <Tabs> and <TabItem> components. Tabs are useful for grouping equivalent information where a user only needs to see one of several options.

import { Tabs, TabItem } from '@astrojs/starlight/components';

Display a tabbed interface using the <Tabs> and <TabItem> components. Each <TabItem> must have a label to display to users.

Keep multiple tab groups synchronized by adding the syncKey attribute.

All <Tabs> on a page with the same syncKey value will display the same active label. This allows your reader to choose once (e.g. their operating system or package manager), and see their choice persisted across page navigations.

To synchronize related tabs, add an identical syncKey property to each <Tabs> component and ensure that they all use the same <TabItem> labels:

Include an icon in a tab item using the icon attribute set to the name of one of Starlight’s built-in icons to display an icon next to the label.

Implementation: Tabs.astro

The <Tabs> component groups multiple <TabItem> components together and accepts the following props:

type: string

A key used to keep multiple tab groups synchronized across multiple pages.

Implementation: TabItem.astro

A set of tabs is composed of tab items, each with the following props:

required
type: string

A tab item must include a label attribute set to the text that will be displayed in the tab.

type: string

Each tab item can include an icon attribute set to the name of one of Starlight’s built-in icons to display an icon next to the label.