# Rubber tabs

Tabs whose underline stretches like a rubber band.

Also called: animated tabs, tab underline animation.

Example: An underline that stretches. Jump between tabs and the underline stretches like a rubber band, thinning as it goes, while the labels gain weight under it. Preview: https://chatcn.dev/preview/rubber-tabs-demo

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

```bash
npx 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

| Prop | Type | Notes |
| --- | --- | --- |
| `tabs` | `{ value, label, content }[]` |  |
| `value` / `defaultValue` / `onValueChange` | `string` |  |
| `panelClassName` | `string` | Give the panel area a height |

## Keyboard

| Key | Action |
| --- | --- |
| `Arrow keys` | Previous 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.

Source: https://chatcn.dev/docs/components/rubber-tabs