Tabs
Build fast websites, faster with Astro’s next-gen island architecture.
The React framework for production-grade applications that scale.
---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>
Installation
pnpx starwind@latest add tabs
npx starwind@latest add tabs
yarn dlx starwind@latest add tabs
Usage
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.
---import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/starwind/tabs";---
<Tabs defaultValue="react" syncKey="frameworks" class="max-w-[400px]"> <TabsList> <TabsTrigger value="react">React</TabsTrigger> <TabsTrigger value="vue">Vue</TabsTrigger> </TabsList> <TabsContent value="react"> React is a JavaScript library for building user interfaces. </TabsContent> <TabsContent value="vue"> Vue is a progressive framework for building user interfaces. </TabsContent></Tabs>
<Tabs defaultValue="react" syncKey="frameworks" class="max-w-[400px]"> <TabsList> <TabsTrigger value="react">React</TabsTrigger> <TabsTrigger value="vue">Vue</TabsTrigger> </TabsList> <TabsContent value="react"> React's virtual DOM optimizes rendering performance. </TabsContent> <TabsContent value="vue"> Vue's reactivity system makes state management intuitive. </TabsContent></Tabs>
Disabled Triggers
Use the disabled
attribute to prevent a tab from being selected.
---import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/starwind/tabs";---
<Tabs defaultValue="active" class="max-w-[400px]"> <TabsList> <TabsTrigger value="active">Active</TabsTrigger> <TabsTrigger value="disabled" disabled>Disabled</TabsTrigger> <TabsTrigger value="pending">Pending</TabsTrigger> </TabsList> <TabsContent value="active">Active tab content</TabsContent> <TabsContent value="disabled">Disabled tab content</TabsContent> <TabsContent value="pending">Pending tab content</TabsContent></Tabs>
API Reference
Tabs
Prop | Type | Default |
---|---|---|
defaultValue | string | - |
syncKey | string | - |
This component also accepts all standard HTML attributes for <div>
elements.
TabsList
This component is used to wrap the TabsTrigger
components. This component also accepts all standard HTML attributes for <div>
elements, except for role
.
TabsTrigger
Prop | Type | Default |
---|---|---|
value | string | - |
disabled | boolean | false |
This component also accepts all standard HTML attributes for <button>
elements, except for type
, id
, and role
.
TabsContent
Prop | Type | Default |
---|---|---|
value | string | - |
This component also accepts all standard HTML attributes for <div>
elements, except for id
, role
, tabindex
, and hidden
.
Changelog
v1.1.0
tailwind-variants
now implemented. This usestailwind-merge
under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.