# Tabs

Switch between views that share one place.

Switch between views that share one place. A row of 13px tab labels; the selected one sits on a filled pill (pill) or over an ink underline (underline), and that indicator slides to the next tab under the pointer and jumps under the keyboard. Panels swap instantly. One tab stop: arrow keys move and select. Tabs can be closable, which makes them document tabs (open files, browser tabs): a close button beside each trigger, Delete on the focused tab, focus and selection handed to a neighbour, a title cut at 240px, and a tab that opens or closes makes room instead of jumping. A strip with more tabs than room scrolls sideways, keeps the selected tab in view, fades each edge it continues past and shows a button at its end that lists every tab in a menu; `fill` makes the panel take the height of its container. Behaviour, focus and ARIA come from the Zag tabs machine, through Ark UI in React, Vue and Svelte.

Kind: component · Category: Navigation · Status: beta · Targets: React, Vue, Svelte · Behaviour: Zag `tabs` machine, through Ark UI

## Add

```bash
npx fndn add tabs
```

It writes the folder `tabs/` into the project's ui folder (`index.ts`, `tabs.tsx`, `Tabs.vue`, `Tabs.svelte`, `tabs.recipe.ts`), and what it is built from: [Button](/components/button.md), [Menu](/components/menu.md), [Tooltip](/components/tooltip.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { Tabs } from "@/components/ui/tabs";
```

```vue
import { Tabs } from "@/components/ui/tabs";
```

```svelte
import { Tabs } from "$lib/components/ui/tabs";
```

## Parts

In the DOM the root carries `data-slot="tabs"` and each part `data-slot="tabs-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `tabs` |  | data-orientation (set by the engine). A grid: without the header part, the list and the all-tabs menu share the first row; every other part spans both columns. Rows are as tall as their content, packed at the top, so a panel keeps its content's height in a taller root. With fill: the height of its container (which must have one), and the selected panel's row takes what the strip leaves. |
| `header` | `div` | `tabs-header` | optional | Optional. The host's header row around the list (headerClass adds the host's class), holding the all-tabs menu (while the strip overflows) and then the host's trailing parts (the end slot). Rendered only when headerClass or end is given. A flex row; with inHeader the list fills its height. |
| `list` | `div` | `tabs-list` |  | role=tablist; the indicator's offset parent. Scrolls sideways when the tabs do not fit (no scrollbar, the wheel's sideways overscroll stays in): the selected tab is kept in view, 24px clear of the edge so the next one peeks in. data-overflow while the tabs are wider than it (measured on mount and on every change of size or of the tabs; never on a list with no box, display: none on it or above it). data-overflow-start / data-overflow-end while tabs are hidden past that edge (the scroll position, logical): each such edge fades out over 24px (a mask; underline keeps its hairline whole). |
| `indicator` | `div` | `tabs-indicator` |  | The engine's indicator: given the selected tab's box as --left / --top / --width / --height, it travels on transform only while a pointer selection is made; hidden until measured. Pill: field colour, radius.chip. Carries kbd-instant. |
| `tab` | `div` | `tabs-tab` | optional, repeats | Only around a closable tab: the trigger and its close button side by side (a button cannot hold a button). Not positioned, so the trigger's offset box stays the list's (the indicator measures the trigger, which keeps room at its end for the close button, so the pill or the underline spans both). It is the tab's room: it opens and closes (see motion, arrival and closing). |
| `trigger` | `button` | `tabs-trigger` | repeats | role=tab; aria-selected, data-selected, data-disabled. Holds the label part. |
| `icon` | `span` | `tabs-icon` | optional | An item's icon before its label: a file icon (an icon element / component, data-slot="icon") or a favicon (an image URL, drawn as an <img alt="">). aria-hidden: the label names the tab. 16px (14px at xs and sm). |
| `label` | `span` | `tabs-label` |  | The tab's text on one line; it truncates at the end and carries the full text as title. A view's name (a tab that is not closable) is never cut by the Tabs themselves: it is cut only when the strip is narrower than the one tab. A closable tab's title is free text (a document's name) and stops at 240px, cut at its end. |
| `close` | `button` | `tabs-close` | optional, repeats | A closable tab's close button: 16px with a 24px target, pulled back over the trigger's end room. Shown on the selected tab and while its tab is hovered (always on touch); keeps its room at rest, so the strip never reflows. Not a tab stop (the keyboard closes with Delete on the tab, aria-keyshortcuts) but not hidden either: named "Close <tab>", reachable by a screen reader's cursor and by touch exploration. A press never takes focus. |
| `more` | `div` | `tabs-more` | optional | The all-tabs menu: the Menu's root, after the list and before the end slot, marked data-tabs="more". Rendered only while the list has data-overflow. Its items are one radio group of every tab in order (a tab whose label is not text is listed by its value), the selected tab checked and disabled tabs disabled; picking one selects that tab (valueChange), closes the menu and focuses the tab, and the strip scrolls it into view. Placed bottom-end. |
| `more-trigger` | `button` | `tabs-more-trigger` | optional | The menu's trigger: the real Button (ghost, muted, square, caret-down), marked data-tabs="more-trigger", named and tooltipped by labels.allTabs. Its size matches the strip: xs for pill (held to the strip's height by negative block margins at xs and sm), the Tabs' size for underline. Underline outside a header: the hairline runs on under it. |
| `content` | `div` | `tabs-content` | repeats | role=tabpanel; hidden unless its tab is selected. With fill: takes the height the strip leaves and scrolls inside itself (put a ScrollArea with h-full in it for the system's scrollbar). |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `{ value: string; label: string; content?: string; disabled?: boolean; closable: boolean? (overrides the Tabs' closable); icon?: icon element or component \| image URL (favicon) }[]` |  | Tabs in order, each with its panel content. Strings are accepted as value = label. |
| `value` | `string` |  | Bindable (React: `defaultValue` and `onValueChange`; Vue: `v-model:value`; Svelte: `bind:value`). Selected tab. Defaults to the first enabled tab. |
| `variant` | `"pill" \| "underline"` | `"pill"` | pill: the selected tab sits on a filled pill: the chat header strip, and document tabs (closable: open files, browser tabs). underline: an ink bar under the selected tab on a hairline (the tabs of a panel). |
| `size` | `"xs" \| "sm" \| "md"` | `"md"` | xs 24 · sm 28: dense strips (an editor's file tabs, a browser's tabs), 12px labels, 14px icons; md (default) keeps each variant's height (pill 26, underline 32). Dimensions only. |
| `inHeader` | `boolean` | `false` | pill or underline, for a strip inside a card header (a code block's file tabs, an editor's panel strip). The list fills the header's height (underline tabs stretch to it) and draws no hairline of its own: the header's bottom line is the line, and the underline rests on it. The panel starts at that line, with no top padding: what it holds (code, a toolbar, a terminal) brings its own inset. Its own prop, not a size: the size scale is dimensions only. |
| `headerProps` | `object` |  | Attributes for the header row, so a host can mark it as its own part (code-block: data-code-block="header"). |
| `headerClass` | `string` |  | Wraps the list in the header part with this class added (the host's header row, e.g. a code block's header). |
| `closable` | `boolean` | `false` | Every tab gets a close button and closes on Delete (an item's own `closable` wins): document tabs (open files, browser tabs). A closable tab's title is free text: it stops at 240px and is cut at its end, keeping its full text in the title. The Tabs never remove a tab themselves: they select the neighbour and emit close; the caller removes the item. A closable tab added after the first paint opens its room; one closed by the pointer closes it first. |
| `closeLabel` | `string` | `"Close"` | Verb of a close button's name, followed by the tab's text ("Close rate-limit.ts"). |
| `labels` | `object` |  | The strings, for translation: allTabs (default "All tabs"), the name and tooltip of the button that lists every tab while the strip overflows. |
| `fill` | `boolean` | `false` | The root takes the height of its container and the selected panel the rest (an editor's bottom panel, a pane). A variant, so hosts never reach into the panel with selectors. |
| `aria-label` | `string` |  | Name of the tab list. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `valueChange` | (value: string) |
| `close` | (value: string) when a closable tab asks to close (its button, or Delete / Backspace on it). If it was selected, valueChange has already moved the selection to the next enabled tab, else the previous. Closed by the pointer: emitted once the tab's room has closed (duration.reveal later); from the keyboard and under reduced motion at once. |

## Slots

| Slot | Content |
| --- | --- |
| `panel` | Content of a panel (Vue slot / Svelte snippet, called with the item). In React an item's `content` may be a node. |
| `end` | Parts after the list inside the header part (a path, a copy button); implies the header part. |

## States

`selected`, `hover`, `press`, `focus-visible`, `disabled`, `closable`, `close-hover`, `close-press`, `fill`, `overflow`

## Keyboard and accessibility

Role: tablist + tab + tabpanel.

Keyboard:

- Tab reaches the selected tab; the list is one tab stop, the next Tab goes to the panel
- ArrowRight / ArrowLeft move to the next / previous enabled tab and select it (selection follows focus); they wrap
- Home / End move to the first / last enabled tab and select it
- Delete (and Backspace, the key macOS labels delete) closes the focused closable tab; focus and selection move to the next enabled tab, else the previous. The browser keeps Ctrl/⌘ W, so the platform's own close shortcut cannot be taken by a web page
- While the strip overflows, the all-tabs button is the next Tab stop after the list: Enter, Space or ArrowDown open its menu (the Menu's keys); Enter on a tab selects it, closes the menu and moves focus to that tab, where the arrow keys and Delete work as after any selection

Notes:

- Give the list an aria-label when nothing else names it.
- A selection made from the keyboard moves the indicator instantly; the slide is for the pointer. Panels never animate.
- A truncated label keeps its full text in the title; the accessible name is the full text either way.
- To select from outside, control `value`: React value / onValueChange, Vue v-model:value, Svelte bind:value.
- A closable trigger carries aria-keyshortcuts="Delete"; its close button is not a tab stop (the Tab key meets only tabs) but it is not hidden: it is named "Close <tab>" (closeLabel + the tab's text), so a screen reader's cursor and touch exploration (VoiceOver, TalkBack) reach and press it; Delete keeps working on the focused tab.
- When the selected tab moves out of a scrolling strip it is scrolled back into view: instantly after a key, smoothly after a click.
- An item's icon is decoration (aria-hidden; a favicon is an <img alt="">): the label is the tab's name.
- The all-tabs button appears only while some tabs are out of view; it is named (labels.allTabs) and shows the same name as a tooltip. Its menu is a radio group, so the selected tab is announced as checked.

## Motion

- indicator: transform and width over duration.move with easing.move, only for a pointer selection; no slide on mount, none on resize, instant under the keyboard; on the selected tab from the first paint (the adapters place it before the engine measures; until then the selected tab paints the same pill itself and hands over at once)
- tab label: colour over duration.base, ease: ink-2 at rest, ink on hover, ink when selected (both variants; no opacity); instant under the keyboard
- press: the tab scales to motion.press-scale over duration.press
- panel: swaps instantly
- close button: fades in on hover of its tab (opacity over duration.fast); background over duration.fast; press scales to motion.press-scale from the pointer only
- strip scroll: smooth to the selected tab after a pointer selection, instant after a key or under reduced motion
- closing: from the keyboard, instant (the tab goes, its neighbours close the gap in one frame, the indicator lands on the neighbour). From the pointer, the tab's room closes (width, min-width and inline padding to 0, and underline's gap after it, over duration.reveal, easing.out-strong) while it fades (opacity over duration.base) and takes no presses; close is emitted when the room has closed (duration.reveal later; at once under reduced motion). The selection and focus move to the neighbour at once
- arrival (closable tabs): a tab added after the first paint opens its room from 0 (width, min-width, inline padding, and underline's gap after it, over duration.reveal, easing.out-strong) while it fades in over duration.base, so the tabs after it and the parts after the strip move instead of jumping; the indicator measures the trigger and lands on the selected tab; nothing plays on the first paint (the adapters set ready two frames after mount); instant when the keyboard was last used; under reduced motion only the fade. The width is auto and moves through interpolate-size: in browsers without it the tab appears at once
- edge fades: none of their own; the mask follows the scroll position at once (no transition), and the all-tabs button appears and goes without motion when the strip starts or stops overflowing

## Tokens

`color.field`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.line`, `text.sm`, `duration.press`, `duration.move`, `easing.move`, `easing.out-strong`, `motion.press-scale`, `duration.base`, `radius.chip`, `color.accent`, `color.hover`, `duration.fast`, `text.xs`, `duration.reveal`

## Dependencies

- [Button](/components/button.md)
- [Menu](/components/menu.md)
- [Tooltip](/components/tooltip.md)

## Examples

### Sections of a project page

React · `project-sections.tsx`

```tsx
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const items: TabsItem[] = [
  { value: "overview", label: "Overview", content: "web-app is live on Production. Last deploy 2 min ago by Maya Chen." },
  { value: "deploys", label: "Deploys", content: "24 deploys in the last 7 days, 1 failed on feat/usage-alerts." },
  { value: "settings", label: "Settings", content: "Build command, environment variables and domains." },
];

export default function ProjectSections() {
  return <Tabs className="w-80" items={items} defaultValue="overview" variant="underline" aria-label="web-app" />;
}
```

Vue · `project-sections.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const items: TabsItem[] = [
  { value: "overview", label: "Overview", content: "web-app is live on Production. Last deploy 2 min ago by Maya Chen." },
  { value: "deploys", label: "Deploys", content: "24 deploys in the last 7 days, 1 failed on feat/usage-alerts." },
  { value: "settings", label: "Settings", content: "Build command, environment variables and domains." },
];

const value = ref("overview");
</script>

<template>
  <Tabs v-model:value="value" class="w-80" :items="items" variant="underline" aria-label="web-app" />
</template>
```

Svelte · `project-sections.svelte`

```svelte
<script lang="ts">
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  const items: TabsItem[] = [
    { value: "overview", label: "Overview", content: "web-app is live on Production. Last deploy 2 min ago by Maya Chen." },
    { value: "deploys", label: "Deploys", content: "24 deploys in the last 7 days, 1 failed on feat/usage-alerts." },
    { value: "settings", label: "Settings", content: "Build command, environment variables and domains." },
  ];

  let value = $state("overview");
</script>

<Tabs bind:value class="w-80" {items} variant="underline" aria-label="web-app" />
```

### Switch the log in a card

React · `log-source.tsx`

```tsx
import { Tabs, type TabsItem } from "@/components/ui/tabs";

/* pill tabs switch what one card shows: here, which log */
const items: TabsItem[] = [
  { value: "build", label: "Build", content: "10:42:48 Build finished in 47s. 312 files, 4.1 MB." },
  { value: "runtime", label: "Runtime", content: "10:51:03 POST /api/webhooks 200 in 84 ms" },
  { value: "edge", label: "Edge", content: "Cache hit rate 92.4% across 3 regions." },
];

export default function LogSource() {
  return <Tabs className="w-80" items={items} defaultValue="build" aria-label="Logs" />;
}
```

Vue · `log-source.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

/* pill tabs switch what one card shows: here, which log */
const items: TabsItem[] = [
  { value: "build", label: "Build", content: "10:42:48 Build finished in 47s. 312 files, 4.1 MB." },
  { value: "runtime", label: "Runtime", content: "10:51:03 POST /api/webhooks 200 in 84 ms" },
  { value: "edge", label: "Edge", content: "Cache hit rate 92.4% across 3 regions." },
];

const value = ref("build");
</script>

<template>
  <Tabs v-model:value="value" class="w-80" :items="items" aria-label="Logs" />
</template>
```

Svelte · `log-source.svelte`

```svelte
<script lang="ts">
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  /* pill tabs switch what one card shows: here, which log */
  const items: TabsItem[] = [
    { value: "build", label: "Build", content: "10:42:48 Build finished in 47s. 312 files, 4.1 MB." },
    { value: "runtime", label: "Runtime", content: "10:51:03 POST /api/webhooks 200 in 84 ms" },
    { value: "edge", label: "Edge", content: "Cache hit rate 92.4% across 3 regions." },
  ];

  let value = $state("build");
</script>

<Tabs bind:value class="w-80" {items} aria-label="Logs" />
```

### An action at the end of the row

React · `with-action.tsx`

```tsx
import { Plus } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const items: TabsItem[] = [
  { value: "variables", label: "Variables", content: "12 variables: 8 in every environment, 4 in Production only." },
  { value: "domains", label: "Domains", content: "app.northwind.example and 2 preview domains." },
];

/* `end` sits at the far end of the tab row: the action for the section */
export default function WithAction() {
  return (
    <Tabs
      className="w-80"
      items={items}
      defaultValue="variables"
      aria-label="Environment"
      end={<Button size="sm" variant="ghost" className="ms-auto" icon={<Plus data-slot="icon" weight="bold" />}>Add</Button>}
    />
  );
}
```

Vue · `with-action.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PhPlus } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const items: TabsItem[] = [
  { value: "variables", label: "Variables", content: "12 variables: 8 in every environment, 4 in Production only." },
  { value: "domains", label: "Domains", content: "app.northwind.example and 2 preview domains." },
];

const value = ref("variables");
</script>

<!-- the end slot sits at the far end of the tab row: the action for the section -->
<template>
  <Tabs v-model:value="value" class="w-80" :items="items" aria-label="Environment">
    <template #end>
      <Button size="sm" variant="ghost" class="ms-auto">
        <template #icon><PhPlus data-slot="icon" weight="bold" /></template>
        Add
      </Button>
    </template>
  </Tabs>
</template>
```

Svelte · `with-action.svelte`

```svelte
<script lang="ts">
  import Plus from "phosphor-svelte/lib/PlusIcon";
  import { Button } from "$lib/components/ui/button";
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  const items: TabsItem[] = [
    { value: "variables", label: "Variables", content: "12 variables: 8 in every environment, 4 in Production only." },
    { value: "domains", label: "Domains", content: "app.northwind.example and 2 preview domains." },
  ];

  let value = $state("variables");
</script>

<!-- the end snippet sits at the far end of the tab row: the action for the section -->
<Tabs bind:value class="w-80" {items} aria-label="Environment">
  {#snippet end()}
    <Button size="sm" variant="ghost" class="ms-auto">
      {#snippet icon()}<Plus data-slot="icon" weight="bold" />{/snippet}
      Add
    </Button>
  {/snippet}
</Tabs>
```

### A tab not on your plan

React · `plan-locked.tsx`

```tsx
import { Tabs, type TabsItem } from "@/components/ui/tabs";

/* Analytics is on the Business plan: the tab stays in its place, disabled */
const items: TabsItem[] = [
  { value: "usage", label: "Usage", content: "1.2 M requests and 38 GB of bandwidth this month." },
  { value: "analytics", label: "Analytics", content: "Visitors, pages and referrers.", disabled: true },
  { value: "invoices", label: "Invoices", content: "INV-2024-0117 · $1,240.00 · Paid Nov 1, 2026" },
];

export default function PlanLocked() {
  return <Tabs className="w-80" items={items} defaultValue="usage" variant="underline" aria-label="Billing" />;
}
```

Vue · `plan-locked.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

/* Analytics is on the Business plan: the tab stays in its place, disabled */
const items: TabsItem[] = [
  { value: "usage", label: "Usage", content: "1.2 M requests and 38 GB of bandwidth this month." },
  { value: "analytics", label: "Analytics", content: "Visitors, pages and referrers.", disabled: true },
  { value: "invoices", label: "Invoices", content: "INV-2024-0117 · $1,240.00 · Paid Nov 1, 2026" },
];

const value = ref("usage");
</script>

<template>
  <Tabs v-model:value="value" class="w-80" :items="items" variant="underline" aria-label="Billing" />
</template>
```

Svelte · `plan-locked.svelte`

```svelte
<script lang="ts">
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  /* Analytics is on the Business plan: the tab stays in its place, disabled */
  const items: TabsItem[] = [
    { value: "usage", label: "Usage", content: "1.2 M requests and 38 GB of bandwidth this month." },
    { value: "analytics", label: "Analytics", content: "Visitors, pages and referrers.", disabled: true },
    { value: "invoices", label: "Invoices", content: "INV-2024-0117 · $1,240.00 · Paid Nov 1, 2026" },
  ];

  let value = $state("usage");
</script>

<Tabs bind:value class="w-80" {items} variant="underline" aria-label="Billing" />
```

### Open files you can close

React · `open-files.tsx`

```tsx
import { File } from "@phosphor-icons/react";
import { useState } from "react";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const files: TabsItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", icon: <File data-slot="icon" />, content: "src/middleware/rate-limit.ts · 84 lines · modified" },
  { value: "src/routes/invoices.ts", label: "invoices.ts", icon: <File data-slot="icon" />, content: "src/routes/invoices.ts · 212 lines" },
  { value: "test/rate-limit.test.ts", label: "rate-limit.test.ts", icon: <File data-slot="icon" />, content: "test/rate-limit.test.ts · 3 failing tests" },
  { value: "src/webhooks/deliver.ts", label: "deliver.ts", icon: <File data-slot="icon" />, content: "src/webhooks/deliver.ts · retry added in #482" },
  { value: "package.json", label: "package.json", icon: <File data-slot="icon" />, content: "package.json · billing-api 2.14.0" },
];

/* open files: closable pill tabs with file icons. The close button, or Delete on the focused tab;
 * the strip scrolls and keeps the selected file in view. Removing the item is yours: the neighbour
 * is already selected */
export default function OpenFiles() {
  const [open, setOpen] = useState(files);
  const [active, setActive] = useState(files[0]!.value);
  if (!open.length) return <p className="w-80 text-sm text-ink-2">No open files</p>;
  return (
    <Tabs
      className="w-80"
      size="sm"
      closable
      items={open}
      value={active}
      onValueChange={setActive}
      onClose={(path) => setOpen((tabs) => tabs.filter((tab) => tab.value !== path))}
      aria-label="Open files"
    />
  );
}
```

Vue · `open-files.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PhFile } from "@phosphor-icons/vue";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const files: TabsItem[] = [
  { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", icon: PhFile, content: "src/middleware/rate-limit.ts · 84 lines · modified" },
  { value: "src/routes/invoices.ts", label: "invoices.ts", icon: PhFile, content: "src/routes/invoices.ts · 212 lines" },
  { value: "test/rate-limit.test.ts", label: "rate-limit.test.ts", icon: PhFile, content: "test/rate-limit.test.ts · 3 failing tests" },
  { value: "src/webhooks/deliver.ts", label: "deliver.ts", icon: PhFile, content: "src/webhooks/deliver.ts · retry added in #482" },
  { value: "package.json", label: "package.json", icon: PhFile, content: "package.json · billing-api 2.14.0" },
];

const open = ref(files);
const active = ref(files[0]!.value);
</script>

<!-- open files: closable pill tabs with file icons. The close button, or Delete on the focused tab;
     the strip scrolls and keeps the selected file in view. Removing the item is yours: the neighbour
     is already selected -->
<template>
  <p v-if="!open.length" class="w-80 text-sm text-ink-2">No open files</p>
  <Tabs
    v-else
    v-model:value="active"
    class="w-80"
    size="sm"
    closable
    :items="open"
    aria-label="Open files"
    @close="(path) => (open = open.filter((tab) => tab.value !== path))"
  />
</template>
```

Svelte · `open-files.svelte`

```svelte
<script lang="ts">
  import File from "phosphor-svelte/lib/FileIcon";
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  const files: TabsItem[] = [
    { value: "src/middleware/rate-limit.ts", label: "rate-limit.ts", icon: File, content: "src/middleware/rate-limit.ts · 84 lines · modified" },
    { value: "src/routes/invoices.ts", label: "invoices.ts", icon: File, content: "src/routes/invoices.ts · 212 lines" },
    { value: "test/rate-limit.test.ts", label: "rate-limit.test.ts", icon: File, content: "test/rate-limit.test.ts · 3 failing tests" },
    { value: "src/webhooks/deliver.ts", label: "deliver.ts", icon: File, content: "src/webhooks/deliver.ts · retry added in #482" },
    { value: "package.json", label: "package.json", icon: File, content: "package.json · billing-api 2.14.0" },
  ];

  let open = $state(files);
  let active = $state(files[0]!.value);
</script>

<!-- open files: closable pill tabs with file icons. The close button, or Delete on the focused tab;
     the strip scrolls and keeps the selected file in view. Removing the item is yours: the neighbour
     is already selected -->
{#if !open.length}
  <p class="w-80 text-sm text-ink-2">No open files</p>
{:else}
  <Tabs
    bind:value={active}
    class="w-80"
    size="sm"
    closable
    items={open}
    aria-label="Open files"
    onclose={(path) => (open = open.filter((tab) => tab.value !== path))}
  />
{/if}
```

### Browser tabs with a new-tab button

React · `browser-tabs.tsx`

```tsx
import { useRef, useState } from "react";
import { GitBranch, Globe, Plus, Terminal } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Tabs, type TabsItem } from "@/components/ui/tabs";
import { Tooltip } from "@/components/ui/tooltip";

const page = (text: string) => <p className="py-2.5 text-sm text-ink-2">{text}</p>;
const pages: TabsItem[] = [
  { value: "deploys", label: "Deploys · web-app", icon: <Terminal data-slot="icon" />, content: page("dpl_7f3a9c is live on Production.") },
  { value: "pr-482", label: "#482 Add retry to webhook delivery", icon: <GitBranch data-slot="icon" />, content: page("2 approvals, checks passing.") },
  { value: "status", label: "Status · Northwind", icon: <Globe data-slot="icon" />, content: page("All systems operational.") },
];

/* browser tabs: closable pill tabs, each with its page's icon. A title stops at 240px, cut with its
 * full text in the title; a new tab opens its room and a closed one gives it back */
export default function BrowserTabs() {
  const [open, setOpen] = useState(pages);
  const [active, setActive] = useState("pr-482");
  const next = useRef(1);
  const add = () => {
    const value = `new-${next.current++}`;
    setOpen((tabs) => [...tabs, { value, label: "New tab", icon: <Globe data-slot="icon" />, content: page("A blank page.") }]);
    setActive(value);
  };
  return (
    <Tabs
      className="w-full max-w-[560px]"
      size="sm"
      closable
      items={open}
      value={active}
      onValueChange={setActive}
      onClose={(value) => setOpen((tabs) => tabs.filter((tab) => tab.value !== value))}
      aria-label="Open tabs"
      end={
        <Tooltip content="New tab">
          <Button variant="ghost" size="xs" square muted aria-label="New tab" icon={<Plus data-slot="icon" weight="bold" />} onClick={add} />
        </Tooltip>
      }
    />
  );
}
```

Vue · `browser-tabs.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { PhGitBranch, PhGlobe, PhPlus, PhTerminal } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Tabs, type TabsItem } from "@/components/ui/tabs";
import { Tooltip } from "@/components/ui/tooltip";

const pages: TabsItem[] = [
  { value: "deploys", label: "Deploys · web-app", icon: PhTerminal, content: "dpl_7f3a9c is live on Production." },
  { value: "pr-482", label: "#482 Add retry to webhook delivery", icon: PhGitBranch, content: "2 approvals, checks passing." },
  { value: "status", label: "Status · Northwind", icon: PhGlobe, content: "All systems operational." },
];

const open = ref(pages);
const active = ref("pr-482");
let next = 1;
function add() {
  const value = `new-${next++}`;
  open.value = [...open.value, { value, label: "New tab", icon: PhGlobe, content: "A blank page." }];
  active.value = value;
}
</script>

<!-- browser tabs: closable pill tabs, each with its page's icon. A title stops at 240px, cut with its
     full text in the title; a new tab opens its room and a closed one gives it back -->
<template>
  <Tabs
    v-model:value="active"
    class="w-full max-w-[560px]"
    size="sm"
    closable
    :items="open"
    aria-label="Open tabs"
    @close="(value) => (open = open.filter((tab) => tab.value !== value))"
  >
    <template #panel="{ item }"><p class="py-2.5 text-sm text-ink-2">{{ item.content }}</p></template>
    <template #end>
      <Tooltip content="New tab">
        <Button variant="ghost" size="xs" square muted aria-label="New tab" @click="add">
          <template #icon><PhPlus data-slot="icon" weight="bold" /></template>
        </Button>
      </Tooltip>
    </template>
  </Tabs>
</template>
```

Svelte · `browser-tabs.svelte`

```svelte
<script lang="ts">
  import GitBranch from "phosphor-svelte/lib/GitBranchIcon";
  import Globe from "phosphor-svelte/lib/GlobeIcon";
  import Plus from "phosphor-svelte/lib/PlusIcon";
  import Terminal from "phosphor-svelte/lib/TerminalIcon";
  import { Button } from "$lib/components/ui/button";
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";
  import { Tooltip } from "$lib/components/ui/tooltip";

  const pages: TabsItem[] = [
    { value: "deploys", label: "Deploys · web-app", icon: Terminal, content: "dpl_7f3a9c is live on Production." },
    { value: "pr-482", label: "#482 Add retry to webhook delivery", icon: GitBranch, content: "2 approvals, checks passing." },
    { value: "status", label: "Status · Northwind", icon: Globe, content: "All systems operational." },
  ];

  let open = $state(pages);
  let active = $state("pr-482");
  let next = 1;
  function add() {
    const value = `new-${next++}`;
    open = [...open, { value, label: "New tab", icon: Globe, content: "A blank page." }];
    active = value;
  }
</script>

<!-- browser tabs: closable pill tabs, each with its page's icon. A title stops at 240px, cut with its
     full text in the title; a new tab opens its room and a closed one gives it back -->
<Tabs
  bind:value={active}
  class="w-full max-w-[560px]"
  size="sm"
  closable
  items={open}
  aria-label="Open tabs"
  onclose={(value) => (open = open.filter((tab) => tab.value !== value))}
>
  {#snippet panel({ item })}<p class="py-2.5 text-sm text-ink-2">{item.content}</p>{/snippet}
  {#snippet end()}
    <Tooltip content="New tab">
      {#snippet trigger(tipProps)}
        <Button {...tipProps()} variant="ghost" size="xs" square muted aria-label="New tab" onclick={add}>
          {#snippet icon()}<Plus data-slot="icon" weight="bold" />{/snippet}
        </Button>
      {/snippet}
    </Tooltip>
  {/snippet}
</Tabs>
```

### Logs that fill their pane

React · `deploy-panel.tsx`

```tsx
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const build = [
  "10:42:01 Cloning github.com/northwind/web-app (main, a1b2c3d)",
  "10:42:03 Restored build cache from dpl_6e21b0",
  "10:42:05 Installing dependencies with pnpm 9.12",
  "10:42:19 Dependencies installed in 14s",
  "10:42:20 Running build: next build",
  "10:42:44 Compiled 312 files in 24s",
  "10:42:46 Uploading 4.1 MB to the edge network",
  "10:42:48 Build finished in 47s",
];
const runtime = [
  "10:51:03 POST /api/webhooks 200 in 84 ms",
  "10:51:09 GET /api/invoices?page=2 200 in 41 ms",
  "10:51:12 POST /api/webhooks 502 in 3,012 ms (retry 1 of 3)",
  "10:51:15 POST /api/webhooks 200 in 96 ms",
];

const log = (lines: string[]) => (
  <pre className="font-mono text-xs leading-5">{lines.map((line) => <div key={line}>{line}</div>)}</pre>
);

const items: TabsItem[] = [
  { value: "build", label: "Build", content: log(build) },
  { value: "runtime", label: "Runtime", content: log(runtime) },
];

/* fill: the tabs take the height of their pane and the log scrolls inside the panel */
export default function DeployPanel() {
  return (
    <div className="h-44 w-80">
      <Tabs fill variant="underline" items={items} defaultValue="build" aria-label="dpl_7f3a9c logs" />
    </div>
  );
}
```

Vue · `deploy-panel.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Tabs, type TabsItem } from "@/components/ui/tabs";

const logs: Record<string, string[]> = {
  build: [
    "10:42:01 Cloning github.com/northwind/web-app (main, a1b2c3d)",
    "10:42:03 Restored build cache from dpl_6e21b0",
    "10:42:05 Installing dependencies with pnpm 9.12",
    "10:42:19 Dependencies installed in 14s",
    "10:42:20 Running build: next build",
    "10:42:44 Compiled 312 files in 24s",
    "10:42:46 Uploading 4.1 MB to the edge network",
    "10:42:48 Build finished in 47s",
  ],
  runtime: [
    "10:51:03 POST /api/webhooks 200 in 84 ms",
    "10:51:09 GET /api/invoices?page=2 200 in 41 ms",
    "10:51:12 POST /api/webhooks 502 in 3,012 ms (retry 1 of 3)",
    "10:51:15 POST /api/webhooks 200 in 96 ms",
  ],
};

const items: TabsItem[] = [
  { value: "build", label: "Build" },
  { value: "runtime", label: "Runtime" },
];

const value = ref("build");
</script>

<!-- fill: the tabs take the height of their pane and the log scrolls inside the panel -->
<template>
  <div class="h-44 w-80">
    <Tabs v-model:value="value" fill variant="underline" :items="items" aria-label="dpl_7f3a9c logs">
      <template #panel="{ item }">
        <pre class="font-mono text-xs leading-5"><div v-for="line in logs[item.value]" :key="line">{{ line }}</div></pre>
      </template>
    </Tabs>
  </div>
</template>
```

Svelte · `deploy-panel.svelte`

```svelte
<script lang="ts">
  import { Tabs, type TabsItem } from "$lib/components/ui/tabs";

  const logs: Record<string, string[]> = {
    build: [
      "10:42:01 Cloning github.com/northwind/web-app (main, a1b2c3d)",
      "10:42:03 Restored build cache from dpl_6e21b0",
      "10:42:05 Installing dependencies with pnpm 9.12",
      "10:42:19 Dependencies installed in 14s",
      "10:42:20 Running build: next build",
      "10:42:44 Compiled 312 files in 24s",
      "10:42:46 Uploading 4.1 MB to the edge network",
      "10:42:48 Build finished in 47s",
    ],
    runtime: [
      "10:51:03 POST /api/webhooks 200 in 84 ms",
      "10:51:09 GET /api/invoices?page=2 200 in 41 ms",
      "10:51:12 POST /api/webhooks 502 in 3,012 ms (retry 1 of 3)",
      "10:51:15 POST /api/webhooks 200 in 96 ms",
    ],
  };

  const items: TabsItem[] = [
    { value: "build", label: "Build" },
    { value: "runtime", label: "Runtime" },
  ];

  let value = $state("build");
</script>

<!-- fill: the tabs take the height of their pane and the log scrolls inside the panel -->
<div class="h-44 w-80">
  <Tabs bind:value fill variant="underline" {items} aria-label="dpl_7f3a9c logs">
    {#snippet panel({ item })}
      <pre class="font-mono text-xs leading-5">{#each logs[item.value] ?? [] as line (line)}<div>{line}</div>{/each}</pre>
    {/snippet}
  </Tabs>
</div>
```

## Recipe

`tabs.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* tabs — tab strip + panels on the Zag tabs machine.
 *   pill (default)  13px labels, 26px tabs; the selected tab sits on a filled pill (the chat header strip)
 *                   whose radius is the chip token
 *   underline       13px labels, 32px tabs on a hairline; an ink bar under the selected tab
 *   size            xs 24 · sm 28 · md (default) — dimensions only; md keeps each variant's height
 *                   (pill 26, underline 32)
 *   inHeader        pill or underline inside a card header: fills the header's height, no hairline
 *                   (its own prop: the size scale is dimensions only)
 *   closable        a closable tab is wrapped in the tab part with its close part beside the
 *                   trigger (a button cannot hold a button): the trigger keeps room at its end and
 *                   the close button is pulled back over it, so the indicator, which measures the
 *                   trigger, covers both. The wrapper is not positioned: the trigger's offset box
 *                   stays relative to the list, which the engine and placeIndicator measure
 *   fill            the root fills its container's height and the selected panel takes the rest
 *   document tabs   closable tabs are documents (open files, browser tabs): a title is free text, so
 *                   a closable tab's label stops at 240px and is cut at its end (with its title);
 *                   a tab that is not closable names a view and is never cut
 *   arrivals        closable tabs (house rule "arrivals and removals make room"): a tab added after
 *                   the first paint (`ready`, set by the adapter after mount) opens its width from 0
 *                   over duration.reveal while it fades in over duration.base; a tab closed by the
 *                   pointer (`closing`) closes its width to 0 the same way, and the adapter calls
 *                   onClose when it has. From the keyboard both are instant (kbd-instant; the adapter
 *                   closes at once); under reduced motion duration.reveal is 0, so the width jumps
 *                   and only the fade is left. Width, min-width and inline padding move (a tab's
 *                   room is its width: no transform can open it); the width is auto, so it moves
 *                   through interpolate-size (Chromium; elsewhere the tab appears at once). The
 *                   indicator measures the trigger, so it rides along and lands on the selected tab
 *   overflow        every variant: a strip with more tabs than room scrolls sideways (no scrollbar),
 *                   fades each edge it continues past and shows the all-tabs button after the list.
 *                   watchStrip (tabs.logic.ts) measures it: data-overflow on the list while the tabs
 *                   are wider than it (never on a list with no box), data-overflow-start and
 *                   data-overflow-end from the scroll position. The fade is a 24px mask on the list,
 *                   the room revealTab keeps clear of each edge; it follows the scroll, with no time
 *                   of its own. The adapters render the button (the more part: a Menu whose trigger is
 *                   the real Button, ghost, muted, square) only while data-overflow holds
 *
 * Everything is here, motion included. The indicator is the engine's: it measures the selected tab
 * and travels on transform only while a selection is being made (the engine sets transition-property
 * from --transition-property then), so it does not slide in on mount or when fonts load. Keyboard
 * selections are instant (kbd-instant). Panels swap instantly. Parts are found by data-slot
 * (tabs, tabs-header, tabs-list, tabs-indicator, tabs-trigger, tabs-label, tabs-content); the root
 * slot is `base`. The all-tabs menu is marked data-tabs="more", its button data-tabs="more-trigger".
 *
 * The root is a grid of two columns, the list and the all-tabs button side by side on the first row
 * (when there is no header part to hold them), and every other part across both: the header, and
 * the selected panel on the second row. Its rows are as tall as their content, packed at the top
 * (a panel keeps its content's height in a taller root); with fill the panel's row takes the
 * height the strip leaves. */

/* until the indicator is measured the selected tab paints itself exactly like the indicator, so the
 * hand-over is invisible (written whole below: a class built from pieces is never generated). The
 * adapters also place the indicator before the first paint (tabs.logic.ts placeIndicator). */

export const tabs = tv({
  slots: {
    base: "grid grid-cols-[minmax(0,1fr)_auto] content-start min-w-0 max-w-full *:col-span-full",
    /* the host's header row, when the list is wrapped in it */
    header: "flex items-center min-w-0",
    list: [
      "relative flex items-center min-w-0 overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden [[data-slot=tabs]>&]:col-span-1",
      /* a tab's width can open from 0 to auto (arrivals) and close back */
      "[interpolate-size:allow-keywords]",
      /* overflowing, each edge the strip continues past fades out over 24px (a mask: the strip has
       * no colour of its own to fade into); logical, so right-to-left swaps the ends */
      "[--_fade:linear-gradient(to_var(--_end,right),transparent,#000_var(--_fade-start,0px),#000_calc(100%_-_var(--_fade-end,0px)),transparent)] [&:dir(rtl)]:[--_end:left]",
      "data-overflow-start:[--_fade-start:24px] data-overflow-end:[--_fade-end:24px]",
      "data-overflow-start:[mask-image:var(--_fade)] data-overflow-end:[mask-image:var(--_fade)]",
    ],
    /* the all-tabs menu (the Menu's root) after the list, holding its button; centred on the strip */
    more: "flex shrink-0 items-center self-stretch [[data-slot=tabs]>&]:col-span-1",
    /* the all-tabs button (the real Button, ghost, muted, square) */
    moreTrigger: "",
    /* a closable tab: the trigger and its close button side by side (never positioned, see above) */
    tab: "group/tab flex shrink-0 items-center min-w-0 max-w-full",
    /* the engine's indicator: left is the engine's inline `left: var(--left)`, overridden (offsets
     * are physical, also right-to-left, and travel on transform) */
    indicator: [
      "kbd-instant",
      "absolute top-0 [left:0]! z-0 w-(--width) h-(--height) rounded-chip bg-field pointer-events-none",
      "[transform:translate(var(--left,0px),var(--top,0px))]",
      /* fndn-check-ok: width — the indicator is absolutely positioned and childless, and scaleX would distort its radius */
      "[--transition-property:transform,width]! [--transition-duration:var(--fndn-duration-move)] [--transition-timing-function:var(--fndn-easing-move)]",
    ],
    trigger: [
      "relative z-1 inline-flex items-center justify-center gap-1.5 shrink-0 min-w-0 max-w-full h-[26px] px-2",
      "rounded-chip text-sm leading-none whitespace-nowrap text-ink-2",
      /* hover is a colour, like every single-choice strip: ink-2 → ink, selected ink */
      "hover:text-ink aria-selected:text-ink",
      "disabled:opacity-50 disabled:cursor-default disabled:pointer-events-none",
      "data-disabled:opacity-50 data-disabled:cursor-default data-disabled:pointer-events-none",
      "[[data-slot=tabs-indicator][hidden]~&]:aria-selected:bg-field [[data-slot=tabs-indicator][hidden]~*>&]:aria-selected:bg-field",
      /* the selected tab's own background is only ever the stand-in: it hands over to the indicator
       * at once (no fade when the engine un-hides it after a first frame); its label colour still
       * transitions as motion-colors-base does */
      "aria-selected:[--fndn-m-colors:color_var(--fndn-duration-base)_ease]",
      "kbd-instant motion-colors-base motion-transform-press active:scale-press",
    ],
    /* the close button of a closable tab: a 16px square pulled back over the trigger's end room,
     * above the trigger. Shown on the selected tab and while the tab is hovered (always on touch);
     * at rest it keeps its room, so the strip never reflows. Not a tab stop: Delete closes the
     * focused tab. Press scales from the pointer only */
    close: [
      "relative z-2 inline-flex shrink-0 items-center justify-center size-4 rounded-[4px] text-[11px] text-ink-3",
      "opacity-0 group-hover/tab:opacity-100 [[aria-selected=true]+&]:opacity-100 pointer-coarse:opacity-100",
      "hover:bg-hover hover:text-ink",
      "[:root:not([data-fndn-input=keyboard])_&:active]:scale-press",
      "motion-colors-fast motion-opacity-fast motion-transform-press",
      /* a 24px target around the 16px glyph box */
      "after:content-[''] after:absolute after:-inset-1",
    ],
    /* an item's icon before its label: a file icon (Phosphor) or a favicon (an image) */
    icon: "inline-flex shrink-0 items-center justify-center size-4 text-[16px] leading-none [&>img]:size-full [&>img]:rounded-[3px] [&>img]:object-contain",
    /* one line that truncates at the end of its own text; the adapters give it a title. The 2px
     * block padding, taken back by the margin, keeps descenders inside the clip */
    label: "block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap [unicode-bidi:plaintext] -my-0.5 py-0.5",
    /* panels: no motion, the content just swaps */
    content: "min-w-0 pt-3 text-sm leading-normal text-ink-2 wrap-anywhere",
  },
  variants: {
    variant: {
      pill: { close: "-ms-5 me-1", more: "[[data-slot=tabs]>&]:ps-1" },
      underline: {
        /* the list clips: 4px of inline padding, taken back by the margin, give the ring room at the
         * ends (a list that is the root's child; one in the header part keeps its edges) */
        list: "gap-4 [[data-slot=tabs]>&]:px-1 [[data-slot=tabs]>&]:-mx-1",
        more: "[[data-slot=tabs]>&]:ps-1",
        close: "-ms-4",
        indicator: "top-auto bottom-0 h-0.5 rounded-[1px] bg-ink [transform:translateX(var(--left,0px))]",
        /* the usual ring (outside the tab) would be cut off by the list: it is drawn 4px inside the
         * tab's height (clear of the bar) and 2px outside its text */
        trigger: [
          "h-8 px-0 rounded-none focus-visible:outline-none",
          "focus-visible:after:content-[''] focus-visible:after:absolute focus-visible:after:inset-y-1 focus-visible:after:-inset-x-0.5",
          "focus-visible:after:rounded-chip focus-visible:after:outline-2 focus-visible:after:outline-solid focus-visible:after:outline-accent focus-visible:after:pointer-events-none",
          "[[data-slot=tabs-indicator][hidden]~&]:aria-selected:bg-transparent [[data-slot=tabs-indicator][hidden]~&]:aria-selected:shadow-[inset_0_-2px_0_var(--fndn-ink)]",
          "[[data-slot=tabs-indicator][hidden]~*>&]:aria-selected:bg-transparent [[data-slot=tabs-indicator][hidden]~*>&]:aria-selected:shadow-[inset_0_-2px_0_var(--fndn-ink)]",
        ],
      },
    },
    size: {
      xs: { trigger: "text-xs", icon: "size-3.5 text-[14px]" },
      sm: { trigger: "text-xs", icon: "size-3.5 text-[14px]" },
      md: {},
    },
    /* inside a card header: the strip fills the header's height, with no hairline of its own; a
     * list that is the root's only child fills the root */
    /* (the panel starts at the header's line: what it holds brings its own inset) */
    inHeader: {
      true: { base: "self-stretch", list: "self-stretch [[data-slot=tabs]>&]:flex-[1_0_auto]", content: "pt-0" },
      false: {},
    },
    /* a closable tab is a document: its trigger keeps room at its end for the close button, and its
     * title (free text) stops at 240px, cut at its end */
    closable: { true: { label: "max-w-60" }, false: {} },
    /* set by the adapter after mount: from then on an inserted closable tab opens its room */
    ready: { true: {}, false: {} },
    /* a tab closed by the pointer, while its room closes; the adapter then calls onClose */
    closing: { true: {}, false: {} },
    /* fill: the root takes its container's height; the selected panel takes what the strip leaves
     * and scrolls inside itself (put a ScrollArea in it for the system's scrollbar) */
    fill: {
      true: { base: "h-full min-h-0 grid-rows-[auto_minmax(0,1fr)]", content: "flex-1 min-h-0 overflow-y-auto overscroll-x-contain" },
      false: {},
    },
  },
  compoundVariants: [
    /* the list scrolls, so it clips: 4px of padding, taken back by the margin, keep the focus ring
     * inside it (a list that is the root's child) */
    { variant: "pill", inHeader: false, class: { list: "[[data-slot=tabs]>&]:p-1 [[data-slot=tabs]>&]:-m-1" } },
    /* the hairline: an inset shadow; on a list that is the root's child (which pads its ends) a
     * background on the content box, so it keeps its length */
    {
      variant: "underline",
      inHeader: false,
      class: {
        list: [
          "shadow-[inset_0_-1px_0_var(--fndn-line)] [[data-slot=tabs]>&]:shadow-none",
          "[[data-slot=tabs]>&]:bg-[linear-gradient(var(--fndn-line)_0_0)] [[data-slot=tabs]>&]:bg-bottom [[data-slot=tabs]>&]:bg-[length:100%_1px] [[data-slot=tabs]>&]:bg-no-repeat [[data-slot=tabs]>&]:bg-origin-content [[data-slot=tabs]>&]:bg-clip-content",
          /* the edge fades leave the hairline whole: a second mask layer keeps the bottom pixel */
          "data-overflow-start:[mask-image:var(--_fade),linear-gradient(#000_0_0)] data-overflow-end:[mask-image:var(--_fade),linear-gradient(#000_0_0)]",
          "[mask-size:100%_100%,100%_1px] [mask-position:0_0,0_100%] [mask-repeat:no-repeat]",
        ],
        /* the hairline runs on under the all-tabs button */
        more: "shadow-[inset_0_-1px_0_var(--fndn-line)]",
      },
    },
    /* pill tabs of 20 and 22px: the 24px button keeps to the strip's height (negative block margins) */
    { variant: "pill", size: "xs", class: { moreTrigger: "-my-0.5" } },
    { variant: "pill", size: "sm", class: { moreTrigger: "-my-px" } },
    /* the dense sizes (editors): xs 24 · sm 28; md keeps each variant's own height */
    { variant: "pill", size: "xs", class: { trigger: "h-5 px-1.5" } },
    { variant: "pill", size: "sm", class: { trigger: "h-[22px] px-1.5" } },
    { variant: "underline", size: "xs", class: { trigger: "h-6" } },
    { variant: "underline", size: "sm", class: { trigger: "h-7" } },
    { variant: "underline", size: ["xs", "sm"], class: { list: "gap-3" } },
    /* a closable trigger keeps room at its end for the close button (after the dense sizes, whose
     * inline padding it overrides at the end) */
    { variant: "pill", closable: true, class: { trigger: "pe-6" } },
    { variant: "underline", closable: true, class: { trigger: "pe-5" } },
    /* in a header the underline tabs stretch to the header's height (after the dense heights: it wins) */
    { variant: "underline", inHeader: true, class: { list: "items-stretch", tab: "self-stretch", trigger: "h-auto" } },
    /* arrivals make room: an inserted closable tab (the tab part, which fades, and its trigger) opens
     * from 0; underline also opens the gap before the next tab (its end margin, from -16px).
     * fndn-check-ok: width, min-width, inline padding and margin are a tab's room in the strip; no
     * transform can open it, and they move over duration.reveal (0 under reduced motion: only the
     * fade stays) */
    {
      ready: true,
      class: {
        tab: [
          "kbd-instant starting:w-0 starting:min-w-0 starting:opacity-0",
          "motion-opacity-base motion-also-[width_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong),min-width_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong),margin-inline-end_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong)]",
        ],
      },
    },
    {
      ready: true,
      closable: true,
      class: {
        trigger: [
          "starting:w-0 starting:min-w-0 starting:px-0",
          "motion-also-[width_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong),min-width_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong),padding-inline_var(--fndn-duration-reveal)_var(--fndn-easing-out-strong)]",
        ],
      },
    },
    { variant: "underline", ready: true, class: { tab: "starting:-me-4" } },
    /* departures close their room: the closing tab's width and padding go to 0 and it fades; it takes
     * no more presses. After the closable compounds, so its px-0 wins over their pe-* */
    {
      closing: true,
      class: {
        tab: "w-0 min-w-0 opacity-0 pointer-events-none",
        trigger: "w-0 min-w-0 px-0",
      },
    },
    { variant: "underline", closing: true, class: { tab: "-me-4" } },
  ],
  defaultVariants: { variant: "pill", size: "md", inHeader: false, closable: false, fill: false, ready: false, closing: false },
});

export type TabsRecipeProps = VariantProps<typeof tabs>;
```
