Cómo funciona
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.
Úsalo para
- 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.
Busca otra opción cuando
- 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.
Uso
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" />Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
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. |
Accesibilidad
- 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.
Movimiento
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.
Añádelo a tu proyecto
Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.
ProgressRing.jsxprogress-ring.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.



