Skip to main content

Starwind UI v3.0 is now available! Migration guide

Build fast websites, faster with Astro’s next-gen island architecture.

The React framework for production-grade applications that scale.

Installation

Usage

---
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/starwind/tabs";
---
<Tabs defaultValue="astro" class="max-w-[400px]">
<TabsList>
<TabsTrigger value="astro">Astro</TabsTrigger>
<TabsTrigger value="next">Next.js</TabsTrigger>
</TabsList>
<TabsContent value="astro">
Build fast websites, faster with Astro's next-gen island architecture.
</TabsContent>
<TabsContent value="next">
The React framework for production-grade applications that scale.
</TabsContent>
</Tabs>

Composition

Match each trigger value to one content value:

Tabs
├── TabsList
│ ├── TabsTrigger
│ └── TabsTrigger
├── TabsContent
└── TabsContent

Synced Tabs

Use the syncKey prop to synchronize multiple tab groups. All tabs with the same syncKey will update together.

React is a JavaScript library for building user interfaces.

Vue is a progressive framework for building user interfaces.

React’s virtual DOM optimizes rendering performance.

Vue’s reactivity system makes state management intuitive.

Disabled Triggers

Use the disabled attribute to prevent a tab from being selected.

Active tab content
Disabled tab content
Pending tab content

Nested Tabs

Show how tabs can be nested by placing a Tabs component inside a TabsContent panel.

Outer Tab 1 content

This tab contains nested tabs:

Inner tab A content
Inner tab B content

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Tabs

Inherits div attributes. Omits `defaultValue`, `onChange`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
defaultValue string | null —
Description
Sets the initial value when the component is uncontrolled.
Classification
Primitive override
Type imports
React import type { TabsValue } from "@starwind-ui/react";
Primitive prop
tabs.Root.defaultValue
orientation "horizontal" | "vertical" "horizontal"
Description
Selects the horizontal or vertical layout direction.
Classification
Primitive override
Primitive prop
tabs.Root.orientation
value string | null —
Description
Controls or identifies the component value.
Classification
Primitive override
Type imports
React import type { TabsValue } from "@starwind-ui/react";
Primitive prop
tabs.Root.value

Tabs List

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
activateOnFocus boolean —
Description
Activates the focused item while moving through the collection.
Classification
Primitive override
Primitive prop
tabs.List.activateOnFocus
loopFocus boolean —
Description
Wraps keyboard focus from the last item to the first and vice versa.
Classification
Primitive override
Primitive prop
tabs.List.loopFocus

Tabs Trigger

Inherits button attributes. Omits `type` and `value`.

Contains the following additional props:

Prop Type Default Toggle details
value Required string —
Description
Controls or identifies the component value.
Classification
Wrapper prop

Tabs Content

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
keepMounted boolean —
Description
Keeps hidden content mounted in the DOM.
Classification
Primitive override
Primitive prop
tabs.Panel.keepMounted
value Required string —
Description
Controls or identifies the component value.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Tabs.

Primitive API

Runtime API

Tabs primitive
createTabs from @starwind-ui/runtime/tabs

Changelog

View version history v2.0.2 10 releases

v2.0.2

  • Fixed the active tab indicator position when its container is scrolled or transformed.

v2.0.1

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v2.0.0

  • Rebuilt Tabs on Starwind Runtime for selection, focus movement, and synchronized groups.
  • See the Tabs Primitive for the underlying unstyled anatomy and behavior API.

v1.4.3

  • Refactor tailwind variants functions into separate variants.ts file

v1.4.1

  • Add starwind:init event listener to enable initialization of additional Tabs loaded after an initial page load, such as when using server islands

v1.4.0

  • style and focus state updates

v1.3.0

  • Add a data-slot attribute to all components to enable global styling updates

v1.2.0

  • Add support for nested tabs

v1.1.1

  • Small script cleanup

v1.1.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.