# Checkbox

Turns one option on or off, independently of the others.

Turn one option on or off, independently of the others. A 16px box on a hairline ring that fills with ink when checked; the box fills first and the check is then drawn from the inline start (the dash of the indeterminate state from its centre); unchecking is a shorter plain fade. The whole row, label included, is the hit area. Behaviour, focus and ARIA come from the Zag checkbox machine, through Ark UI in React, Vue and Svelte. A visually hidden native checkbox carries focus, Space and the form value.

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

## Add

```bash
npx fndn add checkbox
```

It writes the folder `checkbox/` into the project's ui folder (`index.ts`, `checkbox.tsx`, `Checkbox.vue`, `Checkbox.svelte`, `checkbox.recipe.ts`). First time: [Installation](/installation.md).

## Usage

```tsx
import { Checkbox } from "@/components/ui/checkbox";
```

```vue
import { Checkbox } from "@/components/ui/checkbox";
```

```svelte
import { Checkbox } from "$lib/components/ui/checkbox";
```

## Parts

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

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `label` | `checkbox` |  | The row and its hit area; data-state=checked\|unchecked\|indeterminate, data-disabled, data-invalid, data-focus-visible. In row layout it composes the shared option row (`lib/option.ts`). Wrapper rule: class and style land on this outermost element (what a caller sizes and places); every other attribute stays on the control. |
| `control` | `div` | `checkbox-control` |  | The 16px box (18px at size md; aria-hidden); same state attributes as the root; carries kbd-instant. Usable outside the label: written by hand in an option row (with this recipe's control and mark classes) it hovers and presses with that row. |
| `mark` | `span` | `checkbox-mark` | repeats | Decorative check (data-mark=check) and dash (data-mark=indeterminate); shown through the control's data-state; carries kbd-instant |
| `label` | `span` | `checkbox-label` | optional | Visible label; wraps when long |
| `input` | `input` | `checkbox-input` |  | Native checkbox, visually hidden: focus, Space and the form value |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `checked` | `string` |  | Bindable (React: `defaultChecked` and `onCheckedChange`; Vue: `v-model:checked`; Svelte: `bind:checked`). true, false or "indeterminate". |
| `label` | `string` |  | Visible label; otherwise pass aria-label. |
| `size` | `"sm" \| "md"` | `"sm"` | sm: the 16px box. md: an 18px box, for table rows. |
| `tone` | `"ink" \| "red" \| "green"` | `"ink"` | Colour of the checked fill: ink, or red / green for a change to remove / add. The mark is white on red and green in both themes. |
| `layout` | `"inline" \| "row"` | `"inline"` | inline: the box with its label, sized to the text. row: fills a 30px option row (`lib/option.ts`: padding, radius, press hover-2) in a list that owns one glide highlight (`glideLayer` of `lib/glide.ts`; glide(list, layer, { rows: "[data-slot=checkbox]", follow: "hover" })); the box is drawn the same. |
| `disabled` | `boolean` | `false` |  Reaches the input in every target. |
| `tabIndex` | `number` |  | tabindex of the input (the focusable part), for a host that runs a roving tab stop over several boxes (diff-table). |
| `invalid` | `boolean` | `false` |  |
| `name` | `string` |  | Form field name. |
| `value` | `string` | `"on"` | Form value when checked. |

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

## Events

| Event | Payload |
| --- | --- |
| `checkedChange` | (checked: boolean \| "indeterminate") |

## States

`checked`, `indeterminate`, `hover`, `press`, `focus-visible`, `disabled`, `invalid`, `kbd-instant`, `reduced-motion`, `size-md`, `tone-red`, `tone-green`, `row`

## Keyboard and accessibility

Role: checkbox.

Keyboard:

- Tab reaches each checkbox; every box is its own tab stop
- Space toggles

Notes:

- Give it a visible label or an aria-label.
- Indeterminate is reported as mixed (the native input's indeterminate state).
- Several related checkboxes sit in a group with a label (role=group + aria-label, or a fieldset).
- To set it from outside, control `checked` (true, false or "indeterminate"): React checked / onCheckedChange, Vue v-model:checked, Svelte bind:checked.
- Outside setters: the `checked` and `disabled` props.

## Motion

- box on: fill and ring colour over duration.fast, ease; it leads
- check on: drawn by a clip-path wipe from the inline start, inset(0 100% 0 0) to inset(0), over duration.base with easing.out-strong, delayed by duration.stagger so the fill leads; no scale, no opacity ramp; the glyph is not mirrored right to left, so neither is the wipe
- dash on: the same wipe from its centre, inset(0 50%) to inset(0)
- off (and the old mark when check and dash swap): opacity to 0 over duration.fast with easing.out-strong, no wipe, no delay; the box empties over duration.fast; the clip resets after the fade
- press (pointer only): the box scales to motion.press-scale-sm over duration.press with easing.out-strong and springs back the same way
- keyboard (Space): instant; the control and both marks carry kbd-instant and the mark's delay drops
- mount: nothing animates on the first paint, in every target
- reduced motion: no wipe; the marks fade over duration.fast both ways; the press stays
- size, tone and row layout change no motion: the same fill, wipe, exit and press; in a row the press also darkens the row (hover-2)

## Tokens

`color.ink`, `color.ink-3`, `color.on-ink`, `color.line-strong`, `color.accent`, `color.red`, `text.sm`, `duration.fast`, `duration.base`, `duration.press`, `duration.stagger`, `easing.out-strong`, `motion.press-scale-sm`, `color.green`, `color.on-accent`, `text.md`

## Examples

### Email notifications

React · `email-notifications.tsx`

```tsx
import { Checkbox } from "@/components/ui/checkbox";

/* independent options under one heading: a fieldset and its legend name the group */
export default function EmailNotifications() {
  return (
    <fieldset className="flex w-80 flex-col gap-2.5">
      <legend className="mb-3 text-sm font-medium text-ink">Email me when</legend>
      <Checkbox name="email" value="deploy-failed" label="A deploy to Production fails" defaultChecked />
      <Checkbox name="email" value="review-requested" label="Someone requests my review" defaultChecked />
      <Checkbox name="email" value="usage" label="Usage passes 80% of the Team plan" />
    </fieldset>
  );
}
```

Vue · `email-notifications.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Checkbox } from "@/components/ui/checkbox";

/* independent options under one heading: a fieldset and its legend name the group */
const deployFailed = ref(true);
const reviewRequested = ref(true);
const usage = ref(false);
</script>

<template>
  <fieldset class="flex w-80 flex-col gap-2.5">
    <legend class="mb-3 text-sm font-medium text-ink">Email me when</legend>
    <Checkbox v-model:checked="deployFailed" name="email" value="deploy-failed" label="A deploy to Production fails" />
    <Checkbox v-model:checked="reviewRequested" name="email" value="review-requested" label="Someone requests my review" />
    <Checkbox v-model:checked="usage" name="email" value="usage" label="Usage passes 80% of the Team plan" />
  </fieldset>
</template>
```

Svelte · `email-notifications.svelte`

```svelte
<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox";

  /* independent options under one heading: a fieldset and its legend name the group */
  let deployFailed = $state(true);
  let reviewRequested = $state(true);
  let usage = $state(false);
</script>

<fieldset class="flex w-80 flex-col gap-2.5">
  <legend class="mb-3 text-sm font-medium text-ink">Email me when</legend>
  <Checkbox bind:checked={deployFailed} name="email" value="deploy-failed" label="A deploy to Production fails" />
  <Checkbox bind:checked={reviewRequested} name="email" value="review-requested" label="Someone requests my review" />
  <Checkbox bind:checked={usage} name="email" value="usage" label="Usage passes 80% of the Team plan" />
</fieldset>
```

### Select all environments (mixed state)

React · `select-environments.tsx`

```tsx
import { useState } from "react";
import { Checkbox } from "@/components/ui/checkbox";

/* select all: checked when every child is, indeterminate when some are */
const ENVIRONMENTS = ["Production", "Staging", "Preview"];

export default function SelectEnvironments() {
  const [picked, setPicked] = useState<string[]>(["Production"]);
  const all = picked.length === ENVIRONMENTS.length ? true : picked.length ? "indeterminate" : false;
  const toggle = (env: string, on: boolean) => setPicked(on ? [...picked, env] : picked.filter((p) => p !== env));
  return (
    <div className="flex flex-col gap-2.5">
      <Checkbox label="Redeploy in all environments" checked={all} onCheckedChange={(v) => setPicked(v === true ? ENVIRONMENTS : [])} />
      <div className="flex flex-col gap-2.5 ps-6">
        {ENVIRONMENTS.map((env) => (
          <Checkbox key={env} label={env} checked={picked.includes(env)} onCheckedChange={(v) => toggle(env, v === true)} />
        ))}
      </div>
    </div>
  );
}
```

Vue · `select-environments.vue`

```vue
<script setup lang="ts">
import { computed, ref } from "vue";
import { Checkbox } from "@/components/ui/checkbox";

/* select all: checked when every child is, indeterminate when some are */
const ENVIRONMENTS = ["Production", "Staging", "Preview"];

const picked = ref<string[]>(["Production"]);
const all = computed(() => (picked.value.length === ENVIRONMENTS.length ? true : picked.value.length ? "indeterminate" : false));
const toggle = (env: string, on: boolean) => (picked.value = on ? [...picked.value, env] : picked.value.filter((p) => p !== env));
</script>

<template>
  <div class="flex flex-col gap-2.5">
    <Checkbox label="Redeploy in all environments" :checked="all" @update:checked="(v) => (picked = v === true ? ENVIRONMENTS : [])" />
    <div class="flex flex-col gap-2.5 ps-6">
      <Checkbox
        v-for="env in ENVIRONMENTS"
        :key="env"
        :label="env"
        :checked="picked.includes(env)"
        @update:checked="(v) => toggle(env, v === true)"
      />
    </div>
  </div>
</template>
```

Svelte · `select-environments.svelte`

```svelte
<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox";

  /* select all: checked when every child is, indeterminate when some are */
  const ENVIRONMENTS = ["Production", "Staging", "Preview"];

  let picked = $state<string[]>(["Production"]);
  const all = $derived(picked.length === ENVIRONMENTS.length ? true : picked.length ? "indeterminate" : false);
  const toggle = (env: string, on: boolean) => (picked = on ? [...picked, env] : picked.filter((p) => p !== env));
</script>

<div class="flex flex-col gap-2.5">
  <Checkbox label="Redeploy in all environments" checked={all} oncheckedchange={(v) => (picked = v === true ? ENVIRONMENTS : [])} />
  <div class="flex flex-col gap-2.5 ps-6">
    {#each ENVIRONMENTS as env (env)}
      <Checkbox label={env} checked={picked.includes(env)} oncheckedchange={(v) => toggle(env, v === true)} />
    {/each}
  </div>
</div>
```

### Selecting table rows

React · `select-rows.tsx`

```tsx
import { useState } from "react";
import { Checkbox } from "@/components/ui/checkbox";

/* md (18px) in table rows; no visible label, so each box is named after its row */
const projects = [
  { name: "web-app", deployed: "2 min ago" },
  { name: "billing-api", deployed: "Nov 14, 2026" },
  { name: "data-pipeline", deployed: "Nov 9, 2026" },
];

export default function SelectRows() {
  const [selected, setSelected] = useState<string[]>(["billing-api"]);
  return (
    <div className="flex w-80 flex-col gap-2">
      <p className="text-xs text-ink-2" role="status">{selected.length} of {projects.length} projects selected</p>
      <table className="w-full text-sm">
        <tbody>
          {projects.map((p) => (
            <tr key={p.name}>
              <td className="w-8 py-1.5">
                <Checkbox
                  size="md"
                  aria-label={`Select ${p.name}`}
                  checked={selected.includes(p.name)}
                  onCheckedChange={(v) => setSelected(v === true ? [...selected, p.name] : selected.filter((s) => s !== p.name))}
                />
              </td>
              <td className="py-1.5 text-ink">{p.name}</td>
              <td className="py-1.5 text-end text-ink-2">{p.deployed}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}
```

Vue · `select-rows.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Checkbox } from "@/components/ui/checkbox";

/* md (18px) in table rows; no visible label, so each box is named after its row */
const projects = [
  { name: "web-app", deployed: "2 min ago" },
  { name: "billing-api", deployed: "Nov 14, 2026" },
  { name: "data-pipeline", deployed: "Nov 9, 2026" },
];

const selected = ref<string[]>(["billing-api"]);
</script>

<template>
  <div class="flex w-80 flex-col gap-2">
    <p class="text-xs text-ink-2" role="status">{{ selected.length }} of {{ projects.length }} projects selected</p>
    <table class="w-full text-sm">
      <tbody>
        <tr v-for="p in projects" :key="p.name">
          <td class="w-8 py-1.5">
            <Checkbox
              size="md"
              :aria-label="`Select ${p.name}`"
              :checked="selected.includes(p.name)"
              @update:checked="(v) => (selected = v === true ? [...selected, p.name] : selected.filter((s) => s !== p.name))"
            />
          </td>
          <td class="py-1.5 text-ink">{{ p.name }}</td>
          <td class="py-1.5 text-end text-ink-2">{{ p.deployed }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
```

Svelte · `select-rows.svelte`

```svelte
<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox";

  /* md (18px) in table rows; no visible label, so each box is named after its row */
  const projects = [
    { name: "web-app", deployed: "2 min ago" },
    { name: "billing-api", deployed: "Nov 14, 2026" },
    { name: "data-pipeline", deployed: "Nov 9, 2026" },
  ];

  let selected = $state<string[]>(["billing-api"]);
</script>

<div class="flex w-80 flex-col gap-2">
  <p class="text-xs text-ink-2" role="status">{selected.length} of {projects.length} projects selected</p>
  <table class="w-full text-sm">
    <tbody>
      {#each projects as p (p.name)}
        <tr>
          <td class="w-8 py-1.5">
            <Checkbox
              size="md"
              aria-label={`Select ${p.name}`}
              checked={selected.includes(p.name)}
              oncheckedchange={(v) => (selected = v === true ? [...selected, p.name] : selected.filter((s) => s !== p.name))}
            />
          </td>
          <td class="py-1.5 text-ink">{p.name}</td>
          <td class="py-1.5 text-end text-ink-2">{p.deployed}</td>
        </tr>
      {/each}
    </tbody>
  </table>
</div>
```

### Access changes to apply (add / remove)

React · `access-changes.tsx`

```tsx
import { Checkbox } from "@/components/ui/checkbox";

/* tone: green for a change that adds, red for one that removes; the label says which */
export default function AccessChanges() {
  return (
    <fieldset className="flex w-80 flex-col gap-2.5">
      <legend className="mb-3 text-sm font-medium text-ink">Apply 2 access changes</legend>
      <Checkbox tone="green" defaultChecked label="Add Priya Raman to billing-api as maintainer" />
      <Checkbox tone="red" defaultChecked label="Remove Lucas Moreau from mobile" />
    </fieldset>
  );
}
```

Vue · `access-changes.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Checkbox } from "@/components/ui/checkbox";

/* tone: green for a change that adds, red for one that removes; the label says which */
const add = ref(true);
const remove = ref(true);
</script>

<template>
  <fieldset class="flex w-80 flex-col gap-2.5">
    <legend class="mb-3 text-sm font-medium text-ink">Apply 2 access changes</legend>
    <Checkbox v-model:checked="add" tone="green" label="Add Priya Raman to billing-api as maintainer" />
    <Checkbox v-model:checked="remove" tone="red" label="Remove Lucas Moreau from mobile" />
  </fieldset>
</template>
```

Svelte · `access-changes.svelte`

```svelte
<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox";

  /* tone: green for a change that adds, red for one that removes; the label says which */
  let add = $state(true);
  let remove = $state(true);
</script>

<fieldset class="flex w-80 flex-col gap-2.5">
  <legend class="mb-3 text-sm font-medium text-ink">Apply 2 access changes</legend>
  <Checkbox bind:checked={add} tone="green" label="Add Priya Raman to billing-api as maintainer" />
  <Checkbox bind:checked={remove} tone="red" label="Remove Lucas Moreau from mobile" />
</fieldset>
```

### Confirm before deleting (invalid)

React · `confirm-delete.tsx`

```tsx
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";

/* invalid until confirmed: the error says what to do, the action waits for it */
export default function ConfirmDelete() {
  const [confirmed, setConfirmed] = useState(false);
  return (
    <div className="flex w-80 flex-col items-start gap-3">
      <div className="flex flex-col gap-1">
        <Checkbox
          label="I understand that billing-api and its 128 deploys are deleted for good"
          checked={confirmed}
          onCheckedChange={(v) => setConfirmed(v === true)}
          invalid={!confirmed}
        />
        {!confirmed && <p className="ps-6 text-xs text-red">Confirm to delete the project.</p>}
      </div>
      <Button variant="danger" size="sm" disabled={!confirmed}>Delete billing-api</Button>
    </div>
  );
}
```

Vue · `confirm-delete.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";

/* invalid until confirmed: the error says what to do, the action waits for it */
const confirmed = ref(false);
</script>

<template>
  <div class="flex w-80 flex-col items-start gap-3">
    <div class="flex flex-col gap-1">
      <Checkbox
        label="I understand that billing-api and its 128 deploys are deleted for good"
        :checked="confirmed"
        @update:checked="(v) => (confirmed = v === true)"
        :invalid="!confirmed"
      />
      <p v-if="!confirmed" class="ps-6 text-xs text-red">Confirm to delete the project.</p>
    </div>
    <Button variant="danger" size="sm" :disabled="!confirmed">Delete billing-api</Button>
  </div>
</template>
```

Svelte · `confirm-delete.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Checkbox } from "$lib/components/ui/checkbox";

  /* invalid until confirmed: the error says what to do, the action waits for it */
  let confirmed = $state(false);
</script>

<div class="flex w-80 flex-col items-start gap-3">
  <div class="flex flex-col gap-1">
    <Checkbox
      label="I understand that billing-api and its 128 deploys are deleted for good"
      checked={confirmed}
      oncheckedchange={(v) => (confirmed = v === true)}
      invalid={!confirmed}
    />
    {#if !confirmed}<p class="ps-6 text-xs text-red">Confirm to delete the project.</p>{/if}
  </div>
  <Button variant="danger" size="sm" disabled={!confirmed}>Delete billing-api</Button>
</div>
```

### Not on your plan (disabled)

React · `plan-locked.tsx`

```tsx
import { Checkbox } from "@/components/ui/checkbox";

/* disabled: the option is shown so people know it exists, with the reason beside it */
export default function PlanLocked() {
  return (
    <div className="flex flex-col gap-1">
      <Checkbox label="Sign in with SAML single sign-on" disabled />
      <p className="ps-6 text-xs text-ink-2">Available on the Business plan.</p>
    </div>
  );
}
```

Vue · `plan-locked.vue`

```vue
<script setup lang="ts">
import { Checkbox } from "@/components/ui/checkbox";
</script>

<!-- disabled: the option is shown so people know it exists, with the reason beside it -->
<template>
  <div class="flex flex-col gap-1">
    <Checkbox label="Sign in with SAML single sign-on" disabled />
    <p class="ps-6 text-xs text-ink-2">Available on the Business plan.</p>
  </div>
</template>
```

Svelte · `plan-locked.svelte`

```svelte
<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox";
</script>

<!-- disabled: the option is shown so people know it exists, with the reason beside it -->
<div class="flex flex-col gap-1">
  <Checkbox label="Sign in with SAML single sign-on" disabled />
  <p class="ps-6 text-xs text-ink-2">Available on the Business plan.</p>
</div>
```

## Recipe

`checkbox.recipe.ts`:

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

/* checkbox — 16px box on the Zag checkbox machine (data-state=checked|unchecked|indeterminate).
 * The root is a <label>, so the text is part of the hit area; a visually hidden native checkbox
 * carries focus, Space and the form value. The label line is 18px and the box sits 1px down,
 * so box and first text line share one centre line, and a wrapped label keeps the box on line one.
 *
 * Parts are found by data-slot
 * (checkbox, checkbox-control, checkbox-mark, checkbox-label, checkbox-input); the root slot is
 * `base`. The two marks are told apart by data-mark (check | indeterminate). The control also works
 * outside the label, written by hand in an option row (a menu checkbox item: menu imports this
 * recipe): it hovers and presses with whatever element holds it. */

/* the label; in a row the shared option row goes first, so all of this wins over it */
const BASE = [
  "relative inline-flex items-start gap-2 min-w-0 max-w-full text-sm leading-[18px] text-ink cursor-pointer",
  "select-none touch-manipulation [-webkit-touch-callout:none]",
  "data-disabled:opacity-50 data-disabled:cursor-default data-disabled:pointer-events-none",
];

export const checkbox = tv({
  slots: {
    base: BASE,
    /* a box with no visible label still gets a 24px target (::after) */
    control: [
      "kbd-instant",
      "relative grid place-items-center shrink-0 size-4 my-px rounded-[5px] bg-transparent text-on-ink",
      "shadow-[inset_0_0_0_1.5px_var(--fndn-line-strong)]",
      "after:content-[''] after:absolute after:-inset-1",
      "[@media(hover:hover)_and_(pointer:fine)]:[:hover>&[data-state=unchecked]]:shadow-[inset_0_0_0_1.5px_var(--fndn-ink-3)]",
      "data-invalid:data-[state=unchecked]:shadow-[inset_0_0_0_1.5px_var(--fndn-red)]",
      "data-focus-visible:outline-2 data-focus-visible:outline-solid data-focus-visible:outline-accent data-focus-visible:outline-offset-2",
      /* the fill leads: colour over `fast`, both ways. Press: pointer only (Space also makes the
       * label :active, and keyboard changes are instant). The holder is the label, or the option row
       * a hand-written control sits in. */
      "motion-colors-fast motion-shadow-fast motion-transform-press",
      "[:root:not([data-fndn-input=keyboard])_:active>&]:scale-press-sm",
    ],
    /* both marks share the box's one grid cell; the control's state picks the one that shows */
    mark: [
      "kbd-instant",
      "[grid-area:1/1] inline-flex text-[12px]",
      /* On: the mark is drawn, not popped. A clip-path wipe (the check from the inline start, the
       * dash from its centre) starts one stagger step after the fill, so the fill leads and the mark
       * lands on ink. Off: shorter and simpler, the mark fades over `fast` while the box empties; the
       * clip resets only once the fade is over, so an interrupted toggle retargets from where it is.
       * Keyboard changes are instant: kbd-instant zeroes the durations and delays. */
      "opacity-0 [clip-path:inset(0_100%_0_0)] data-[mark=indeterminate]:[clip-path:inset(0_50%)]",
      "[transition:opacity_var(--fndn-duration-fast)_ease,clip-path_0ms_linear_var(--fndn-duration-fast)]",
      "[[data-state=checked]>&[data-mark=check]]:opacity-100 [[data-state=checked]>&[data-mark=check]]:[clip-path:inset(0)] [[data-state=checked]>&[data-mark=check]]:[transition:opacity_0ms_linear,clip-path_var(--fndn-duration-base)_var(--fndn-easing-out-strong)_var(--fndn-duration-stagger)] [[data-state=indeterminate]>&[data-mark=indeterminate]]:opacity-100 [[data-state=indeterminate]>&[data-mark=indeterminate]]:[clip-path:inset(0)] [[data-state=indeterminate]>&[data-mark=indeterminate]]:[transition:opacity_0ms_linear,clip-path_var(--fndn-duration-base)_var(--fndn-easing-out-strong)_var(--fndn-duration-stagger)]",
      /* reduced motion: no wipe; the mark fades over `fast` both ways (the old one drops faster, so
       * a check/dash swap does not read as two marks) */
      "motion-reduce:[clip-path:none] motion-reduce:data-[mark=indeterminate]:[clip-path:none] motion-reduce:[transition:opacity_var(--fndn-duration-fast)_ease]",
      "[[data-state=checked]>&[data-mark=check]]:motion-reduce:[clip-path:none] [[data-state=checked]>&[data-mark=check]]:motion-reduce:[transition:opacity_var(--fndn-duration-fast)_ease] [[data-state=indeterminate]>&[data-mark=indeterminate]]:motion-reduce:[clip-path:none] [[data-state=indeterminate]>&[data-mark=indeterminate]]:motion-reduce:[transition:opacity_var(--fndn-duration-fast)_ease]",
    ],
    /* author text reads in its own direction; the alignment stays on the page's side */
    label: "min-w-0 [overflow-wrap:anywhere] [unicode-bidi:plaintext] [&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
    /* the native checkbox: present for focus, keys and forms, never seen (sr-only does the hiding) */
    input: "sr-only opacity-0 pointer-events-none",
  },
  variants: {
    /* md: an 18px box for table rows (the label line stays 18px, so the box needs no offset) */
    size: {
      sm: {},
      md: { control: "size-[18px] my-0" },
    },
    /* the checked (and indeterminate) fill; red and green carry the on-accent mark, white in both themes */
    tone: {
      ink: {
        control: [
          "data-[state=checked]:bg-ink data-[state=checked]:shadow-[inset_0_0_0_1.5px_var(--fndn-ink)]",
          "data-[state=indeterminate]:bg-ink data-[state=indeterminate]:shadow-[inset_0_0_0_1.5px_var(--fndn-ink)]",
        ],
      },
      red: {
        control: [
          "data-[state=checked]:bg-red data-[state=checked]:shadow-[inset_0_0_0_1.5px_var(--fndn-red)] data-[state=checked]:text-on-accent",
          "data-[state=indeterminate]:bg-red data-[state=indeterminate]:shadow-[inset_0_0_0_1.5px_var(--fndn-red)] data-[state=indeterminate]:text-on-accent",
        ],
      },
      green: {
        control: [
          "data-[state=checked]:bg-green data-[state=checked]:shadow-[inset_0_0_0_1.5px_var(--fndn-green)] data-[state=checked]:text-on-accent",
          "data-[state=indeterminate]:bg-green data-[state=indeterminate]:shadow-[inset_0_0_0_1.5px_var(--fndn-green)] data-[state=indeterminate]:text-on-accent",
        ],
      },
    },
    /* row: the checkbox fills a list row. The root composes the shared option row (recipe
     * `option`: metrics, radius, press); the list owns the one glide layer. The text line stays 18px and the row pads it
     * to the option height, so a wrapped label keeps the box on line one. */
    layout: {
      inline: {},
      row: {
        base: [
          option().base(), ...BASE,
          "flex w-full max-w-none text-dense py-[calc((var(--option-height,30px)_-_18px)_/_2)]",
          "pointer-coarse:text-md pointer-coarse:py-[calc((max(40px,var(--option-height,30px))_-_18px)_/_2)]",
        ],
      },
    },
  },
  defaultVariants: { size: "sm", tone: "ink", layout: "inline" },
});

export type CheckboxRecipeProps = VariantProps<typeof checkbox>;
```
