<!-- generated by scripts/gen-docs.mjs from docs/system/save-toggle.md. Edit the source and rerun. -->
# SaveToggle

## Description
Saves a thing for later, such as a room, a paper or a fund, and shows whether it is saved: a bookmark that fills with the accent. It moves at once and moves back if the save is refused.

`import { SaveToggle } from "@/components/cobalt/ui/save-toggle"`, source `registry/cobalt/ui/save-toggle.tsx`, status `ready`.
Foundation: `Base UI Toggle`. Traps checked: `trap/button-icon-name`, `trap/color-only-status`, `trap/control-height`, `trap/focus-ring-shape`, `trap/weight-shift`, `trap/toast-errors`, `trap/reduced-motion-ignored`, `trap/touch-hover-flash`.

`trap/button-icon-name` is answered by `label`, the name in every form, with Save or Saved in the tooltip of the glyph forms (ARIA). `trap/color-only-status` by the fill of the glyph and `aria-pressed`, so the accent of the saved mark is never the only sign (States). `trap/control-height` by the 32px glyph forms and the 32px labeled form, which reach 44px under a coarse pointer through `touch-target` (Rules). `trap/focus-ring-shape` by the shared outline on the control corner, `--r-control` (States). `trap/weight-shift` by `TextSwap`, which holds "Save" and "Saved" in one cell as wide as the longer (Anti-slop). `trap/toast-errors` by `useOptimisticToggle`, which moves the mark back and hands the refusal to `onRefused`, where the host shows a toast because the mark already answered (Rules). `trap/reduced-motion-ignored` by the base styles, which keep the glyph's fade and drop its blur (Motion). `trap/touch-hover-flash` by Tailwind's `(hover: hover)` guard on the ghost fill (States).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Base UI `Toggle`: a `button` with `aria-pressed`, `pressed` and `onPressedChange`, Space and Enter | The bookmark from `registry/cobalt/icon.tsx` in an `IconSwap`, filled on its path when saved; three looks, `icon`, `labeled` and `overlay`; the labeled words through `TextSwap`; the saved mark in the accent, `--primary`, in every form (D42): the whole glyph on a row or a page, the inside under the overlay's white edge on a photo; the overlay's white edge and its dark inside at rest; the tooltip on the glyph forms, Save or Saved, so the thing's name stays in `label` and a long title never fills a tooltip; `useOptimisticToggle` in `registry/cobalt/lib/use-optimistic-toggle.ts`, which keeps every control for one key in step, sends the presses for one key in order, lets the last press win and moves the mark back on a refusal |

## Examples
Papers in a reading list, each with a bookmark at its end that saves it at once.

Real uses, 0 call sites (`rg -n "<SaveToggle\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new. The first source app saves events, people and listings with its own toggle, and the second keeps a watchlist with a labelled one (`docs/research/2026-10-17-bespoke-sources.md`, section 2.1).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/save-toggle/default.tsx` | default | Papers in a reading list, each with a bookmark at its end that saves it at once |
| `docs/system/examples/save-toggle/default.tsx` | variant=icon | The icon form at the end of a row, muted until saved, then the accent |
| `docs/system/examples/save-toggle/variant-labeled.tsx` | variant=labeled | A room's page saves it with a labelled button, whose Save turns to Saved without changing its width |
| `docs/system/examples/save-toggle/variant-overlay.tsx` | variant=overlay | On a photo the bookmark has no chip behind it; saved, it fills with the accent under its white edge |
| `docs/system/examples/save-toggle/synced.tsx` | state:synced | Saving on the photo also turns the button beside it to Saved |
| `docs/system/examples/save-toggle/refused.tsx` | state:refused | The bookmark fills at once, the server refuses, and it moves back while a toast says Boardroom was not saved |
| `docs/system/examples/save-toggle/variant-overlay.tsx` | composition:MediaTile | The overlay form on a tile's photo, above the tile's stretched link |

Example: Papers in a reading list, each with a bookmark at its end that saves it at once (`docs/system/examples/save-toggle/default.tsx`)

```tsx
import { toast } from "sonner";

import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle } from "@/components/cobalt/ui/item";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

const papers = [
  { id: "p1", title: "Liquidity transformation in open-end bond funds", about: "Working paper, March 2026" },
  { id: "p2", title: "Fee dispersion among registered investment advisers", about: "Journal article, 2025" },
  { id: "p3", title: "Do 13F filings predict returns after the 45-day lag?", about: "Working paper, June 2026" },
];

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

function PaperRow({ paper }: { paper: (typeof papers)[number] }) {
  const saved = useOptimisticToggle(`reading:${paper.id}`, paper.id === "p2", {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? `Could not save ${paper.title}` : `Could not remove ${paper.title} from saved`, {
        id: `reading:${paper.id}`,
        description: "Check your connection and try again.",
      }),
  });
  return (
    <Item render={<li />}>
      <ItemContent>
        <ItemTitle>{paper.title}</ItemTitle>
        <ItemDescription>{paper.about}</ItemDescription>
      </ItemContent>
      <ItemActions>
        <SaveToggle pressed={saved.on} onPressedChange={saved.flip} label={`Save ${paper.title}`} />
      </ItemActions>
    </Item>
  );
}

export default function Example() {
  return (
    <ItemGroup variant="card" render={<ul aria-label="Papers on fund liquidity" />} className="w-full max-w-lg">
      {papers.map((paper) => (
        <PaperRow key={paper.id} paper={paper} />
      ))}
    </ItemGroup>
  );
}
```

Example: The overlay form on a tile's photo, above the tile's stretched link (`docs/system/examples/save-toggle/variant-overlay.tsx`)

```tsx
import { toast } from "sonner";

import { MediaTile, MediaTileMedia, MediaTileMeta, MediaTileTitle } from "@/components/cobalt/ui/media-tile";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

const events = [
  { id: "film-overlay", name: "Film night", when: "Fri, Oct 23", src: "/photos/film-night.webp", saved: false },
  { id: "gala-overlay", name: "Winter gala dinner", when: "Sat, Dec 12", src: "/photos/gala-dinner.webp", saved: true },
];

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

function Tile({ event }: { event: (typeof events)[number] }) {
  const saved = useOptimisticToggle(`saved:${event.id}`, event.saved, {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? `Could not save ${event.name}` : `Could not remove ${event.name} from saved`, {
        id: `saved:${event.id}`,
        description: "Check your connection and try again.",
      }),
  });
  return (
    <MediaTile>
      <MediaTileMedia>
        <img src={event.src} alt="" width={800} height={800} decoding="async" />
        <SaveToggle variant="overlay" pressed={saved.on} onPressedChange={saved.flip} label={`Save ${event.name}`} />
      </MediaTileMedia>
      <MediaTileTitle href={`#${event.id}`}>{event.name}</MediaTileTitle>
      {/* The tile says when; the bookmark alone says whether it is saved. */}
      <MediaTileMeta>{event.when}</MediaTileMeta>
    </MediaTile>
  );
}

export default function Example() {
  return (
    <div className="grid w-full max-w-md grid-cols-2 gap-x-4">
      {events.map((event) => (
        <Tile key={event.id} event={event} />
      ))}
    </div>
  );
}
```

## Variants

### variant
- `icon`: a 32px ghost button with the glyph alone, at the end of a row or in a toolbar, muted at rest and the accent when saved. The default. Used at 0 call sites.
- `labeled`: a 32px secondary button with the glyph and the words Save or Saved, on a record's own page; saved, the glyph takes the accent and the word the ink. Used at 0 call sites.
- `overlay`: the glyph alone on a photo, in its top end corner, white with a dark inside, filling with the accent, `--primary`, under its white edge, as every form does. Used at 0 call sites.

Example: The icon form at the end of a row, muted until saved, then the accent (`docs/system/examples/save-toggle/default.tsx`)

```tsx
import { toast } from "sonner";

import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle } from "@/components/cobalt/ui/item";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

const papers = [
  { id: "p1", title: "Liquidity transformation in open-end bond funds", about: "Working paper, March 2026" },
  { id: "p2", title: "Fee dispersion among registered investment advisers", about: "Journal article, 2025" },
  { id: "p3", title: "Do 13F filings predict returns after the 45-day lag?", about: "Working paper, June 2026" },
];

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

function PaperRow({ paper }: { paper: (typeof papers)[number] }) {
  const saved = useOptimisticToggle(`reading:${paper.id}`, paper.id === "p2", {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? `Could not save ${paper.title}` : `Could not remove ${paper.title} from saved`, {
        id: `reading:${paper.id}`,
        description: "Check your connection and try again.",
      }),
  });
  return (
    <Item render={<li />}>
      <ItemContent>
        <ItemTitle>{paper.title}</ItemTitle>
        <ItemDescription>{paper.about}</ItemDescription>
      </ItemContent>
      <ItemActions>
        <SaveToggle pressed={saved.on} onPressedChange={saved.flip} label={`Save ${paper.title}`} />
      </ItemActions>
    </Item>
  );
}

export default function Example() {
  return (
    <ItemGroup variant="card" render={<ul aria-label="Papers on fund liquidity" />} className="w-full max-w-lg">
      {papers.map((paper) => (
        <PaperRow key={paper.id} paper={paper} />
      ))}
    </ItemGroup>
  );
}
```

Example: A room's page saves it with a labelled button, whose Save turns to Saved without changing its width (`docs/system/examples/save-toggle/variant-labeled.tsx`)

```tsx
import { toast } from "sonner";

import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

export default function Example() {
  const saved = useOptimisticToggle("saved:harbour-labeled", false, {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? "Could not save Harbour room" : "Could not remove Harbour room from saved", {
        id: "saved:harbour-labeled",
        description: "Check your connection and try again.",
      }),
  });
  return (
    <div className="flex w-full max-w-md flex-wrap items-start justify-between gap-x-4 gap-y-2">
      <div className="flex min-w-0 flex-col gap-1">
        <h3 className="text-xl font-semibold tracking-tight">Harbour room</h3>
        <p className="text-sm text-muted-foreground">Seats 12, second floor, facing the water</p>
      </div>
      <SaveToggle variant="labeled" pressed={saved.on} onPressedChange={saved.flip} label="Save Harbour room" />
    </div>
  );
}
```

Example: On a photo the bookmark has no chip behind it; saved, it fills with the accent under its white edge (`docs/system/examples/save-toggle/variant-overlay.tsx`)

```tsx
import { toast } from "sonner";

import { MediaTile, MediaTileMedia, MediaTileMeta, MediaTileTitle } from "@/components/cobalt/ui/media-tile";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

const events = [
  { id: "film-overlay", name: "Film night", when: "Fri, Oct 23", src: "/photos/film-night.webp", saved: false },
  { id: "gala-overlay", name: "Winter gala dinner", when: "Sat, Dec 12", src: "/photos/gala-dinner.webp", saved: true },
];

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

function Tile({ event }: { event: (typeof events)[number] }) {
  const saved = useOptimisticToggle(`saved:${event.id}`, event.saved, {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? `Could not save ${event.name}` : `Could not remove ${event.name} from saved`, {
        id: `saved:${event.id}`,
        description: "Check your connection and try again.",
      }),
  });
  return (
    <MediaTile>
      <MediaTileMedia>
        <img src={event.src} alt="" width={800} height={800} decoding="async" />
        <SaveToggle variant="overlay" pressed={saved.on} onPressedChange={saved.flip} label={`Save ${event.name}`} />
      </MediaTileMedia>
      <MediaTileTitle href={`#${event.id}`}>{event.name}</MediaTileTitle>
      {/* The tile says when; the bookmark alone says whether it is saved. */}
      <MediaTileMeta>{event.when}</MediaTileMeta>
    </MediaTile>
  );
}

export default function Example() {
  return (
    <div className="grid w-full max-w-md grid-cols-2 gap-x-4">
      {events.map((event) => (
        <Tile key={event.id} event={event} />
      ))}
    </div>
  );
}
```

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| idle | rendered, not saved | press it to save | the outlined bookmark; `aria-pressed="false"` | test |
| saved | pressed, or saved on the server | press it to remove it from saved | the bookmark filled with the accent in every form, Saved in the labeled form; `aria-pressed="true"` | test |
| pending | a save on its way after a press | press again, which replaces the press still waiting | the mark already moved; nothing else, since the mark is the answer | by hand |
| refused | the server refused the save | press again to retry | the mark moved back, and the host's toast from `onRefused` | by hand |
| hover | pointer over the icon or labeled form, under `(hover: hover)` | press it | the ghost fill or the darker grey, and on a glyph form the tooltip, Save or Saved | by hand |
| focus-visible | Tab onto it | press it with Space or Enter | the 2px outline on its control corner, `--r-control`, 10px by default | by hand |
| disabled | `disabled` | nothing | half opacity, and no tooltip | by hand |

Example: Saving on the photo also turns the button beside it to Saved (`docs/system/examples/save-toggle/synced.tsx`)

```tsx
import { toast } from "sonner";

import { MediaTile, MediaTileMedia, MediaTileMeta, MediaTileTitle } from "@/components/cobalt/ui/media-tile";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

// Every control that reads the key "saved:fjord-synced" shows the same mark.
function useSavedWalk() {
  return useOptimisticToggle("saved:fjord-synced", false, {
    send: request,
    // Keyed by the item, so a second refusal before the first toast goes says it once.
    onRefused: (on) =>
      toast(on ? "Could not save Fjord walk" : "Could not remove Fjord walk from saved", {
        id: "saved:fjord-synced",
        description: "Check your connection and try again.",
      }),
  });
}

function Tile() {
  const saved = useSavedWalk();
  return (
    <MediaTile className="w-40 shrink-0">
      <MediaTileMedia>
        <img src="/photos/fjord-walk.jpg" alt="" width={1000} height={1000} decoding="async" />
        <SaveToggle variant="overlay" pressed={saved.on} onPressedChange={saved.flip} label="Save Fjord walk" />
      </MediaTileMedia>
      <MediaTileTitle href="#fjord">Fjord walk</MediaTileTitle>
      <MediaTileMeta>Sun, Oct 25</MediaTileMeta>
    </MediaTile>
  );
}

function Panel() {
  const saved = useSavedWalk();
  return (
    // At least 14rem beside the tile, or the whole row under it, so the words never run six lines deep.
    <div className="flex min-w-0 grow basis-56 flex-col items-start gap-3 rounded-2xl bg-card p-4">
      <p className="text-sm text-muted-foreground">Six miles along the water, back by lunch. Meet at the harbour car park at 9:00 AM.</p>
      <SaveToggle variant="labeled" pressed={saved.on} onPressedChange={saved.flip} label="Save Fjord walk" />
    </div>
  );
}

export default function Example() {
  return (
    <div className="flex w-full max-w-lg flex-wrap items-start gap-4">
      <Tile />
      <Panel />
    </div>
  );
}
```

Example: The bookmark fills at once, the server refuses, and it moves back while a toast says Boardroom was not saved (`docs/system/examples/save-toggle/refused.tsx`)

```tsx
import { toast } from "sonner";

import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle } from "@/components/cobalt/ui/item";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

// Stands in for a server that refuses: it answers no after 600ms.
const refuse = () => new Promise<void>((_, reject) => setTimeout(() => reject(new Error("refused")), 600));

export default function Example() {
  const saved = useOptimisticToggle("saved:boardroom-refused", false, {
    send: refuse,
    // Keyed by the room, so pressing twice before the answer says it once.
    onRefused: (on) =>
      toast(on ? "Could not save Boardroom" : "Could not remove Boardroom from saved", {
        id: "saved:boardroom-refused",
        description: "The server did not answer. Try again.",
      }),
  });
  return (
    <ItemGroup variant="card" className="w-full max-w-md">
      <Item>
        <ItemContent>
          <ItemTitle>Boardroom</ItemTitle>
          <ItemDescription>Seats 20, top floor</ItemDescription>
        </ItemContent>
        <ItemActions>
          <SaveToggle pressed={saved.on} onPressedChange={saved.flip} label="Save Boardroom" />
        </ItemActions>
      </Item>
    </ItemGroup>
  );
}
```

### State precedence
- Pending and saved: both show. The mark shows the press at once; pending has no look of its own.
- Refused and saved: refused wins. The mark returns to what the server holds.
- Hover and saved: both show. The fill under the pointer and the glyph in the accent.
- Focus-visible and every other state: both show. The outline is drawn outside the button.
- Disabled and pending: Not applicable: a disabled toggle takes no press.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| idle to saved and back | input | `IconSwap`, `--t-icon` 250ms on `--curve-in-out` | opacity and filter of each glyph | the fade stays and the blur drops, from the base styles |
| labeled words swap | input | `TextSwap`, `--t-icon` 250ms on `--curve-in-out` | opacity | the same fade |
| pointer over and press on the icon and labeled forms | input | `pressable`, `--t-press` on `--curve` | background-color, box-shadow | the same colour change |
| tooltip opens or closes | announce | `popup-motion` at `--t-pop` | opacity | the same fade |

## Props

<!-- Props generated from registry/cobalt/ui/save-toggle.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `label` | `string` |  | The name, which stays the same in both states: "Save Harbour room". |
| `onPressedChange` | `(pressed: boolean) => void` |  |  |
| `pressed` | `boolean` |  |  |
| `className?` | `string` |  |  |
| `disabled?` | `boolean` |  |  |
| `variant?` | `"icon" \| "labeled" \| "overlay"` | `"icon"` | `icon` a 32px ghost button with the glyph alone; `labeled` a 32px secondary button with the glyph and the words Save or Saved; `overlay` the glyph alone on a photo. |
| `words?` | `Partial<{ save: string; saved: string; }>` |  | The visible words: the labeled form's label, and the glyph forms' tooltip. |

`pressed` and `onPressedChange` hold the mark; pass `useOptimisticToggle`'s `on` and `flip`. `label` is the name, the same in both states, such as "Save Harbour room". `variant` is `icon`, `labeled` or `overlay`. `words` replaces "Save" and "Saved" in the labeled form and in the glyph forms' tooltip. `disabled` turns it off. `className` is for placement, such as `top-1 end-1` on a small photo.

## Usage

### When to use
- A person keeps things to come back to: rooms, listings, papers, funds, saved searches.
- The same thing shows in several places on a page, such as a tile and its panel, and every one of them must say whether it is saved.

### When not to use
- The choice is a setting that changes how the product behaves. Use Switch instead.
- The person follows a thing to hear about it. Use Button instead, labelled Follow, with `useOptimisticToggle` for the state.
- The control filters a list on the page. Use Pill instead.

### Rules
- `rule/save-toggle-acts-at-once`: When a `SaveToggle` saves to a server, drive it with `useOptimisticToggle` instead of `useAction` or a `StateButton`, because a save is a mark the person sets and expects to move under the finger, and `useAction` ignores a second press while the first is pending. Evidence: principle heuristic: visibility of system status, the mark is the answer; person D39, whose feedback table moves a setting at once and back with a message on a failure (docs/system/feedback.md). Check: review of every `SaveToggle` whose `onPressedChange` awaits a request.
  - Don't: `const save = useAction(() => api.save(id)); <SaveToggle pressed={saved} onPressedChange={() => void save.run()} />`
  - Do: `const saved = useOptimisticToggle("saved:" + id, room.saved, { send }); <SaveToggle pressed={saved.on} onPressedChange={saved.flip} label="Save Harbour room" />`
- `rule/save-toggle-one-key-per-thing`: When the same thing has more than 1 control on a page, give every control the same `useOptimisticToggle` key, such as `"saved:" + room.id`, instead of a state per control, because two states drift apart the moment one is pressed and the page then says saved and not saved at once. Evidence: single use docs/system/examples/save-toggle/synced.tsx:22; principle heuristic: consistency and standards, one thing shows one state wherever it appears. Check: review.
  - Don't: `const [saved, setSaved] = useState(room.saved)` in the tile and again in the panel
  - Do: `useOptimisticToggle("saved:" + room.id, room.saved, { send })` in both
- `rule/save-toggle-refusal-says-so`: When a save is refused, move the mark back and say so once in a `toast()` keyed by the thing, through `onRefused`, instead of moving it back in silence, because a mark that quietly undoes itself reads as a press that did not land. Evidence: principle heuristic: visibility of system status; person D39. Check: review of every `useOptimisticToggle` without `onRefused`.
  - Don't: `useOptimisticToggle(key, value, { send })` with no word on a refusal
  - Do: `useOptimisticToggle(key, value, { send, onRefused: () => toast("Could not save Boardroom", { id: key }) })`
- `rule/save-toggle-overlay-only-on-photos`: When a `SaveToggle` uses `variant="overlay"`, place it on a photo inside `MediaTileMedia` or another positioned picture, instead of on a card or the page, because its white edge and dark inside are drawn to read on a picture and fixed in both themes, so on a light card the edge disappears and the mark reads as a grey smudge. Evidence: person D42, the saved mark under its white edge on a photo; principle heuristic: consistency and standards, a mark drawn for one surface is used on it. Check: review of every `variant="overlay"`.
  - Don't: `<Card><SaveToggle variant="overlay" ... /></Card>`
  - Do: `<MediaTileMedia><img src={src} alt="" /><SaveToggle variant="overlay" ... /></MediaTileMedia>`

### Content
- `rule/save-toggle-label-names-the-thing`: When writing `label`, write "Save" and the thing's name, such as "Save Harbour room", and keep it the same in both states, instead of "Save" alone or a name that turns into "Remove", because `aria-pressed` says the state and a list of buttons all named Save is one name for many things. The name is for screen readers; the tooltip shows only Save or Saved, so a long title never fills it. Evidence: principle wcag: 2.4.6 Headings and labels; principle platform: a toggle button keeps its name and changes its pressed state. Check: test `save-toggle.test.tsx` renders the name unchanged in both states.
  - Don't: `<SaveToggle label={saved ? "Remove" : "Save"} ... />`
  - Do: `<SaveToggle label={"Save " + room.name} ... />`

### Anti-slop
- `rule/save-toggle-no-pop`: When the mark changes, let the glyph cross-fade as it does, instead of a scale, a bounce or a burst through `className`, because a save happens many times a day and the system never scales. Evidence: person D36; person D14. Check: lint rule/component-override (scripts/check-system.mjs).
  - Don't: `<SaveToggle className="data-pressed:scale-110 transition-transform" ... />`
  - Do: `<SaveToggle pressed={saved.on} onPressedChange={saved.flip} label="Save Harbour room" />`

### Limits
Not applicable: every form is one 32px control with a fixed name and fixed words, and only the labeled form's words grow with a longer `words` value, checked in docs/system/stress/save-toggle.tsx, where German and French words and an 87-character name hold the button at one line at 320.

## Accessibility
Rests on Base UI `Toggle`, a native `button` with `aria-pressed`.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the toggle | focuses it, shows the outline, and opens a glyph form's tooltip | the toggle | by hand |
| Space | the toggle | saves it, or removes it from saved | stays on the toggle | by hand |
| Enter | the toggle | the same as Space | stays on the toggle | by hand |
| Escape | a glyph form with its tooltip open | closes the tooltip | stays on the toggle | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| toggle | button | `aria-label` from `label` | `aria-pressed` | the name, "toggle button", then "pressed" or "not pressed" | test |
| glyphs and words | none, `aria-hidden` | none | none | nothing; the name and the pressed state say it | test |
| tooltip | tooltip | its text, Save or Saved from `words` | none | the word, once, on hover or focus | by hand |

## Tokens
| Part | State | Token |
|---|---|---|
| icon and labeled forms | all | the Button's tokens: `--control-sm`, `--r-control`, `--muted`, `--muted-foreground`, `--foreground` |
| icon and labeled forms | saved | `--primary`, the accent, on the glyph |
| overlay form | saved | `--primary`, the accent, inside the white edge |
| overlay form | focus-visible | `--r-control` for the outline's corner |
| overlay form | idle | the photo's own white edge and dark inside, which do not change with the theme |
| glyph | swap | `--t-icon`, `--curve-in-out`, `--blur-leave` |

## Related
- Switch: a setting that acts on the flip.
- Pill: an on or off filter on a list.
- MediaTile: the photo the overlay form sits on.
- Toaster: where a refusal is said.
- Reactions: the emoji people reacted with under a message, each a toggle with its count, and a button to add one.
- IconButton: an icon action that keeps nothing for later.
