Skip to content
Sign upGet access
MicrointeractionsRubber tabsMenu

Rubber tabs

Tabs whose underline stretches like a rubber band.

Jump between tabs and the underline stretches like a rubber band, thinning as it goes, while the labels gain weight under it.

The edge facing where you are going is stiff and shoots ahead while the trailing edge is soft and catches up, so the band stretches across the jump and thins as it stretches, then snaps back to the width of the label. Each label gets heavier and brighter as the band passes under it, and the panels cross slide in the direction of travel.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/rubber-tabs.json

Usage

tsx
import { RubberTabs } from "@/components/ui/chatcn/rubber-tabs"

<RubberTabs tabs={[{ value: "overview", label: "Overview", content: <Overview /> }]} />

Props

PropTypeNotes
tabs{ value, label, content }[]
value / defaultValue / onValueChangestring
panelClassNamestringGive the panel area a height

Keyboard

KeyAction
Arrow keysPrevious or next tab

Accessibility

  • A real tablist: tabs control their panels and only the selected one is in the tab order.

Motion

  • Leading edge spring 540, trailing 120; panels slide 560 ms with a small overshoot. Reduced motion: the band jumps and the panels swap.