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

## Description
Shows how much of a known amount is done, as a bar that fills toward its end.

`import { Progress, ProgressLabel, ProgressValue } from "@/components/cobalt/ui/progress"`, source `registry/cobalt/ui/progress.tsx`, status `ready-with-gaps`.
Foundation: `shadcn progress (base-luma, base)`. Traps checked: `trap/motion-layout-property`, `trap/motion-linear`, `trap/reduced-motion-ignored`, `trap/color-only-status`, `trap/live-region-double`, `trap/loading-layout-shift`, `trap/loop-offscreen` (n/a: no loop; the indeterminate state holds still), `trap/demo-on-timers` (n/a: no example steps an animation on a timer; the export in in-card.tsx stands in for a server reporting progress), `trap/illustration-announced` (n/a: the bar is the progressbar itself), `trap/loading-label-swap` (n/a: the label names the task and stays).

### Foundation
| Given by the foundation | Added by the team |
|---|---|
| Base UI `Progress`: `Root` with `role="progressbar"`, `aria-valuenow`, `aria-valuemin`, `aria-valuemax` and `aria-valuetext`, `aria-labelledby` wired to `Label` after mount, `Value` as the formatted text hidden from assistive tech, and `data-progressing`, `data-indeterminate` and `data-complete` on every part; `Track` and `Indicator` | `Progress` renders the track and the fill itself, so a call passes `value` and its label and value children; the fill is the full track scaled from its left edge with `scale-x-(--progress)` on `transition-transform duration-settle`, so progress moves on the compositor and width never animates (the primitive's inline width is held at 100%); the track `h-3 rounded-full bg-muted`, the fill `bg-primary`, the accent, because how much is done is what the accent's fill is for, so it follows the colour the host or the reader picks (it stayed ink under every accent before, audit B, 17 October); the label `text-sm font-medium`, taking the room beside the value and wrapping there, the value `tabular-nums text-muted-foreground` at the row's end (`ms-auto`), never wrapping; the fill grows from the start edge, the right on a right-to-left page; the share is held to the track, so a value past `max` fills it and one under zero, a total of zero or a value that is not a number leaves it empty; without a `format` the value text and `aria-valuetext` read the share through `percent` from `registry/cobalt/lib/format.ts`, so 1,283,999 of 1,284,000 reads 99%, never 100% before it is done |

## Examples
Bars with a label, with and without the value.

Real uses, 0 call sites (`rg -n "<Progress\b" app docs/system/examples --glob '!docs/system/examples/progress/*'`): the showcase chrome renders no Progress of its own yet, and the examples folder does not count.

Uses inside the registry: none. No registry component reports a known amount yet.

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/progress/default.tsx` | default | Bars with a label, with and without the value |
| Not applicable: progressing is the rest state, the bars in default.tsx | state:progressing | The fill at the value's share of the track |
| Not applicable: an unknown amount is Spinner's job (`rule/progress-known-total`), so no example draws the empty track | state:indeterminate | With value null the track stays empty |
| `docs/system/examples/progress/state-complete.tsx` | state:complete | A full bar at 100 percent |
| `docs/system/examples/progress/in-card.tsx` | composition:Card | An export in a card ends in a toast with Download |

Example: Bars with a label, with and without the value (`docs/system/examples/progress/default.tsx`)

```tsx
import { Progress, ProgressLabel, ProgressValue } from "@/components/cobalt/ui/progress";

export default function Example() {
  return (
    <div className="flex max-w-sm flex-col gap-6">
      <Progress value={64}>
        <ProgressLabel>Uploading</ProgressLabel>
        <ProgressValue />
      </Progress>
      <Progress value={20}>
        <ProgressLabel>Importing holdings</ProgressLabel>
      </Progress>
    </div>
  );
}
```

Example: An export in a card ends in a toast with Download (`docs/system/examples/progress/in-card.tsx`)

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

import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/cobalt/ui/card";
import { Progress, ProgressLabel, ProgressValue } from "@/components/cobalt/ui/progress";
import { StateButton } from "@/components/cobalt/ui/state-button";
import { useAction } from "@/lib/cobalt/use-action";

const HOLDINGS = 186;

// Stands in for your API call that starts the export. It answers after 900ms, 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();
    }, 900),
  );

// The finished file, written here so Download saves something real.
const download = () => {
  const first = ["North", "West", "Grand", "Union", "Summit", "Lake"];
  const middle = ["Rail", "Power", "Bank", "Foods", "Mining", "Pharma"];
  const last = ["Corp", "Holdings", "Group", "Inc", "Ltd", "Co"];
  const rows = Array.from({ length: HOLDINGS }, (_, i) => {
    const name = `${first[i % 6]} ${middle[Math.floor(i / 6) % 6]} ${last[Math.floor(i / 36) % 6]}`;
    return `${name},${1_000 + ((i * 7_919) % 90_000)},${(2.4 / (1 + i * 0.08)).toFixed(2)}%`;
  });
  const url = URL.createObjectURL(new Blob([["Holding,Shares,Weight", ...rows].join("\n")], { type: "text/csv" }));
  const link = document.createElement("a");
  link.href = url;
  link.download = "harbour-large-cap-core-holdings.csv";
  link.click();
  URL.revokeObjectURL(url);
};

export default function Example() {
  // How many holdings are written so far; null when no export is running.
  const [written, setWritten] = useState<number | null>(null);
  const [exported, setExported] = useState(false);
  const start = useAction(async () => {
    await request();
    setWritten(0);
  });
  // The export runs for a few seconds. You can leave the card; the toast says when the file is ready.
  useEffect(() => {
    if (written === null) return;
    const timer = setTimeout(() => {
      const next = written + 5;
      if (next < HOLDINGS) {
        setWritten(next);
        return;
      }
      setWritten(null);
      setExported(true);
      toast("Holdings export ready", {
        description: `${HOLDINGS} rows, as a spreadsheet.`,
        duration: 10_000,
        action: { label: "Download", onClick: download },
      });
    }, 150);
    return () => clearTimeout(timer);
  }, [written]);
  const running = written !== null;
  return (
    <Card className="w-full max-w-sm">
      <CardHeader>
        <CardTitle>Holdings export</CardTitle>
        <CardDescription>Harbour Large Cap Core, from the filing of Aug 29.</CardDescription>
      </CardHeader>
      {/* The two lines and the bar share one cell, and the bar stays, hidden, while it is not
          running. At rest the cell holds what the file is, a line and a line under it, as tall as
          the bar's label over its track, so starting the export moves nothing. */}
      <CardContent className="grid *:col-start-1 *:row-start-1">
        <Progress value={written ?? 0} max={HOLDINGS} className={running ? "self-start" : "invisible self-start"}>
          <ProgressLabel>Exporting</ProgressLabel>
          <ProgressValue />
        </Progress>
        {!running && (
          <div className="flex flex-col gap-0.5 text-sm">
            <p className="font-medium">{HOLDINGS} holdings</p>
            {/* A failed start says why in the line that is already here, so nothing moves. */}
            <p className="text-muted-foreground">
              {start.error !== null ? (
                <span className="text-destructive">The export did not start. Try again.</span>
              ) : exported ? (
                "Exported just now."
              ) : (
                "A spreadsheet with shares and weights."
              )}
            </p>
          </div>
        )}
      </CardContent>
      <CardFooter>
        <StateButton
          variant="secondary"
          className="w-full"
          status={start.status}
          pendingLabel="Starting"
          successLabel="Started"
          failureLabel="Not started"
          disabled={running}
          onClick={() => void start.run()}
        >
          {exported ? "Export again" : "Export holdings"}
        </StateButton>
      </CardFooter>
    </Card>
  );
}
```

## Variants
Not applicable: Progress has no variant axis. The bar is 12px tall, the accent over grey, at the width of its container.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| progressing | `value` between 0 and `max` | wait, read the value | the fill's length along the track, `aria-valuenow` and the value text | test |
| indeterminate | `value={null}` | wait | the empty track with `data-indeterminate` and `aria-valuetext="indeterminate progress"`; nothing moves, so only the label tells of work going on | test |
| complete | `value` equal to `max` | read | the fill at the track's end, `data-complete`, the value text at 100 percent | test |

Example: A full bar at 100 percent (`docs/system/examples/progress/state-complete.tsx`)

```tsx
import { Progress, ProgressLabel, ProgressValue } from "@/components/cobalt/ui/progress";

export default function Example() {
  return (
    <Progress value={100} className="max-w-sm">
      <ProgressLabel>Uploaded</ProgressLabel>
      <ProgressValue />
    </Progress>
  );
}
```

### State precedence
- Progressing and complete: complete wins when `value` reaches `max`. The fill covers the track and `data-complete` replaces `data-progressing`.
- Indeterminate and progressing: Not applicable: `value` is `null` or a number.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| `value` changes | announce | `duration-settle`, `--t-settle` 300ms on `--curve`; Settle, the control telling you its state; eased, measured `cubic-bezier(0.23, 1, 0.32, 1)` over 0.3s, .design-system/evidence/progress/measure-1280.json | scale, the full-width fill scaled from its left edge; width never animates | the base layer limits transitions to opacity and colour, so the fill jumps to its new length |

## Props

<!-- Props generated from registry/cobalt/ui/progress.tsx with TypeScript by scripts/props-table.mjs -->
### Progress

No props of its own.

Also accepts every native `<div>` attribute; from Base UI: `aria-valuetext`, `format`, `getAriaValueText`, `locale`, `max`, `min`, `render`, `value`.

### ProgressLabel

No props of its own.

Also accepts every native `<span>` attribute; from Base UI: `render`.

### ProgressValue

No props of its own.

Also accepts every native `<span>` attribute; from Base UI: `render`.

`value` is the amount done, `null` for indeterminate, and `max` is the total, 100 by default. Base UI's `format`, `locale` and `getAriaValueText` pass to the root and shape the value text. Children are the `ProgressLabel` and `ProgressValue`, rendered before the track in a wrapping row; `className` on the root sets the width.

## Usage

### When to use
- A known amount of work is being done, such as an upload, an import or the steps of a setup, and the user waits on it.

### When not to use
- The amount of work is not known. Use Spinner instead.
- The content's shape is known and it is on its way. Use Skeleton instead.
- A button is waiting on its own press. Use StateButton instead.

### Rules
- `rule/progress-known-total`: When the amount of work is not known, render `Spinner` instead of `Progress` with `value={null}`, because the indeterminate state draws an empty track with nothing moving, so nothing tells the user that work is going on. Evidence: principle heuristic: visibility of system status, a still empty bar reports nothing; measured `--progress: 0` with no animation on `value={null}`, asserted in `progress.test.tsx`. Check: test `progress.test.tsx` renders `value={null}` and finds `data-indeterminate` with `--progress:0`; review of every `value={null}`.
  - Don't: `<Progress value={null} />`
  - Do: `<Spinner label="Importing" />`
- `rule/progress-label-names-the-task`: When the bar has no visible heading naming the task, give it a `ProgressLabel` in the -ing form, such as "Uploading", and a `ProgressValue`, instead of a bare bar, because the label becomes the bar's name through `aria-labelledby` and the value is read as `aria-valuetext`; a bare bar is announced as a progress bar at 64 percent of nothing in particular. Evidence: principle wcag: 4.1.2 Name, role, value; measured `aria-labelledby` set to the label's id after mount, .design-system/evidence/progress/measure-1280.json. Check: test `progress.test.tsx` expects the label's id and the value text; a11y scan on the showcase.
  - Don't: `<Progress value={64} />`
  - Do: `<Progress value={64}><ProgressLabel>Uploading</ProgressLabel><ProgressValue /></Progress>`
- `rule/progress-moves-on-scale`: When a host styles the fill, keep it as the scaled full track instead of transitioning `width`, `left` or a variable on an ancestor, because width runs layout every frame and stutters on slow devices, while the scale runs on the compositor. Evidence: measured the fill's transition on `transform, translate, scale, rotate` at 0.3s with `width: 100%` held inline, .design-system/evidence/progress/measure-1280.json; principle platform: compositor-only properties, transform and opacity. Check: probe .design-system/scripts/measure-feedback.mjs reads the fill's transition properties; review.
  - Don't: `<Progress value={done} className="[&_[data-slot=progress-indicator]]:transition-[width]" />`
  - Do: `<Progress value={done} />`
- `rule/progress-state-in-words`: When the task pauses or fails, say so in `ProgressLabel`, such as "Upload paused", instead of recolouring the fill, because the fill is the accent and stays the accent, and a red fill tells nothing to the user who cannot see the hue. Evidence: person D13; principle wcag: 1.4.1 Use of color. Check: lint rule/component-override on Progress (scripts/check-system.mjs); review.
  - Don't: `<Progress value={40} className="[&_[data-slot=progress-indicator]]:bg-bad" />`
  - Do: `<Progress value={40}><ProgressLabel>Upload paused</ProgressLabel><ProgressValue /></Progress>`

### Content
- Follows `rule/writing-status-verb-ing`.
- `rule/progress-value-from-the-primitive`: When the value is shown, render `ProgressValue`, shaped by `format` where percent is wrong, instead of writing the number by hand beside the bar, because the primitive's text is also the `aria-valuetext`, so the eye and the ear get the same number. Evidence: principle wcag: 4.1.2 Name, role, value; measured `aria-valuetext="64%"` equal to the value text, .design-system/evidence/progress/measure-1280.json. Check: test `progress.test.tsx` expects "64%" in the value text and in `aria-valuetext`.
  - Don't: `<Progress value={64}><span>64%</span></Progress>`
  - Do: `<Progress value={64}><ProgressValue /></Progress>`

### Anti-slop
- `rule/progress-plain-fill`: When a progress bar is wanted, use `Progress` as it is, the 12px grey track under the accent fill, instead of a gradient, a striped fill or a fill recoloured through `className`, because the plain accent follows the colour the host or the reader picks and a gradient is a banned fill. Evidence: single use `registry/cobalt/ui/progress.tsx:80`, the fill is `bg-primary`, as Kaan asked on 2026-10-17 through audit B, where it stayed ink under every accent; person D12. Check: lint rule/ban-gradient (scripts/check-system.mjs); review.
  - Don't: `<Progress value={64} className="[&_[data-slot=progress-indicator]]:bg-linear-to-r [&_[data-slot=progress-indicator]]:from-primary" />`
  - Do: `<Progress value={64} />`

### Limits
Not applicable: the bar takes its container's width, 310px at 390 where the label and the value share one row and the track wraps under them (.design-system/evidence/progress/measure-1280.json, `narrow390`), and no count or length has been grown to a break.

## Accessibility
Rests on Base UI `Progress`, a `div` with `role="progressbar"`. Contrast, as drawn (.design-system/evidence/progress/measure-1280.json): the fill on the track 17.03:1 light and 14.5:1 dark; the label on the card 19.8:1 light and 17.18:1 dark; the value 6.01:1 light and 6.94:1 dark; the track against the card 1.16:1 light and 1.18:1 dark, under the 3:1 of WCAG 1.4.11 Non-text contrast, so the amount left reads from the fill's end alone. NEEDS REVIEW.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the bar | skips it, it is not focusable | the next control | test |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| root | progressbar | `ProgressLabel` through `aria-labelledby`, set after mount; the server markup has none | `aria-valuenow`, `aria-valuemin`, `aria-valuemax`, `aria-valuetext`; `data-progressing`, `data-indeterminate`, `data-complete` | the name, "progress bar" and the value text when a reader reaches it; a change is not announced live | test |
| label | presentation | nothing | its `id`, which the root names | nothing of its own | test |
| value | none, `aria-hidden="true"` | nothing | none | nothing; the root's `aria-valuetext` carries the number | test |

## Tokens
| Part | State | Token |
|---|---|---|
| track | all | `--muted` |
| fill | all | `--primary`, `--t-settle`, `--curve` |
| label | all | `--foreground` |
| value | all | `--muted-foreground` |

## Related
- Spinner: a wait whose amount is not known.
- Skeleton: content on its way, whose shape is known.
- StateButton: a button that reports its own action in place.
- Timeline: events in order of time, with no amount to fill.
- Meter: how much of a fixed allowance is used, such as seats or requests.
- Trace: the steps an agent took to answer, folded under one line, each queued, running, done or failed.
