We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Tabs Component

The Tabs component creates an interactive interface that organizes content into separate, easily accessible sections. Each tab panel displays unique content while keeping your interface clean and focused.

  • Check Circle

    Synchronized Groups: Link multiple tab sets together

  • Check Circle

    Accessibility: Full ARIA support and keyboard navigation

  • Check Circle

    Custom Styling: Extensive style customization options

Create tabbed interfaces with the Tabs and TabItem components:

Content for the first tab would go here.

Content for the second tab would go here.

<Tabs>
<TabItem label="First Tab">
Content for the first tab
</TabItem>
<TabItem label="Second Tab">
Content for the second tab
</TabItem>
</Tabs>

The Tabs component supports two different animation types:

  • fade (Default): Smoothly fades between tabs
  • slide: Slides between tabs

Here’s some content for the first tab

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.

Here’s some content for the second tab

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.

Here’s some content for the first tab

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.

Here’s some content for the second tab

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, quos.

Tabs Component Props Extends <div> HTMLElement
Prop Type Default Description
defaultTab string First tab Label of initially active tab
syncKey string Key for synchronizing multiple tab groups
labels string[] Optional array of tab labels
buttonProps ButtonProps Props passed to tab buttons
TabItem Component Props Extends <div> HTMLElement
Prop Type Default Description
label string Text shown in the tab button

Link multiple tab groups to switch together:

First group content First group details
Second group content Second group details
<Tabs syncKey="related-content">
<TabItem label="Overview">First group content</TabItem>
<TabItem label="Details">First group details</TabItem>
</Tabs>
<Tabs syncKey="related-content">
<TabItem label="Overview">Second group content</TabItem>
<TabItem label="Details">Second group details</TabItem>
</Tabs>

The Tabs component emits a tab-change event when selection changes:

Content for the first tab Content for the second tab Content for the third tab
Waiting for events to be emitted… (Click on the tabs to see the events)
// Listen for tab changes
const tabs = document.querySelector('tabs-wrapper');
tabs.addEventListener(TabsEventNames.Change, (event) => {
const { id, tabId, syncKey } = event.detail;
console.log(`Tab: ${tabId}, Sync Key: ${syncKey}`, id);
});

Limited Time Launch Sale

Get started with our AstroJS starter template and access a complete collection of pre-built components, including these versatile Tabs!

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes