Tabs
Tabs switch between views of the same content, such as the summary, releases and royalties of one artist.
When to use
Section titled “When to use”- Use tabs for 2 to 6 views that sit at the same level.
- Keep the content of every tab related; use separate pages for unrelated content.
- Don’t use tabs as steps of a process; use a stepper.
12 rilis aktif bulan ini.
12 rilis aktif bulan ini.
Anatomy
Section titled “Anatomy”- 1Active tab
- 2Indicator on primary
- 3Tab
- 4Panel
A row of labels over a border line, and the content of the active tab below it. The active tab has foreground text and a 2px primary line under it; the others use muted-foreground. Tabs are 36px tall and never sit on a pill.
Variants
Section titled “Variants”There is one style, horizontal or vertical (orientation="vertical"). In vertical tabs the line moves to the right edge.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
defaultValue / value |
default-value / v-model |
value |
string | none | The active tab. |
onValueChange |
@update:model-value |
onChanged |
function | none | Runs when the tab changes. |
orientation |
orientation |
none | horizontal | vertical |
horizontal |
Direction of the tab list. |
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
export default function TabsDemo() { return ( <Tabs defaultValue="ringkasan" className="w-full max-w-md"> <TabsList> <TabsTrigger value="ringkasan">Ringkasan</TabsTrigger> <TabsTrigger value="rilis">Rilis</TabsTrigger> <TabsTrigger value="royalti">Royalti</TabsTrigger> </TabsList> <TabsContent value="ringkasan" className="pt-3 text-muted-foreground">12 rilis aktif bulan ini.</TabsContent> <TabsContent value="rilis" className="pt-3 text-muted-foreground">3 rilis menunggu dikirim.</TabsContent> <TabsContent value="royalti" className="pt-3 text-muted-foreground">Laporan Oktober sudah masuk.</TabsContent> </Tabs> )}<script setup lang="ts">import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"</script>
<template> <Tabs default-value="ringkasan" class="w-full max-w-md"> <TabsList> <TabsTrigger value="ringkasan">Ringkasan</TabsTrigger> <TabsTrigger value="rilis">Rilis</TabsTrigger> <TabsTrigger value="royalti">Royalti</TabsTrigger> </TabsList> <TabsContent value="ringkasan" class="pt-3 text-muted-foreground">12 rilis aktif bulan ini.</TabsContent> <TabsContent value="rilis" class="pt-3 text-muted-foreground">3 rilis menunggu dikirim.</TabsContent> <TabsContent value="royalti" class="pt-3 text-muted-foreground">Laporan Oktober sudah masuk.</TabsContent> </Tabs></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
class TabsDemo extends StatelessWidget { const TabsDemo({super.key});
@override Widget build(BuildContext context) { return ShadTabs<String>( value: 'ringkasan', // Tabs share the bar width equally; leave room for the longest label. tabBarConstraints: const BoxConstraints(maxWidth: 520), tabs: const [ ShadTab(value: 'ringkasan', content: Text('12 rilis aktif bulan ini.'), child: Text('Ringkasan')), ShadTab(value: 'rilis', content: Text('3 rilis menunggu dikirim.'), child: Text('Rilis')), ShadTab(value: 'royalti', content: Text('Laporan Oktober sudah masuk.'), child: Text('Royalti')), ], ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/tabs.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/tabs.jsonAccessibility
Section titled “Accessibility”- Renders
role="tablist",tabandtabpanel, witharia-selectedon the active tab. - Arrow keys move between tabs; Tab moves into the panel.
