Tabs
A tray of tabs with one gummy candy living in it. Pick a tab and the candy
stretches toward it like pulled mochi, snaps over and lands in a puff. Give a
tab a color and the candy changes flavour when it gets there.
Strawberry daifuku, melon pan and a very tall parfait.
Installation
❯ npx shadcn@latest add https://yan.moe/r/tabs.jsonUsage
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"<Tabs defaultValue="sweet">
<TabsList>
<TabsTrigger value="sweet">Sweet</TabsTrigger>
<TabsTrigger value="sour" color="lemon">Sour</TabsTrigger>
</TabsList>
<TabsContent value="sweet">Strawberry daifuku.</TabsContent>
<TabsContent value="sour">Lemon drops.</TabsContent>
</Tabs>Accessibility
- Built on Radix Tabs: arrow keys move between tabs, Home and End jump to the ends, and panels are linked with
aria-controls. - The candy follows the active tab however it was chosen: pointer, arrow keys or code.
- With
prefers-reduced-motion: reduce, the candy jumps into place and the puff and panel float are skipped.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on TabsList. kawaii: mochi stretch and a landing puff. subtle: the candy slides. off: it jumps. | "kawaii" | "subtle" | "off" | "kawaii" |
colorSet on TabsTrigger. The candy's colour while that tab is active. | "sakura" | "lavender" | "mint" | "sky" | "lemon" | "peach" | "sakura" |
value / defaultValueSet on Tabs. The active tab. | string | - |
onValueChangeSet on Tabs. Called when the active tab changes. | (value: string) => void | - |
orientationSet on Tabs. Changes which arrow keys move focus. | "horizontal" | "vertical" | "horizontal" |