<!-- generated by scripts/gen-docs.mjs from docs/system/content-changes.md. Edit the source and rerun. -->
# Content changes

## Description
Changes what a box shows while the box keeps its size, so nothing around the change moves.

`import { Swap } from "@/components/cobalt/ui/swap"`, source `registry/cobalt/ui/swap.tsx`, status `ready-with-gaps`.
`import { Crossfade } from "@/components/cobalt/ui/crossfade"`, source `registry/cobalt/ui/crossfade.tsx`, status `ready-with-gaps`.
`import { IconSwap } from "@/components/cobalt/ui/icon-swap"`, source `registry/cobalt/ui/icon-swap.tsx`, status `ready-with-gaps`.
`import { TextSwap } from "@/components/cobalt/ui/text-swap"`, source `registry/cobalt/ui/text-swap.tsx`, status `ready-with-gaps`.
Foundation: `hand-rolled (Swap on motion/react AnimatePresence and MotionConfig, Crossfade on motion/react motion.div and MotionConfig, IconSwap and TextSwap on CSS grid stacking and a CSS transition)`. Traps checked: `trap/motion-exit-slower`, `trap/motion-layout-property`, `trap/motion-overshoot`, `trap/motion-ease-in-enter`, `trap/motion-linear`, `trap/motion-blocks-input`, `trap/motion-restart`, `trap/motion-frequent`, `trap/reduced-motion-ignored`, `trap/loading-layout-shift`, `trap/demo-on-timers`, `trap/motion-transition-all`, `trap/weight-shift`, `trap/numbers-shift`, `trap/icon-optical-size`, `trap/icon-optical-align`, `trap/text-measure`.

### Overview
Four parts change what a box shows without changing the box. They share one contract: the box keeps its size while its content changes (D37), so the parent holds a fixed width, and a fixed height or a fixed shape, and nothing around the change moves. Pick by what changes.

| Part | What changes | What you see | Time and curve | Example |
| --- | --- | --- | --- | --- |
| IconSwap | a glyph trades places in a fixed slot | both glyphs stacked; one fades and blurs out as the other fades in | `--t-icon` 250ms on `--curve-in-out` | the eye and the crossed eye on an API key |
| TextSwap | a word or a short status, from a set known up front | every wording stacked in a slot as wide as the longest, or with `fit` as wide as the one on show, for a surface that eases with its words such as a tooltip; the old word gone before the new one can be read; opacity only | out: 70 percent of `--t-pop` on `--curve`; in: `--t-icon` 250ms on `--curve-in-out`, so a glyph and its word land together | Live and Paused on a live chart; Pause and Resume on its button |
| Crossfade | content replaced, many times a day, with no order worth showing | the old content gone at once, the new one fading in where it was; nothing moves | `--t-crossfade` 320ms on `--curve-sheet` | the next paper in a screening queue |
| Swap | content leaving and arriving, with a direction | the old content leaving 8px one way, then, once it is nearly gone, the new arriving from 8px the other way | out: 70 percent of `--t-pop` on `--curve`; in: the settle spring, `--t-settle` 300ms, 42ms later | the name of the next or previous day in a room booking, whose time slots crossfade below it |

1. Is it a glyph? Use IconSwap.
2. Is it one or two words, and do you know every wording now? Use TextSwap.
3. Is it a step forward or back through an ordered sequence, a few times in a session? Use Swap.
4. Anything else, especially content stepped through hundreds of times a day: use Crossfade.

A button that reports its own request is none of these: StateButton moves its label on the settle spring, vertically, inside the box its label sets, with Swap's handover.

Swap and TextSwap never show two legible copies at once, and StateButton hands its label over the same way; Crossfade removes the old content at once and IconSwap's glyphs blur as they cross. The leaving copy takes the quick exit a popup takes and is under 5 percent opacity 48ms after the change; the arriving copy starts late (Swap, 42ms) or slowly (TextSwap, on `--curve-in-out`). Recorded frame by frame at 16ms with a fake clock, the fainter of two overlapping copies never passed 3 percent, against 15 to 36 percent before (`.design-system/evidence/swap/handover.json`, `.design-system/evidence/text-swap/handover.json`).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Swap. motion `AnimatePresence` with `initial={false}` so the first content ships as it is, and `custom` so the leaving copy takes the latest direction; `MotionConfig` with `reducedMotion="user"` | `direction`, forward or backward, so a Next press and a Previous press read as opposite moves; the old copy out 8px the other way on the quick exit a popup takes, 70 percent of `times.pop` on `curves.out`, at 15 percent opacity 32ms in and under 5 percent by 48ms; the new copy in from 8px (`distances.settle`) on `springs.settle` after a 42ms delay, 40 percent of that exit, so the two are never legible together (the earlier copy started at once and both read for two frames, "ThuFriday", `.design-system/evidence/swap/handover.json`); both copies stacked in one grid cell, so the leaving copy is never lifted out of the flow and cannot drift (the earlier `popLayout` left it where the container had been when a fit-content card resized, measured 154px to 203px wide, `.design-system/evidence/swap/motion2.json`); the leaving copy takes no press; no blur (audit, 16 October 2026); `data-slot="swap"` |
| Crossfade. motion `motion.div` keyed by `id`, so React unmounts the old content and mounts the new one, `initial` and `animate` on opacity only, `MotionConfig` with `reducedMotion="user"` | No `AnimatePresence`, so there is no exit and two contents are never on screen together; the crossfade time, `times.crossfade` on `curves.sheet`, which starts at once and is still visibly fading at 100ms (the plain fade on `curves.out` reached 67 percent opacity on the first frame and read as a cut); `useSyncExternalStore` as a hydration flag so the first content ships visible instead of at opacity 0 waiting for a fade the page cannot run yet; `data-slot="crossfade"` |
| IconSwap. Nothing: CSS grid stacking (`col-start-1 row-start-1`) and a CSS transition | Both glyphs mounted in one `inline-grid` cell, `size-4` by default and sized by `className` and never by the glyphs; the leaving glyph to `blur-(--blur-leave)` and `opacity-0` while the other does the reverse, on `duration-icon` and `ease-in-out`, the time and curve TextSwap uses, so a glyph and its word land together; `aria-hidden` on the glyph not shown; `data-active` for the host's styles; `data-slot="icon-swap"` |
| TextSwap. Nothing: CSS grid stacking (`col-start-1 row-start-1`) and a CSS transition on opacity | Every wording mounted in one `inline-grid` cell, so the slot is as wide as the longest; the shown wording at opacity 1 and the rest at 0, each transition taking the timing of the state it goes to: a leaving wording 70 percent of `--t-pop` on `ease-out`, under 5 percent by 48ms, an arriving one `duration-icon` on `ease-in-out`, the time and curve IconSwap uses, which starts slowly enough that the two are never legible together (the earlier symmetric fade drew both at 36 to 64 percent at 128ms); `show` as the key of the wording or `null` for none; `aria-hidden` on every wording not shown; `data-active` for the host's styles; each wording trimmed to its capitals by base.css, as a button label is, so a word in a button sits on its centre; `data-slot="text-swap"` |

## Examples
The days of a room booking, stepped through with Swap.

Real uses, 0 call sites (`rg -n "<Swap\b|<Crossfade\b|<IconSwap\b|<TextSwap\b" app registry --glob '!registry/cobalt/ui/*'`): the showcase chrome renders none of the four of its own, and the examples folder does not count.

Uses inside the registry, which other components build on:
- CopyButton's copy glyph that becomes a check, an IconSwap, `registry/cobalt/ui/copy-button.tsx:97`. Its tooltip words, Copy command to Copied and back, are a TextSwap with the cap trim turned off (`*:[text-box:normal]`), since a tooltip's line box is its height and the trim made it 16.6px tall instead of 24px, `registry/cobalt/ui/copy-button.tsx:119`.
- SaveToggle's bookmark that fills, an IconSwap, `registry/cobalt/ui/save-toggle.tsx:63`, and its Save and Saved label, a TextSwap, `registry/cobalt/ui/save-toggle.tsx:87`.
- Composer's send glyph, an IconSwap, `registry/cobalt/ui/composer.tsx:1465`.
- The icon button's `icon` slot takes an IconSwap when the glyph changes with the state, `registry/cobalt/ui/icon-button.tsx:31`.
- Swap and Crossfade have no registry use. StateButton moves its own label with the settle spring on the vertical axis and Swap's handover (`registry/cobalt/ui/state-button.tsx`), the same verb as Swap but not a Swap, and changes its words one at a time beside a spinner or a glyph inside the box its label sets, so it needs no TextSwap.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/content-changes/default.tsx` | default | Next day and Previous day move the day's name sideways while its free times fade in place, so a slot never slides under your pointer |
| `docs/system/examples/content-changes/default.tsx` | direction=forward | Next day moves the old day's name out to the left and the new one in from the right |
| `docs/system/examples/content-changes/default.tsx` | direction=backward | Previous day mirrors the move |
| `docs/system/examples/content-changes/default.tsx` | composition:Card | Swap on the day's name and Crossfade on its free times, keyed on the same day, inside a card of fixed width whose height never changes |
| Not applicable: swapping is reached by pressing Next day and lasts about 340ms | state:swap-swapping | The old content fading as it moves 8px away, then the new one arriving 8px from the other side |
| `docs/system/examples/content-changes/crossfade.tsx` | composition:Card | Crossfade, the paper inside a card of fixed width, in a box as tall as the longest paper may be |
| Not applicable: fading is reached by pressing Include or Exclude and lasts 320ms | state:crossfade-fading | The new content alone, from opacity 0 to 1, the old one already gone |
| `docs/system/examples/content-changes/icon-swap.tsx` | show=first | The eye and the copy glyph at rest |
| `docs/system/examples/content-changes/icon-swap.tsx` | show=second | The crossed eye while the key shows, the check for a moment after copying |
| `docs/system/examples/content-changes/icon-swap.tsx` | composition:IconButton | Each glyph in an icon button inside the key's field, whose name says what a press does |
| Not applicable: swapping is reached by pressing either button and lasts 250ms | state:icon-swap-swapping | One glyph fading and blurring out while the other fades in, in the same 16px cell |
| `docs/system/examples/content-changes/text-swap.tsx` | show=key | The count updates every second until you press Pause, and the status and the button's label change in place at the same size |
| Not applicable: no example starts blank; `show={null}` is the stress page's last row | show=null | Every wording at opacity 0, the slot still as wide as the longest |
| `docs/system/examples/content-changes/text-swap.tsx` | composition:Button | The button's label changes from Pause to Resume and the button keeps its width |
| Not applicable: fading is reached by pressing Pause and lasts 250ms | state:text-swap-fading | One wording gone within 48ms, the next fading in after it |
| Not applicable: the two axes belong to different parts, `direction` to Swap and `show` to IconSwap and TextSwap | matrix:direction,show | No part takes both |

Example: Next day and Previous day move the day's name sideways while its free times fade in place, so a slot never slides under your pointer (`docs/system/examples/content-changes/default.tsx`)

```tsx
import { useState } from "react";

import { ChevronLeftIcon, ChevronRightIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { Crossfade } from "@/components/cobalt/ui/crossfade";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { Swap } from "@/components/cobalt/ui/swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";

const times = ["09:00", "10:00", "11:30", "13:00", "14:30", "16:00"];
const first = Date.UTC(2026, 9, 15);
const dayName = new Intl.DateTimeFormat("en-GB", { weekday: "long", day: "numeric", month: "long", timeZone: "UTC" });

// Weekdays only, from Thursday 15 October. Every day has the same six times, so the grid never
// changes height; only what is free does.
function dayAt(index: number) {
  let date = first;
  for (let left = index; left > 0; ) {
    date += 86_400_000;
    if (new Date(date).getUTCDay() % 6 !== 0) left -= 1;
  }
  return {
    id: String(index),
    name: dayName.format(date),
    taken: times.filter((_, t) => (index * 7 + t * 3) % 5 < 2),
  };
}

export default function Example() {
  const [index, setIndex] = useState(0);
  const [direction, setDirection] = useState<"forward" | "backward">("forward");
  const [picked, setPicked] = useState<string | null>(null);
  const day = dayAt(index);
  const step = (by: 1 | -1) => {
    setDirection(by === 1 ? "forward" : "backward");
    setIndex((value) => value + by);
  };
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>Room 4.12</CardTitle>
          <CardDescription>Six seats and a screen</CardDescription>
        </CardHeader>
        <CardContent className="flex flex-col gap-3">
          <div className="flex items-center gap-2">
            <IconButton
              icon={<ChevronLeftIcon />}
              label="Previous day"
              size="icon-sm"
              // Today is the first bookable day. The button keeps focus while it cannot go back further.
              disabled={index === 0}
              focusableWhenDisabled
              onClick={() => step(-1)}
            />
            <div className="min-w-0 flex-1 overflow-hidden text-center text-sm font-medium">
              <Swap id={day.id} direction={direction}>
                <span className="block truncate">{day.name}</span>
              </Swap>
            </div>
            <IconButton
              icon={<ChevronRightIcon />}
              label="Next day"
              size="icon-sm"
              onClick={() => step(1)}
            />
          </div>
          {/* The slots are targets: sliding them 8px would move one out from under a resting pointer,
              so they fade in place, keyed on the same day, and only the name says which way you went. */}
          <Crossfade id={day.id} className="grid grid-cols-3 gap-2">
            {times.map((time) => {
              const key = `${day.id} ${time}`;
              const taken = day.taken.includes(time);
              return (
                <Button
                  key={time}
                  size="sm"
                  variant={picked === key ? "default" : "secondary"}
                  aria-pressed={picked === key}
                  disabled={taken}
                  className="tabular-nums"
                  onClick={() => setPicked(key)}
                >
                  {time}
                </Button>
              );
            })}
          </Crossfade>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: Swap on the day's name and Crossfade on its free times, keyed on the same day, inside a card of fixed width whose height never changes (`docs/system/examples/content-changes/default.tsx`)

```tsx
import { useState } from "react";

import { ChevronLeftIcon, ChevronRightIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { Crossfade } from "@/components/cobalt/ui/crossfade";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { Swap } from "@/components/cobalt/ui/swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";

const times = ["09:00", "10:00", "11:30", "13:00", "14:30", "16:00"];
const first = Date.UTC(2026, 9, 15);
const dayName = new Intl.DateTimeFormat("en-GB", { weekday: "long", day: "numeric", month: "long", timeZone: "UTC" });

// Weekdays only, from Thursday 15 October. Every day has the same six times, so the grid never
// changes height; only what is free does.
function dayAt(index: number) {
  let date = first;
  for (let left = index; left > 0; ) {
    date += 86_400_000;
    if (new Date(date).getUTCDay() % 6 !== 0) left -= 1;
  }
  return {
    id: String(index),
    name: dayName.format(date),
    taken: times.filter((_, t) => (index * 7 + t * 3) % 5 < 2),
  };
}

export default function Example() {
  const [index, setIndex] = useState(0);
  const [direction, setDirection] = useState<"forward" | "backward">("forward");
  const [picked, setPicked] = useState<string | null>(null);
  const day = dayAt(index);
  const step = (by: 1 | -1) => {
    setDirection(by === 1 ? "forward" : "backward");
    setIndex((value) => value + by);
  };
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>Room 4.12</CardTitle>
          <CardDescription>Six seats and a screen</CardDescription>
        </CardHeader>
        <CardContent className="flex flex-col gap-3">
          <div className="flex items-center gap-2">
            <IconButton
              icon={<ChevronLeftIcon />}
              label="Previous day"
              size="icon-sm"
              // Today is the first bookable day. The button keeps focus while it cannot go back further.
              disabled={index === 0}
              focusableWhenDisabled
              onClick={() => step(-1)}
            />
            <div className="min-w-0 flex-1 overflow-hidden text-center text-sm font-medium">
              <Swap id={day.id} direction={direction}>
                <span className="block truncate">{day.name}</span>
              </Swap>
            </div>
            <IconButton
              icon={<ChevronRightIcon />}
              label="Next day"
              size="icon-sm"
              onClick={() => step(1)}
            />
          </div>
          {/* The slots are targets: sliding them 8px would move one out from under a resting pointer,
              so they fade in place, keyed on the same day, and only the name says which way you went. */}
          <Crossfade id={day.id} className="grid grid-cols-3 gap-2">
            {times.map((time) => {
              const key = `${day.id} ${time}`;
              const taken = day.taken.includes(time);
              return (
                <Button
                  key={time}
                  size="sm"
                  variant={picked === key ? "default" : "secondary"}
                  aria-pressed={picked === key}
                  disabled={taken}
                  className="tabular-nums"
                  onClick={() => setPicked(key)}
                >
                  {time}
                </Button>
              );
            })}
          </Crossfade>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: Crossfade, the paper inside a card of fixed width, in a box as tall as the longest paper may be (`docs/system/examples/content-changes/crossfade.tsx`)

```tsx
import { useState } from "react";

import { Button } from "@/components/cobalt/ui/button";
import {
  Card,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/cobalt/ui/card";
import { Crossfade } from "@/components/cobalt/ui/crossfade";

const papers = [
  {
    id: "P-20114",
    title: "Dense passage retrieval for open-domain question answering",
    meta: "Karpukhin et al., EMNLP 2020",
    abstract:
      "Passages are retrieved with a dual encoder trained on question and passage pairs, replacing sparse term matching. On five open-domain benchmarks the learned index beats a strong term-based baseline by 9 to 19 points in top-20 accuracy.",
  },
  {
    id: "P-20187",
    title: "Lost in the middle",
    meta: "Liu et al., TACL 2024",
    abstract:
      "Models given long contexts use information at the start and the end of the input far better than information in the middle.",
  },
  {
    id: "P-20203",
    title: "A survey of evaluation methods for retrieval-augmented generation in clinical decision support",
    meta: "Okafor, Lindqvist and Haddad, JAMIA 2025",
    abstract:
      "We screened 412 studies and kept 61 that evaluated a retrieval-augmented system on clinical questions. Most report answer accuracy alone; few measure whether the cited sources support the answer, and none follow patients.",
  },
];

export default function Example() {
  const [done, setDone] = useState(0);
  const paper = papers[done % papers.length]!;
  // Either decision moves on; a real screen would also record which one was made.
  const next = () => setDone((value) => value + 1);
  return (
    <Card className="w-full max-w-sm">
      <CardHeader>
        <CardTitle>Screening</CardTitle>
        <CardDescription>Retrieval-augmented generation review</CardDescription>
      </CardHeader>
      <CardContent>
        {/* One Crossfade wraps the whole paper, in a box as tall as the longest paper may be: two
            lines of title, one of authors and three of abstract. A short paper leaves the space at
            the bottom, so the buttons below never move. */}
        <Crossfade id={paper.id} className="flex h-33 flex-col gap-1">
          <p className="line-clamp-2 font-medium">{paper.title}</p>
          <p className="truncate text-muted-foreground">{paper.meta}</p>
          <p className="mt-2 line-clamp-3 text-muted-foreground">{paper.abstract}</p>
        </Crossfade>
      </CardContent>
      <CardFooter className="justify-end gap-2">
        <Button variant="secondary" onClick={next}>
          Exclude
        </Button>
        <Button onClick={next}>Include</Button>
      </CardFooter>
    </Card>
  );
}
```

Example: Each glyph in an icon button inside the key's field, whose name says what a press does (`docs/system/examples/content-changes/icon-swap.tsx`)

```tsx
import { useState } from "react";

import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from "@/components/cobalt/icon";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { IconSwap } from "@/components/cobalt/ui/icon-swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";
import { useAction } from "@/lib/cobalt/use-action";

const KEY = "tc_test_8f2Kq7Lm1xVz9Rw3";
// As many dots as the key has characters, so showing it never changes the line's width.
const HIDDEN = `${KEY.slice(0, 8)}${"•".repeat(KEY.length - 12)}${KEY.slice(-4)}`;

export default function Example() {
  const [shown, setShown] = useState(false);
  // Copying stays on the page, so it answers at once; the check holds for a moment, then the copy
  // glyph returns, ready for the next press.
  const copy = useAction(() => navigator.clipboard.writeText(KEY));
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>API key</CardTitle>
          <CardDescription>For scripts and notebooks that read your saved searches</CardDescription>
        </CardHeader>
        <CardContent>
          <div className="flex h-(--control) items-center gap-0.5 rounded-(--r-control) bg-muted ps-3 pe-1">
            <code className="min-w-0 flex-1 truncate font-mono text-xs">{shown ? KEY : HIDDEN}</code>
            {/* A two-state toggle: the host's name says what a press does, so the swap needs no words. */}
            <IconButton
              size="icon-xs"
              icon={<IconSwap show={shown ? "second" : "first"} first={<EyeIcon />} second={<EyeOffIcon />} />}
              label={shown ? "Hide key" : "Show key"}
              onClick={() => setShown((value) => !value)}
            />
            {/* A one-off confirmation: the check returns to the copy glyph once the result is shown. */}
            <IconButton
              size="icon-xs"
              icon={
                <IconSwap
                  show={copy.status === "success" ? "second" : "first"}
                  first={<CopyIcon />}
                  second={<CheckIcon />}
                />
              }
              label={copy.status === "success" ? "Copied" : copy.status === "failure" ? "Not copied" : "Copy key"}
              onClick={() => void copy.run()}
            />
          </div>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: The button's label changes from Pause to Resume and the button keeps its width (`docs/system/examples/content-changes/text-swap.tsx`)

```tsx
import { useEffect, useState } from "react";

import { Button } from "@/components/cobalt/ui/button";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/cobalt/ui/card";
import { Sparkline } from "@/components/cobalt/ui/sparkline";
import { TextSwap } from "@/components/cobalt/ui/text-swap";
import { integer } from "@/lib/cobalt/format";

// Stands in for your live feed: one count a second, taken in turn from this list.
const feed = [
  1180, 1210, 1195, 1240, 1302, 1288, 1251, 1276, 1319, 1297, 1264, 1284, 1231, 1259, 1243, 1290, 1311, 1268,
  1222, 1205, 1248, 1273, 1306, 1281,
];

export default function Example() {
  const [live, setLive] = useState(true);
  const [second, setSecond] = useState(0);
  useEffect(() => {
    if (!live) return;
    const timer = setInterval(() => setSecond((value) => value + 1), 1000);
    return () => clearInterval(timer);
  }, [live]);
  // The last 12 seconds, the newest last.
  const values = Array.from({ length: 12 }, (_, i) => feed[(second + i) % feed.length]!);
  return (
    <Card className="w-full max-w-sm">
      <CardHeader>
        <CardTitle>Requests</CardTitle>
        <CardDescription>Per second, last 12 seconds</CardDescription>
        {/* The status is read when it changes. Each wording sits at the end of a slot as wide as
            "Paused", so the card's corner never moves. */}
        <CardAction role="status" className="mt-0.5 text-sm text-muted-foreground">
          <TextSwap
            show={live ? "live" : "paused"}
            options={{ live: "Live", paused: "Paused" }}
            className="justify-items-end"
          />
        </CardAction>
      </CardHeader>
      {/* Tabular figures, so a new count changes digits and never the number's width. */}
      <CardContent className="flex items-end justify-between gap-4">
        <span className="text-2xl font-semibold tabular-nums">{integer(values.at(-1)!)}</span>
        <Sparkline values={values} label="Requests per second over the last 12 seconds" area className="w-32" />
      </CardContent>
      <CardFooter>
        {/* Pausing stays on the page, so it answers at once. The label says what a press does next;
            centring the slot keeps the shorter word in the middle of the button. */}
        <Button variant="secondary" size="sm" onClick={() => setLive((value) => !value)}>
          <TextSwap
            show={live ? "pause" : "resume"}
            options={{ pause: "Pause", resume: "Resume" }}
            className="justify-items-center"
          />
        </Button>
      </CardFooter>
    </Card>
  );
}
```

## Variants
Crossfade has no variant axis: the fade's duration and curve come from `registry/cobalt/lib/motion.ts` and are not props.

### direction
Swap's one axis.
- `forward`: the new content arrives from the right and the old leaves to the left, as a Next press reads. The default.
- `backward`: the mirror, as a Previous press reads. Set it on the render that changes `id`, as the example does with the press that steps back.

Example: Next day moves the old day's name out to the left and the new one in from the right (`docs/system/examples/content-changes/default.tsx`)

```tsx
import { useState } from "react";

import { ChevronLeftIcon, ChevronRightIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { Crossfade } from "@/components/cobalt/ui/crossfade";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { Swap } from "@/components/cobalt/ui/swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";

const times = ["09:00", "10:00", "11:30", "13:00", "14:30", "16:00"];
const first = Date.UTC(2026, 9, 15);
const dayName = new Intl.DateTimeFormat("en-GB", { weekday: "long", day: "numeric", month: "long", timeZone: "UTC" });

// Weekdays only, from Thursday 15 October. Every day has the same six times, so the grid never
// changes height; only what is free does.
function dayAt(index: number) {
  let date = first;
  for (let left = index; left > 0; ) {
    date += 86_400_000;
    if (new Date(date).getUTCDay() % 6 !== 0) left -= 1;
  }
  return {
    id: String(index),
    name: dayName.format(date),
    taken: times.filter((_, t) => (index * 7 + t * 3) % 5 < 2),
  };
}

export default function Example() {
  const [index, setIndex] = useState(0);
  const [direction, setDirection] = useState<"forward" | "backward">("forward");
  const [picked, setPicked] = useState<string | null>(null);
  const day = dayAt(index);
  const step = (by: 1 | -1) => {
    setDirection(by === 1 ? "forward" : "backward");
    setIndex((value) => value + by);
  };
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>Room 4.12</CardTitle>
          <CardDescription>Six seats and a screen</CardDescription>
        </CardHeader>
        <CardContent className="flex flex-col gap-3">
          <div className="flex items-center gap-2">
            <IconButton
              icon={<ChevronLeftIcon />}
              label="Previous day"
              size="icon-sm"
              // Today is the first bookable day. The button keeps focus while it cannot go back further.
              disabled={index === 0}
              focusableWhenDisabled
              onClick={() => step(-1)}
            />
            <div className="min-w-0 flex-1 overflow-hidden text-center text-sm font-medium">
              <Swap id={day.id} direction={direction}>
                <span className="block truncate">{day.name}</span>
              </Swap>
            </div>
            <IconButton
              icon={<ChevronRightIcon />}
              label="Next day"
              size="icon-sm"
              onClick={() => step(1)}
            />
          </div>
          {/* The slots are targets: sliding them 8px would move one out from under a resting pointer,
              so they fade in place, keyed on the same day, and only the name says which way you went. */}
          <Crossfade id={day.id} className="grid grid-cols-3 gap-2">
            {times.map((time) => {
              const key = `${day.id} ${time}`;
              const taken = day.taken.includes(time);
              return (
                <Button
                  key={time}
                  size="sm"
                  variant={picked === key ? "default" : "secondary"}
                  aria-pressed={picked === key}
                  disabled={taken}
                  className="tabular-nums"
                  onClick={() => setPicked(key)}
                >
                  {time}
                </Button>
              );
            })}
          </Crossfade>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: Previous day mirrors the move (`docs/system/examples/content-changes/default.tsx`)

```tsx
import { useState } from "react";

import { ChevronLeftIcon, ChevronRightIcon } from "@/components/cobalt/icon";
import { Button } from "@/components/cobalt/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { Crossfade } from "@/components/cobalt/ui/crossfade";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { Swap } from "@/components/cobalt/ui/swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";

const times = ["09:00", "10:00", "11:30", "13:00", "14:30", "16:00"];
const first = Date.UTC(2026, 9, 15);
const dayName = new Intl.DateTimeFormat("en-GB", { weekday: "long", day: "numeric", month: "long", timeZone: "UTC" });

// Weekdays only, from Thursday 15 October. Every day has the same six times, so the grid never
// changes height; only what is free does.
function dayAt(index: number) {
  let date = first;
  for (let left = index; left > 0; ) {
    date += 86_400_000;
    if (new Date(date).getUTCDay() % 6 !== 0) left -= 1;
  }
  return {
    id: String(index),
    name: dayName.format(date),
    taken: times.filter((_, t) => (index * 7 + t * 3) % 5 < 2),
  };
}

export default function Example() {
  const [index, setIndex] = useState(0);
  const [direction, setDirection] = useState<"forward" | "backward">("forward");
  const [picked, setPicked] = useState<string | null>(null);
  const day = dayAt(index);
  const step = (by: 1 | -1) => {
    setDirection(by === 1 ? "forward" : "backward");
    setIndex((value) => value + by);
  };
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>Room 4.12</CardTitle>
          <CardDescription>Six seats and a screen</CardDescription>
        </CardHeader>
        <CardContent className="flex flex-col gap-3">
          <div className="flex items-center gap-2">
            <IconButton
              icon={<ChevronLeftIcon />}
              label="Previous day"
              size="icon-sm"
              // Today is the first bookable day. The button keeps focus while it cannot go back further.
              disabled={index === 0}
              focusableWhenDisabled
              onClick={() => step(-1)}
            />
            <div className="min-w-0 flex-1 overflow-hidden text-center text-sm font-medium">
              <Swap id={day.id} direction={direction}>
                <span className="block truncate">{day.name}</span>
              </Swap>
            </div>
            <IconButton
              icon={<ChevronRightIcon />}
              label="Next day"
              size="icon-sm"
              onClick={() => step(1)}
            />
          </div>
          {/* The slots are targets: sliding them 8px would move one out from under a resting pointer,
              so they fade in place, keyed on the same day, and only the name says which way you went. */}
          <Crossfade id={day.id} className="grid grid-cols-3 gap-2">
            {times.map((time) => {
              const key = `${day.id} ${time}`;
              const taken = day.taken.includes(time);
              return (
                <Button
                  key={time}
                  size="sm"
                  variant={picked === key ? "default" : "secondary"}
                  aria-pressed={picked === key}
                  disabled={taken}
                  className="tabular-nums"
                  onClick={() => setPicked(key)}
                >
                  {time}
                </Button>
              );
            })}
          </Crossfade>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

### show
IconSwap takes `first` or `second`; TextSwap takes a key of its `options`, or `null`.
- `first`: IconSwap shows the first glyph; the second is hidden and `aria-hidden`. The rest state in both buttons of the example.
- `second`: IconSwap shows the second glyph; the first is hidden and `aria-hidden`. The crossed eye while the key shows, and the check after copying.
- `key`: TextSwap shows the wording under that key of `options` and hides every other. Used at 0 call sites; the example's two pairs, Live and Paused over a count that updates every second while Live.
- `null`: TextSwap shows no wording and the slot keeps its width, for a line that is blank until the first event. Used at 0 call sites.

Example: The eye and the copy glyph at rest (`docs/system/examples/content-changes/icon-swap.tsx`)

```tsx
import { useState } from "react";

import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from "@/components/cobalt/icon";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { IconSwap } from "@/components/cobalt/ui/icon-swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";
import { useAction } from "@/lib/cobalt/use-action";

const KEY = "tc_test_8f2Kq7Lm1xVz9Rw3";
// As many dots as the key has characters, so showing it never changes the line's width.
const HIDDEN = `${KEY.slice(0, 8)}${"•".repeat(KEY.length - 12)}${KEY.slice(-4)}`;

export default function Example() {
  const [shown, setShown] = useState(false);
  // Copying stays on the page, so it answers at once; the check holds for a moment, then the copy
  // glyph returns, ready for the next press.
  const copy = useAction(() => navigator.clipboard.writeText(KEY));
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>API key</CardTitle>
          <CardDescription>For scripts and notebooks that read your saved searches</CardDescription>
        </CardHeader>
        <CardContent>
          <div className="flex h-(--control) items-center gap-0.5 rounded-(--r-control) bg-muted ps-3 pe-1">
            <code className="min-w-0 flex-1 truncate font-mono text-xs">{shown ? KEY : HIDDEN}</code>
            {/* A two-state toggle: the host's name says what a press does, so the swap needs no words. */}
            <IconButton
              size="icon-xs"
              icon={<IconSwap show={shown ? "second" : "first"} first={<EyeIcon />} second={<EyeOffIcon />} />}
              label={shown ? "Hide key" : "Show key"}
              onClick={() => setShown((value) => !value)}
            />
            {/* A one-off confirmation: the check returns to the copy glyph once the result is shown. */}
            <IconButton
              size="icon-xs"
              icon={
                <IconSwap
                  show={copy.status === "success" ? "second" : "first"}
                  first={<CopyIcon />}
                  second={<CheckIcon />}
                />
              }
              label={copy.status === "success" ? "Copied" : copy.status === "failure" ? "Not copied" : "Copy key"}
              onClick={() => void copy.run()}
            />
          </div>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: The crossed eye while the key shows, the check for a moment after copying (`docs/system/examples/content-changes/icon-swap.tsx`)

```tsx
import { useState } from "react";

import { CheckIcon, CopyIcon, EyeIcon, EyeOffIcon } from "@/components/cobalt/icon";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { IconButton } from "@/components/cobalt/ui/icon-button";
import { IconSwap } from "@/components/cobalt/ui/icon-swap";
import { TooltipProvider } from "@/components/cobalt/ui/tooltip";
import { useAction } from "@/lib/cobalt/use-action";

const KEY = "tc_test_8f2Kq7Lm1xVz9Rw3";
// As many dots as the key has characters, so showing it never changes the line's width.
const HIDDEN = `${KEY.slice(0, 8)}${"•".repeat(KEY.length - 12)}${KEY.slice(-4)}`;

export default function Example() {
  const [shown, setShown] = useState(false);
  // Copying stays on the page, so it answers at once; the check holds for a moment, then the copy
  // glyph returns, ready for the next press.
  const copy = useAction(() => navigator.clipboard.writeText(KEY));
  return (
    <TooltipProvider>
      <Card className="w-full max-w-sm">
        <CardHeader>
          <CardTitle>API key</CardTitle>
          <CardDescription>For scripts and notebooks that read your saved searches</CardDescription>
        </CardHeader>
        <CardContent>
          <div className="flex h-(--control) items-center gap-0.5 rounded-(--r-control) bg-muted ps-3 pe-1">
            <code className="min-w-0 flex-1 truncate font-mono text-xs">{shown ? KEY : HIDDEN}</code>
            {/* A two-state toggle: the host's name says what a press does, so the swap needs no words. */}
            <IconButton
              size="icon-xs"
              icon={<IconSwap show={shown ? "second" : "first"} first={<EyeIcon />} second={<EyeOffIcon />} />}
              label={shown ? "Hide key" : "Show key"}
              onClick={() => setShown((value) => !value)}
            />
            {/* A one-off confirmation: the check returns to the copy glyph once the result is shown. */}
            <IconButton
              size="icon-xs"
              icon={
                <IconSwap
                  show={copy.status === "success" ? "second" : "first"}
                  first={<CopyIcon />}
                  second={<CheckIcon />}
                />
              }
              label={copy.status === "success" ? "Copied" : copy.status === "failure" ? "Not copied" : "Copy key"}
              onClick={() => void copy.run()}
            />
          </div>
        </CardContent>
      </Card>
    </TooltipProvider>
  );
}
```

Example: The count updates every second until you press Pause, and the status and the button's label change in place at the same size (`docs/system/examples/content-changes/text-swap.tsx`)

```tsx
import { useEffect, useState } from "react";

import { Button } from "@/components/cobalt/ui/button";
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/cobalt/ui/card";
import { Sparkline } from "@/components/cobalt/ui/sparkline";
import { TextSwap } from "@/components/cobalt/ui/text-swap";
import { integer } from "@/lib/cobalt/format";

// Stands in for your live feed: one count a second, taken in turn from this list.
const feed = [
  1180, 1210, 1195, 1240, 1302, 1288, 1251, 1276, 1319, 1297, 1264, 1284, 1231, 1259, 1243, 1290, 1311, 1268,
  1222, 1205, 1248, 1273, 1306, 1281,
];

export default function Example() {
  const [live, setLive] = useState(true);
  const [second, setSecond] = useState(0);
  useEffect(() => {
    if (!live) return;
    const timer = setInterval(() => setSecond((value) => value + 1), 1000);
    return () => clearInterval(timer);
  }, [live]);
  // The last 12 seconds, the newest last.
  const values = Array.from({ length: 12 }, (_, i) => feed[(second + i) % feed.length]!);
  return (
    <Card className="w-full max-w-sm">
      <CardHeader>
        <CardTitle>Requests</CardTitle>
        <CardDescription>Per second, last 12 seconds</CardDescription>
        {/* The status is read when it changes. Each wording sits at the end of a slot as wide as
            "Paused", so the card's corner never moves. */}
        <CardAction role="status" className="mt-0.5 text-sm text-muted-foreground">
          <TextSwap
            show={live ? "live" : "paused"}
            options={{ live: "Live", paused: "Paused" }}
            className="justify-items-end"
          />
        </CardAction>
      </CardHeader>
      {/* Tabular figures, so a new count changes digits and never the number's width. */}
      <CardContent className="flex items-end justify-between gap-4">
        <span className="text-2xl font-semibold tabular-nums">{integer(values.at(-1)!)}</span>
        <Sparkline values={values} label="Requests per second over the last 12 seconds" area className="w-32" />
      </CardContent>
      <CardFooter>
        {/* Pausing stays on the page, so it answers at once. The label says what a press does next;
            centring the slot keeps the shorter word in the middle of the button. */}
        <Button variant="secondary" size="sm" onClick={() => setLive((value) => !value)}>
          <TextSwap
            show={live ? "pause" : "resume"}
            options={{ pause: "Pause", resume: "Resume" }}
            className="justify-items-center"
          />
        </Button>
      </CardFooter>
    </Card>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| Swap rest | render, or the swap finished | read the content | the content at opacity 1 with no transform, one child in the tree | test |
| Swap swapping | a new `id` | read the arriving content, press the control that changed it again | two children in one grid cell for about 120ms: the old at x 0 to -8px fading out, under 5 percent by 48ms, the new from x 8px to 0 fading in from 42ms; recorded at 16ms steps on a fake clock at 1440 and 390, light and dark, the fainter of the two never passed 3 percent (`.design-system/evidence/swap/handover.json`) and nothing around the swap moved by more than 0.5px (`.design-system/evidence/swap/motion2.json`) | by hand |
| Swap first paint | server render or first mount | read the content | the content as it is: `initial={false}` ships no opacity 0 and no offset | test |
| Crossfade rest | render, or the fade finished | read the content | the content at opacity 1, one child in the tree | test |
| Crossfade fading | a new `id` | read the arriving content, press the control that changed it again | one child only in the tree at opacity 0 rising to 1 over 320ms, the old content unmounted on the same frame; the container takes the new content's height at once, so the example holds it fixed: measured the card at 384 by 314px in every frame and nothing in it moved by more than 0.5px (`.design-system/evidence/crossfade/motion2.json`) | by hand |
| Crossfade first paint | server render or first mount | read the content | the content at opacity 1 with no inline style, because `initial` is `false` until hydration | test |
| IconSwap first shown | `show="first"` | whatever the host control allows; the slot itself takes no input | the first glyph at `opacity-100`, the second at `opacity-0` and blurred with `aria-hidden="true"` | test |
| IconSwap second shown | `show="second"` | the same | the reverse | test |
| IconSwap swapping | `show` changes | the same; a press mid-swap starts the reverse from the glyph's current opacity | both glyphs mid-way for 250ms on `--curve-in-out`; measured at 16ms intervals at 1440 and 390, the key, its field and both buttons moved by no more than 0.5px (`.design-system/evidence/icon-swap/motion2.json`) | by hand |
| TextSwap shown | `show` is a key of `options` | read the word; the slot takes no input | that wording at opacity 1 and `data-active="true"`, every other at opacity 0 with `aria-hidden="true"` | test |
| TextSwap blank | `show={null}` | nothing to read | every wording at opacity 0 and `aria-hidden="true"`, the slot still at the width of the longest | test |
| TextSwap fading | `show` changes | read the arriving word | the leaving wording under 5 percent by 48ms, the arriving one under 3 percent until then and in by 250ms; recorded at 16ms steps on a fake clock at 1440 and 390, light and dark, the fainter of the two never passed 3 percent (`.design-system/evidence/text-swap/handover.json`), and the card, its status, the number and the button moved by no more than 0.5px (`.design-system/evidence/text-swap/motion2.json`) | by hand |

### State precedence
- Swap swapping and a second new `id` mid-swap: the newest content wins. The arriving copy of the first press becomes a leaving copy from where it is, so nothing jumps back (`trap/motion-restart`).
- Swap swapping and first paint: first paint wins. The first content never animates in, only a change of `id` does.
- Swap rest and swapping: Not applicable: the states are one per child, the leaving child is in swapping while the arriving child reaches rest.
- Crossfade fading and a second new `id` mid-fade: the newest content wins. The half-faded child is unmounted and the new one starts from opacity 0, so a fast screener sees each paper start the same way (`trap/motion-restart` does not apply: there is no position to continue from).
- Crossfade fading and first paint: first paint wins. The content the server sent never fades; only a change of `id` after hydration does.
- Crossfade rest and fading: Not applicable: one child is in the tree at a time, so it is one or the other.
- IconSwap swapping and a second change mid-swap: the newest `show` wins. A CSS transition continues from the current value, so the glyph returns from where it is instead of jumping (`trap/motion-restart`).
- IconSwap first shown and second shown: Not applicable: `show` is one value at a time, so exactly 1 glyph is active.
- IconSwap swapping and the host's disabled state: both show. The slot keeps transitioning; the host's half opacity sits on top.
- TextSwap fading and a second change mid-fade: the newest `show` wins. A CSS opacity transition continues from the current value, so a wording that was half in fades back from there (`trap/motion-restart`).
- TextSwap shown and blank: Not applicable: `show` is one value at a time, a key or `null`.
- TextSwap fading and the host's `aria-busy` or disabled state: both show. The slot fades on its own and the host's state sits beside it.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| Swap, a new `id`, in | announce | `springs.settle`, a 0.3s spring with no bounce, mirrored as `--t-settle`, after a 42ms delay, 40 percent of the exit; recorded 0.02 opacity at 48ms, 0.15 at 64ms and 0.49 at 96ms on the fake clock (`.design-system/evidence/swap/handover.json`) | opacity 0 to 1, x from 8px (`distances.settle`) to 0, mirrored by `direction` (transform) | only the opacity animates: the component drops the offset under `useReducedMotion` |
| Swap, a new `id`, out | announce | 70 percent of `times.pop`, 105ms on `curves.out`, the quick exit popups take; recorded 0.44 opacity at 16ms, 0.15 at 32ms and 0.05 at 48ms, gone from the tree by 128ms (`.design-system/evidence/swap/handover.json`) | opacity 1 to 0, x 0 to 8px the other way (transform) | the same fade, with no offset |
| Crossfade, a new `id` | announce | `times.crossfade`, 0.32s on `curves.sheet`, mirrored as `--t-crossfade` on `--curve-sheet`; measured 0.23 opacity on the first frame and 0.77 at 80ms; the earlier 0.15s fade on `curves.out` measured opacity at 1 after 117ms and 0.67 on its first frame (`.design-system/evidence/crossfade/motion-390.json`) | opacity 0 to 1 only; one child in the tree throughout | the fade stays, which `rule/motion-reduced` keeps as the thing that explains the change; the same time under `reduce` |
| IconSwap, `show` changes | announce | `duration-icon`, `--t-icon` 250ms on `--curve-in-out`; measured 250ms on `cubic-bezier(0.77, 0, 0.175, 1)` for both glyphs (`.design-system/evidence/icon-swap/motion-390.json`) | opacity and filter (`blur(2px)` to none) of each glyph's wrapper; nothing on the slot, which stays 16px | the blur drops; the 250ms opacity fade stays, set by `base.css` under `prefers-reduced-motion` (measured, `reduced.afterTrigger.animations`) |
| TextSwap, `show` changes | announce | arriving: `duration-icon`, `--t-icon` 250ms on `--curve-in-out` through `ease-in-out`, the same as IconSwap, so a glyph and a word that change together land together; leaving: 70 percent of `--t-pop` on `--curve` through `ease-out`; recorded the leaving word at 0.15 at 32ms and 0.05 at 48ms, the arriving at 0.03 at 48ms, 0.19 at 96ms and 0.64 at 128ms (`.design-system/evidence/text-swap/handover.json`) | opacity of each wording only; the slot's width stays that of the longest wording | both fades stay, set by `base.css` under `prefers-reduced-motion` (measured, `.design-system/evidence/text-swap/motion-390.json`, `reduced.afterTrigger.animations`) |

## Props

<!-- Props generated from registry/cobalt/ui/swap.tsx, registry/cobalt/ui/crossfade.tsx, registry/cobalt/ui/icon-swap.tsx, registry/cobalt/ui/text-swap.tsx with TypeScript by scripts/props-table.mjs -->
### Swap

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  |  |
| `id` | `string` |  |  |
| `className?` | `string` |  |  |
| `direction?` | `"forward" \| "backward"` | `"forward"` | Forward brings the new content in from the right, as a Next press does; backward from the left. |

### Crossfade

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `children` | `ReactNode` |  |  |
| `id` | `string` |  |  |
| `className?` | `string` |  |  |

### IconSwap

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `first` | `ReactNode` |  |  |
| `second` | `ReactNode` |  |  |
| `show` | `"first" \| "second"` |  | `first` IconSwap shows the first glyph; `second` IconSwap shows the second glyph; `key` TextSwap shows the wording under that key of `options` and hides every other; `null` TextSwap shows no wording and the slot keeps its width. |
| `className?` | `string` |  |  |
| `data-icon?` | `"inline-start" \| "inline-end"` |  |  |

### TextSwap

| Prop | Type | Default | Purpose |
|---|---|---|---|
| `options` | `Record<Key, ReactNode>` |  |  |
| `show` | `Key` |  | `first` IconSwap shows the first glyph; `second` IconSwap shows the second glyph; `key` TextSwap shows the wording under that key of `options` and hides every other; `null` TextSwap shows no wording and the slot keeps its width. |
| `className?` | `string` |  |  |
| `fit?` | `boolean` | `false` | The slot takes the width of the wording on show instead of the longest. |

Swap: `id` names the content; a new value starts the swap and the same value never does, so pass the item's own key and not an index that may repeat. `direction` is `forward` by default and `backward` for a step back; set it with the same press that changes `id`. `children` is the content as it should read at rest. `className` lands on the moving element, for its layout such as `grid grid-cols-3 gap-2`; the container's size belongs to the parent.

Crossfade: `id` names the content; a new value unmounts the old content and fades the new one in. `children` is the content as it should read at rest. `className` lands on the fading element, for its layout and its fixed height, such as `flex h-33 flex-col gap-1`.

IconSwap: `show` names the glyph to show. `first` and `second` are the two glyphs, any node, both always mounted; an empty `<span />` is a valid glyph for a slot that is sometimes blank, as the pill does. `className` sets the slot's size, such as `size-5`, and never the glyphs' size, which fill the cell through `[&>*]:size-full`. `data-icon` (`"inline-start"` or `"inline-end"`) is set on the slot as on any glyph in a Button, so the button trims its padding on that side and the slot sits where a lone glyph would.

TextSwap: `options` is a record of every wording the slot can show, keyed by the state; all of them are mounted, so the type of `show` is the union of the keys and a wording not in the record cannot be shown. A wording can be any short node, such as a word beside a glyph. `show` is the key to show or `null` for a blank slot that keeps its width. `className` lands on the slot: `justify-items-center` centres a shorter word in a button, `justify-items-end` holds a status against the end of a header; the wordings inherit the host's font and colour. Each wording is trimmed to its capitals for a fixed-height control; where the line box is the height, as in a tooltip, `*:[text-box:normal]` keeps the full line, as CopyButton's tooltip does.

## Usage

### When to use
- You step through a sequence a few times in a session and the order matters, such as the days of a booking calendar, the weeks of a schedule or the steps of a setup, and seeing which way it went helps you keep your place: Swap.
- Content is stepped through hundreds of times a day, such as papers in a screening queue, rows in a review or search results, and the new item simply replaces the old: Crossfade.
- A glyph changes with a state, such as an eye becoming a crossed eye while a secret shows, a copy glyph becoming a check for a moment, or a bookmark filling when saved, inside a box that must not change: IconSwap.
- A slot is sometimes blank, such as the check on a pill that is off, and the blank must hold the slot's width: IconSwap with an empty glyph.
- A word or a short status changes in place beside things that must not move, such as Live and Paused, Pause and Resume, or Follow and Following, and every wording is known up front: TextSwap.

### When not to use
- A button reports its own request, such as Saving and Saved, or its glyph gives way to a turning ring while it waits. Use StateButton instead, which carries `aria-busy`, the ring and the blocked repeat.
- The content is loading, not changing. Use Skeleton instead for the wait, and let the content replace it.
- A surface opens or closes. Use Dialog, Sheet, Popover or Grow instead, which grow from their trigger.

### Rules
- `rule/swap-id-is-the-content-key`: When choosing `id`, pass the item's own key, such as `day.id`, instead of a counter or an index that can repeat, because a repeated value never starts a swap and a value that changes without the content does. Evidence: principle platform: React keys, the key names the element's identity; single use `docs/system/examples/content-changes/default.tsx:60`, keyed on the day. Check: review of every Swap's `id` expression.
  - Don't: `<Swap id={String(Date.now())}>{item.title}</Swap>`
  - Do: `<Swap id={item.id}>{item.title}</Swap>`
- `rule/swap-direction-follows-the-press`: When a press steps back, set `direction="backward"` on the same render that changes `id`, instead of leaving the default, because the content then leaves the way you are going and the move contradicts the arrow you pressed. Evidence: principle heuristic: match between system and the real world, Previous moves content the way a page turns back; single use `docs/system/examples/content-changes/default.tsx:37`, which sets the direction and the day in one handler. Check: review of every Swap driven by a Previous control.
  - Don't: `onClick={() => setIndex(index - 1)}` with `<Swap id={day.id}>`
  - Do: `onClick={() => { setDirection("backward"); setIndex(index - 1); }}` with `<Swap id={day.id} direction={direction}>`
- `rule/swap-container-holds-the-box`: When the swapped content can differ in size between items, give its container a fixed shape, such as a day's name in a header row whose width the card at `w-full max-w-sm` sets, instead of letting the container follow its content, because both copies share the grid cell while the old one leaves, so a container that follows its content takes the larger of the two and then snaps, and a fit-content card moves everything centred around it (`trap/loading-layout-shift`). Evidence: measured the earlier events examples' cards growing from 138 to 187px and from 154 to 203px wide on the first frame, which moved the Next button 24.5px under the pointer, and the day example at 384 by 238px at 1440 and 310 by 238px at 390 in every frame, `.design-system/evidence/swap/motion2.json`. Check: probe .design-system/tmp/motion2-scripts/record.mjs on the showcase at 1440 and 390.
  - Don't: `<Card className="max-w-sm"><Swap id={item.id}>{item.title}</Swap></Card>`
  - Do: `<Card className="w-full max-w-sm"><div className="min-w-0 flex-1 overflow-hidden"><Swap id={day.id} direction={direction}>{day.name}</Swap></div></Card>`
- `rule/swap-no-second-motion`: When content sits inside a Swap, leave `transition-*`, `animate-*` and motion props off that content, because the Swap already fades it and moves it 8px, and a second motion on the same frames doubles the travel and lands on different timing. Evidence: principle heuristic: aesthetic and minimalist design, one verb per change; person D14. Check: lint trap/motion-transition-all inside Swap children (scripts/check-system.mjs); review.
  - Don't: `<Swap id={item.id}><p className="animate-in fade-in slide-in-from-top-2">{item.title}</p></Swap>`
  - Do: `<Swap id={item.id}><p>{item.title}</p></Swap>`
- `rule/swap-not-under-the-pointer`: When the changing content holds targets someone may be resting the pointer on, such as a grid of time slots, wrap the targets in a Crossfade keyed on the same id and keep Swap for the label that names the step, instead of swapping the targets, because Swap moves its content 8px sideways and a slot slides out from under a pointer that has not moved. Evidence: measured the six slot buttons of the earlier day example travelling 8px under a resting pointer, `docs/research/2026-10-17-audit-b.md` (content changes, finding 2), and the slot times at 88 to 96 left edges across three presses then, against 3 now, one per column, `.design-system/evidence/swap/handover.json`; single use `docs/system/examples/content-changes/default.tsx:73`, the slots in a Crossfade under the swapped day name. Check: review of every Swap whose children hold buttons, links or fields.
  - Don't: `<Swap id={day.id} className="grid grid-cols-3 gap-2">{slots}</Swap>`
  - Do: `<Swap id={day.id} direction={direction}>{day.name}</Swap><Crossfade id={day.id} className="grid grid-cols-3 gap-2">{slots}</Crossfade>`
- `rule/crossfade-id-is-the-content-key`: When choosing `id`, pass the item's own key, such as `paper.id`, instead of a counter or an index that can repeat, because a repeated value never starts the fade and a value that changes without the content fades content that did not change. Evidence: principle platform: React keys, the key names the element's identity; single use `docs/system/examples/content-changes/crossfade.tsx:55`, keyed on the paper. Check: review of every Crossfade's `id` expression.
  - Don't: `<Crossfade id={String(Math.random())}>{paper.abstract}</Crossfade>`
  - Do: `<Crossfade id={paper.id}>{paper.abstract}</Crossfade>`
- `rule/crossfade-wraps-the-whole-change`: When a title and a body change together, put both inside one Crossfade instead of one Crossfade per part, because two fades started on different renders land a frame apart and the content reads as two changes. Evidence: single use `docs/system/examples/content-changes/crossfade.tsx:55`, one Crossfade around the title, the authors and the abstract; principle heuristic: aesthetic and minimalist design, one change, one fade. Check: review of sibling Crossfades keyed on the same id.
  - Don't: `<Crossfade id={p.id}><CardTitle>{p.title}</CardTitle></Crossfade><Crossfade id={p.id}><p>{p.abstract}</p></Crossfade>`
  - Do: `<Crossfade id={p.id}><p>{p.title}</p><p>{p.abstract}</p></Crossfade>`
- `rule/crossfade-holds-its-height`: When items differ in length, give the Crossfade a fixed height and clamp each part to a number of lines, such as `h-33` with `line-clamp-2` on the title and `line-clamp-3` on the abstract, instead of letting the box follow its content, because the container takes the new height on the first frame and moves the buttons below out from under the pointer of someone pressing them hundreds of times (`trap/loading-layout-shift`). Evidence: measured the earlier listings card changing between 222.5 and 384px wide and 122 and 142px tall from one listing to the next, moving its Next button up to 161.5px, and the screening card at 384 by 314px at 1440 and 310px wide at 390 in every frame, `.design-system/evidence/crossfade/motion2.json`. Check: probe .design-system/tmp/motion2-scripts/record.mjs on the showcase at 1440 and 390.
  - Don't: `<Crossfade id={p.id}>{p.abstract}</Crossfade><Button>Next</Button>`
  - Do: `<Crossfade id={p.id} className="h-33"><p className="line-clamp-3">{p.abstract}</p></Crossfade><Button>Next</Button>`
- `rule/crossfade-no-second-motion`: When content sits inside a Crossfade, leave `transition-*`, `animate-*` and motion props off that content, because the piece is quiet by design and a second motion on it brings back the movement it exists to avoid. Evidence: person D14; principle heuristic: aesthetic and minimalist design, the frequent surface is the quiet one. Check: lint trap/motion-transition-all inside Crossfade children (scripts/check-system.mjs); review.
  - Don't: `<Crossfade id={p.id}><p className="animate-in slide-in-from-bottom-2">{p.abstract}</p></Crossfade>`
  - Do: `<Crossfade id={p.id}><p>{p.abstract}</p></Crossfade>`
- `rule/icon-swap-for-a-changing-glyph`: When an icon changes with a state, render both glyphs through `IconSwap` instead of `{shown ? <EyeOffIcon /> : <EyeIcon />}`, because a glyph that mounts and unmounts has no slot to hold and nudges the text beside it, while the fixed cell measured no movement of anything around it. Evidence: measured `somethingBesideTheSlotMoved: false`, the label at x 75 before and after and the button at 79.73px wide both times, .design-system/evidence/icon-swap/motion-390.json; app 5/5 registry sites whose glyph changes take an IconSwap (`registry/cobalt/ui/copy-button.tsx:97`, `registry/cobalt/ui/save-toggle.tsx:63`, `registry/cobalt/ui/composer.tsx:1422`, `registry/cobalt/ui/icon-button.tsx:31`, `registry/cobalt/ui/command-palette.tsx:339`). Check: lint rule/motion-icon-in-a-slot (scripts/check-system.mjs); review.
  - Don't: `<Button>{saved ? <CheckIcon /> : <BookmarkIcon />} Save</Button>`
  - Do: `<Button><IconSwap show={saved ? "first" : "second"} first={<CheckIcon />} second={<BookmarkIcon />} /> Save</Button>`
- `rule/icon-swap-size-on-the-slot`: When the glyph should be another size than 16px, pass the size as `className` on the IconSwap, such as `size-5`, instead of sizing the glyphs, because the glyphs fill the cell through `[&>*]:size-full` and a glyph larger than its cell overflows the slot and the slot's neighbours. Evidence: measured the slot at 16 by 16 with its glyphs filling it, .design-system/evidence/icon-swap/motion-390.json; principle heuristic: consistency and standards, one place sets the size (`trap/icon-optical-size`). Check: lint rule/component-override on IconSwap's children (scripts/check-system.mjs); review.
  - Don't: `<IconSwap show={show} first={<CheckIcon className="size-6" />} second={<CopyIcon />} />`
  - Do: `<IconSwap className="size-6" show={show} first={<CheckIcon />} second={<CopyIcon />} />`
- `rule/icon-swap-name-on-the-host`: When the two glyphs mean two states, say the state on the host once: change its name to the action a press takes, such as `label={shown ? "Hide key" : "Show key"}`, or keep one name and set `aria-pressed`, instead of doing both or neither, because both glyphs are `aria-hidden` on one side or the other and the swap announces nothing by itself, while a name that changes on a pressed toggle says the state twice and contradicts itself. Evidence: principle wcag: 4.1.2 Name, role, value, a control's state is exposed by the control, and a toggle button keeps its name while `aria-pressed` changes; single use `docs/system/examples/content-changes/icon-swap.tsx:35`. Check: test `icon-swap.test.tsx` renders the hidden glyph with `aria-hidden="true"`; a11y scan on the host.
  - Don't: `<IconButton icon={<IconSwap show={shown ? "second" : "first"} first={<EyeIcon />} second={<EyeOffIcon />} />} label={shown ? "Hide key" : "Show key"} aria-pressed={shown} />`
  - Do: `<IconButton icon={<IconSwap show={shown ? "second" : "first"} first={<EyeIcon />} second={<EyeOffIcon />} />} label={shown ? "Hide key" : "Show key"} />`
- `rule/icon-swap-two-glyphs`: When a slot would cycle through more than 2 glyphs, nest the third as a second IconSwap in the `second` slot or redesign the states, because the component takes exactly 2 glyphs and a glyph swapped in from outside unmounts and moves the slot's neighbours. Evidence: principle platform: the prop type `show: "first" | "second"` fails a third value in the typecheck; app 4/4 registry sites use 2 glyphs. Check: lint through the typecheck, which fails a third value of `show`.
  - Don't: `<IconSwap show={state} first={<A />} second={state === "b" ? <B /> : <C />} />`
  - Do: `<IconSwap show={state === "a" ? "first" : "second"} first={<A />} second={<IconSwap show={state === "b" ? "first" : "second"} first={<B />} second={<C />} />} />`
- `rule/text-swap-every-wording-up-front`: When a word changes with a state, pass every wording in `options` and drive `show` with the state, instead of changing a string with `{live ? "Live" : "Paused"}`, because the mounted wordings give the slot the width of the longest, while a changing string resizes the slot and moves what is beside it (`trap/weight-shift`, `trap/loading-layout-shift`). Evidence: measured the Pause button and the status at the same box at every 16ms frame of the change, `.design-system/evidence/text-swap/motion2.json`; single use `docs/system/examples/content-changes/text-swap.tsx:59-61`, the button's two wordings passed up front. Check: test `text-swap.test.tsx` renders every wording with the active one marked; review.
  - Don't: `<Button>{live ? "Pause" : "Resume"}</Button>`
  - Do: `<Button><TextSwap show={live ? "pause" : "resume"} options={{ pause: "Pause", resume: "Resume" }} /></Button>`
- `rule/text-swap-align-the-slot`: When the slot sits in a button or at the end of a row, pass `justify-items-center` or `justify-items-end` as `className`, instead of leaving the shorter wording at the start of the slot, because the slot is as wide as the longest wording and a shorter one left at the start leaves a gap on one side that reads as a misaligned label. Evidence: measured "Saved" at 40.1px in a slot 79.4px wide, the width of "Save search" at 14px, which left 39px of the button empty on its right in the earlier icon-swap example; single use `docs/system/examples/content-changes/text-swap.tsx:62`. Check: review of every TextSwap inside a Button or a CardAction.
  - Don't: `<Button><TextSwap show={show} options={{ pause: "Pause", resume: "Resume" }} /></Button>`
  - Do: `<Button><TextSwap show={show} options={{ pause: "Pause", resume: "Resume" }} className="justify-items-center" /></Button>`
- `rule/text-swap-null-for-blank`: When the slot has nothing to say yet, pass `show={null}` instead of an empty wording or unmounting the TextSwap, because `null` keeps the slot's width and `aria-hidden` on every wording, while an unmount collapses the slot and moves what is beside it when the first status arrives. Evidence: principle heuristic: consistency and standards, the slot's width is set once. Check: test `text-swap.test.tsx` renders `show={null}` with every wording hidden and mounted.
  - Don't: `{status && <TextSwap show={status} options={wordings} />}`
  - Do: `<TextSwap show={status ?? null} options={wordings} />`
- `rule/text-swap-announce-on-the-host`: When a status must reach a screen reader, put `role="status"` on the element around the TextSwap, because every wording not shown is `aria-hidden` and the slot has no live region of its own, so a change is read only if the user lands on it. A button's own label needs no live region: the button's name changes and is read on focus. Evidence: principle wcag: 4.1.3 Status messages, a status change is announced without focus moving to it; single use `docs/system/examples/content-changes/text-swap.tsx:42`. Check: review of every status TextSwap's host for `role="status"`; a11y scan on the host.
  - Don't: `<CardAction><TextSwap show={status} options={wordings} /></CardAction>`
  - Do: `<CardAction role="status"><TextSwap show={status} options={wordings} /></CardAction>`

### Content
- Follows `rule/writing-heading-sentence-case`.
- Follows `rule/writing-status-verb-ing`.
- Not applicable: Swap, Crossfade and IconSwap render no copy of their own; the content's slots and the host's label keep their own rules.
- `rule/text-swap-wording-is-a-status`: When writing a wording, write one or two words in sentence case with no end punctuation: a state, such as "Live" or "Paused", or on a button the action a press takes next, such as "Pause" or "Resume", because the word is read at a glance beside a control and a sentence with a period reads as a message, not a state. Evidence: principle heuristic: match between system and the real world, the word reports a state or names the next action; app 4/4 example wordings follow the shape (`docs/system/examples/content-changes/text-swap.tsx`). Check: lint copy/template on the status slot (scripts/copy-check.mjs); review.
  - Don't: `options={{ live: "Updates are live now.", paused: "Paused!" }}`
  - Do: `options={{ live: "Live", paused: "Paused" }}`

### Anti-slop
- `rule/swap-not-for-frequent-changes`: When the content is stepped through more than 10 times in a sitting, such as papers in a screening queue, rows or search results, use Crossfade instead of Swap, because 8px of travel is still motion, and at that frequency you want the content to change with nothing moving. Evidence: person D14; principle heuristic: aesthetic and minimalist design, the more often a thing is seen the less it moves. Check: review of each Swap against the surface's frequency.
  - Don't: `<Swap id={paper.id}><PaperSummary paper={paper} /></Swap>`
  - Do: `<Crossfade id={paper.id}><PaperSummary paper={paper} /></Crossfade>`
- `rule/swap-not-a-page-transition`: When the whole view changes, such as a route or a tab panel, leave Swap off the view's root and change the view in place, because a view that slides on every route reads as the page reloading. Evidence: person D14; principle heuristic: consistency and standards, a route change looks like a route change. Check: review of every Swap's children for a view root.
  - Don't: `<Swap id={route}><Page /></Swap>`
  - Do: `<Page />`
- `rule/crossfade-has-no-exit`: When the old content should be seen leaving, use Swap instead of wrapping Crossfade in `AnimatePresence` or adding an exit of your own, because two paragraphs of text laid over each other read as a smear and the piece unmounts the old content on purpose. Evidence: measured one child in the tree through the whole change, .design-system/evidence/crossfade/motion-390.json; person D14. Check: review of every Crossfade for a wrapping `AnimatePresence`.
  - Don't: `<AnimatePresence mode="wait"><Crossfade id={p.id}>{p.abstract}</Crossfade></AnimatePresence>`
  - Do: `<Crossfade id={p.id}>{p.abstract}</Crossfade>`
- `rule/crossfade-not-a-loader`: When content is waiting on a request, show Skeleton or keep the old content instead of fading an empty Crossfade in and out, because a fade on nothing says a change happened when none did. Evidence: principle heuristic: visibility of system status, a wait is shown as a wait; single use `docs/system/examples/content-changes/crossfade.tsx:55`, which fades only a loaded paper. Check: review of every Crossfade's children for a loading branch.
  - Don't: `<Crossfade id={loading ? "loading" : item.id}>{loading ? null : item.body}</Crossfade>`
  - Do: `{loading ? <Skeleton className="h-16" /> : <Crossfade id={item.id}>{item.body}</Crossfade>}`
- `rule/icon-swap-no-spin-or-bounce`: When a glyph changes, keep the one `IconSwap` transition instead of adding `animate-spin`, `animate-bounce` or a rotate to the arriving glyph, because the verb is two glyphs trading places on `--curve-in-out`, and a spin on a check is an overshoot the user sees every time they copy. Evidence: person D14; principle heuristic: aesthetic and minimalist design, one verb per change (`trap/motion-overshoot`). Check: lint trap/motion-overshoot (scripts/check-system.mjs); review.
  - Don't: `<IconSwap show={show} first={<CheckIcon className="animate-bounce" />} second={<CopyIcon />} />`
  - Do: `<IconSwap show={show} first={<CheckIcon />} second={<CopyIcon />} />`
- `rule/icon-swap-success-for-a-moment`: When a glyph confirms a one-off action, such as copied, drive `show` from `useAction`'s `status`, which returns to idle after `RESULT_HOLD_MS` (1500ms), instead of a flag you set and never clear, because a check that stays says the action is still true and the next press on the same button then confirms nothing. Evidence: single use `docs/system/examples/content-changes/icon-swap.tsx:43`, the copy glyph driven by `copy.status`; principle heuristic: visibility of system status, feedback ends when the event does. Check: review of every IconSwap driven by a one-off action for a reset.
  - Don't: `onClick={() => setCopied(true)}` with `show={copied ? "second" : "first"}`
  - Do: `onClick={() => void copy.run()}` with `show={copy.status === "success" ? "second" : "first"}`
- `rule/text-swap-no-movement`: When a wording changes, keep the opacity handover, the old word out on the quick exit and the new one in over 250ms, instead of adding a slide, a scale or a blur to the wordings, because the piece exists so that a word can change without the eye being pulled to it, and text that moves while it fades is read twice. Evidence: person D14; principle heuristic: aesthetic and minimalist design, a status seen hundreds of times a day gets a fade only. Check: lint trap/motion-transition-all inside TextSwap's wordings (scripts/check-system.mjs); review.
  - Don't: `options={{ paused: <span className="animate-in slide-in-from-bottom-1">Paused</span> }}`
  - Do: `options={{ paused: "Paused" }}`
- `rule/text-swap-not-for-content`: When the changing text is a title, a paragraph or anything you read for more than a glance, use Crossfade or Swap instead of a TextSwap, because every wording stays mounted and the slot takes the width and height of the longest, so a paragraph in `options` leaves a blank the size of the longest paragraph under the shorter ones. Evidence: measured the slot at the width of the longest of three wordings, `widths` all 115.16px, .design-system/evidence/text-swap/motion-390.json; principle heuristic: aesthetic and minimalist design, a status is one line. Check: review of every TextSwap's wordings for a node longer than one line.
  - Don't: `<TextSwap show={page} options={{ a: <p>{pages[0]}</p>, b: <p>{pages[1]}</p> }} />`
  - Do: `<Crossfade id={page}>{pages[index]}</Crossfade>`

### Limits
- `rule/swap-content-under-one-screen`: When the swapped content is taller than about a third of a 390x844 screen, use Crossfade instead, because a block that large moving sideways reads as the page sliding, and its leaving copy keeps the cell at the larger height for about 120ms. Evidence: measured the earlier day example's swapped grid at 72px tall at 390, `.design-system/evidence/swap/motion2.json`; principle heuristic: aesthetic and minimalist design, moving content is read as a unit. Check: review of every Swap's content height at 390.
  - Don't: `<Swap id={item.id}><LongArticle /></Swap>`
  - Do: `<Crossfade id={item.id}><LongArticle /></Crossfade>`
- `rule/crossfade-height-jump`: When the content cannot be clamped, such as a full article, put the controls above it and give the content its own scroll at `h-[60dvh]`, instead of controls below a box that changes height, because the container takes the new height at once and a jump taller than the viewport moves the control the user is pressing off the screen (`trap/loading-layout-shift`). Evidence: measured `containerHeights: [72, 92]` on an unclamped paragraph, .design-system/evidence/crossfade/motion-390.json; principle heuristic: user control and freedom, the control stays under the pointer. Check: review of every Crossfade's items at 390.
  - Don't: `<Crossfade id={l.id}><LongArticle /></Crossfade><Button>Next</Button>`
  - Do: `<Button>Next</Button><div className="h-[60dvh] overflow-y-auto"><Crossfade id={l.id}><LongArticle /></Crossfade></div>`
- `rule/text-swap-wording-length`: When a wording would run past 25 characters in a row at 390px, shorten it or give the slot its own row, because at 26 characters the longest wording wraps to a second line and the slot grows from 20px to 40px tall, moving what is below. Evidence: measured wrap at 26 characters in a 310px row at 390 with the slot at 172.5px, .design-system/evidence/text-swap/grow-text-390.json. Check: probe the stress page `/stress/text-swap` at 390 with the worst data.
  - Don't: `options={{ paused: "Live updates are paused for this chart" }}`
  - Do: `options={{ paused: "Paused" }}`
- Not applicable: IconSwap takes exactly 2 glyphs by type and the slot's size is set by the host through `className`, so no dimension grows; the slot measured 16px by 16px before and after a swap (`.design-system/evidence/icon-swap/motion-390.json`).

## Accessibility
Swap and Crossfade rest on the content's own semantics. Swap adds a `<div>` grid cell and a `<div>` per copy, and Crossfade one `<div>`, with no role; a screen reader reads the new content as a change to the page, with no announcement unless the host adds a live region. Swap's leaving copy takes no pointer press while it fades.

IconSwap and TextSwap rest on the host. Each is a `<span>` with no role. IconSwap's glyph not shown is `aria-hidden="true"`, and the glyphs themselves are decorative, named by the host. Every TextSwap wording not shown is `aria-hidden="true"`, and the shown wording is plain text read when a screen reader reaches it, or announced when the host is a `role="status"` element.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| any key that changes `id`, such as Enter on Next day | the control outside the Swap | the content swaps; the control keeps focus | unchanged | by hand |
| Tab | before the Swap | moves into a focusable inside the arriving content; the leaving content is unmounted after about 120ms | the content's first focusable | by hand |
| any key that changes `id`, such as Enter on Include | the control outside the Crossfade | the content changes; the control keeps focus, and does not move because the box holds its height | unchanged | by hand |
| Tab | before the Crossfade | moves into a focusable inside the content if there is one | the content's first focusable | by hand |
| Enter or Space | the button that holds an IconSwap | the host changes `show`; the slot itself is not focusable | the host button | by hand |
| Enter or Space | the control that changes a TextSwap's word, such as Pause | the word changes; the slot itself is not focusable | the host control | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| Swap root | none | none | `data-slot="swap"` on each copy; the content's own roles and names | nothing of its own; the content's text when you read it | test |
| Crossfade root | none | none | `data-slot="crossfade"`; the content's own roles and names | nothing of its own; the content's text when you read it | test |
| IconSwap slot | none | none, the host names the control | `data-slot="icon-swap"` | nothing | test |
| IconSwap shown glyph | none | none | `aria-hidden="false"`, `data-active="true"`; the glyph inside is `aria-hidden` by the icon barrel | nothing; the host's name says the state | test |
| IconSwap hidden glyph | none | none | `aria-hidden="true"`, `data-active="false"` | nothing | test |
| TextSwap slot | none, unless the host is `role="status"` | none | `data-slot="text-swap"` | nothing of its own; inside a `role="status"` host, the shown wording when it changes; inside a button, the button's new name | test |
| TextSwap shown wording | none | its text | `aria-hidden="false"`, `data-active="true"` | the text, when a screen reader reaches it | test |
| TextSwap hidden wording | none | none | `aria-hidden="true"`, `data-active="false"` | nothing | test |

## Tokens
| Part | State | Token |
|---|---|---|
| Swap copy | in | `springs.settle`, mirrored as `--t-settle`, after 40 percent of the exit, 42ms; `distances.settle` (8px) |
| Swap copy | out | 70 percent of `times.pop`, mirrored as `--t-pop`, on `curves.out` (`--curve`) |
| Crossfade root | fading | `times.crossfade` on `curves.sheet`, mirrored as `--t-crossfade` on `--curve-sheet` |
| IconSwap glyph wrappers | swapping | `--t-icon` as `duration-icon`, `--curve-in-out` as `ease-in-out`, `--blur-leave` |
| IconSwap slot | all | none of its own; `size-4` from the spacing scale, overridden by `className` |
| TextSwap wordings | arriving | `--t-icon` as `duration-icon`, `--curve-in-out` as `ease-in-out` |
| TextSwap wordings | leaving | 70 percent of `--t-pop`, `--curve` as `ease-out` |
| TextSwap slot | all | none of its own; the host's colour and size |

## Related
- Motion: the verbs, the curve and the times these four use.
- IconButton: the host that names an icon-only control and takes an IconSwap in its slot.
- CopyButton: a copy glyph that becomes a check, built on IconSwap.
- SaveToggle: a bookmark that fills and a label that changes, built on IconSwap and TextSwap.
- StateButton: a button that reports its own request, with the announcement built in.
- Skeleton: the wait before content arrives.
