Docs menu

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.json

Usage

tsx
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
tsx
<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

PropTypeDefault
intensity

Set on TabsList. kawaii: mochi stretch and a landing puff. subtle: the candy slides. off: it jumps.

"kawaii" | "subtle" | "off""kawaii"
color

Set on TabsTrigger. The candy's colour while that tab is active.

"sakura" | "lavender" | "mint" | "sky" | "lemon" | "peach""sakura"
value / defaultValue

Set on Tabs. The active tab.

string-
onValueChange

Set on Tabs. Called when the active tab changes.

(value: string) => void-
orientation

Set on Tabs. Changes which arrow keys move focus.

"horizontal" | "vertical""horizontal"