How it works
A track in --ds-chart-track and a round-capped arc drawn with pathLength = 1, so stroke-dashoffset runs from 1 (empty) to 0 (full); the svg is turned −90° to start at 12 o'clock. The arc moves with a CSS transition and the number counts in requestAnimationFrame on the same curve and duration. An IntersectionObserver starts the first sweep when the ring is 30% in view; until then (and in the server render) it rests at zero. A new value transitions from the arc's current position, never back through zero. Indeterminate mode spins the whole ring at 2s while a quarter arc chases at 1.4s.
Use it for
- A single completion figure that should read at a glance, such as course progress, storage used or profile strength.
- Tasks with a clear percentage, like an upload or export, when the space is square.
- Checks and matching of unknown length: use indeterminate mode.
Look elsewhere when
- Progress inside table rows or list items: a horizontal bar saves space and aligns better.
- Comparing several values: rings are hard to compare by length; use a bar chart.
- Operations that end within a second: show the result or a button loading state.
Usage
import { ProgressRing } from './ProgressRing.jsx'
export function CourseProgress({ done, total }) {
return <ProgressRing value={done} max={total} size={124} thickness={14} aria-label="Course progress" />
}
// Red, amber or green by value
<ProgressRing value={score} thresholds label="Strength" />
// Unknown wait
<ProgressRing indeterminate label="Syncing" />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
value | number | 0 | Current value, between min and max. |
min | number | 0 | Minimum value. |
max | number | 100 | Maximum value. |
size | number | 120 | Ring diameter in px; the number scales with it. |
thickness | number | 14 | Ring width in px. 14 to 16 reads best at 120px. |
thresholds | boolean | { danger: number, warning: number } | false | Color by percentage: true means below 30 danger, below 70 warning, otherwise success. Pass custom limits. false (default) keeps one color: the accent or `color`. |
indeterminate | boolean | false | Shows a spinning arc and no number. |
label | ReactNode | — | Caption under the number. A string also becomes the accessible name. |
unit | string | '%' | Unit after the number; an empty string hides it. |
color | string | — | Arc color when thresholds are off, any CSS color such as var(--ds-chart-3). Defaults to the accent. |
duration | number | 900 | Length in ms of the sweep and the count, on cubic-bezier(0.22, 1, 0.36, 1). |
animateOnMount | boolean | true | Start at zero and sweep to the value the first time the ring is 30% in view. false shows the value at once. |
formatValue | (value: number) => string | — | Custom number format. It receives the in-between value while counting (not rounded), for example to keep one decimal. |
...rest | HTMLAttributes<HTMLDivElement> | — | Other attributes go to the root element, such as aria-label, className and style. |
Accessibility
- The root is role="progressbar" with aria-valuenow, aria-valuemin and aria-valuemax; aria-valuetext includes the unit, such as “86%”.
- Screen readers get only the final value: the counting digits are aria-hidden, so no run of in-between numbers is read.
- A string label becomes the aria-label automatically; indeterminate mode omits aria-valuenow and sets aria-busy.
- Color is not the only signal: the number and caption are always visible.
- Reduced motion shows the final value at once with no counting, and indeterminate mode breathes in place instead of spinning.
Motion
First view: the arc sweeps and the number counts for 900ms on cubic-bezier(0.22, 1, 0.36, 1). Value changes use the same curve from the current position; threshold colors cross-fade in 240ms. Indeterminate: 2s linear spin plus a 1.4s ease-in-out chase. Reduced motion shows the final value at once, without counting.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
ProgressRing.jsxprogress-ring.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



