How it works
Both arcs are the same half circle with pathLength="1": the value arc runs left to right, the rest arc right to left, and each shows its part through stroke-dashoffset alone. A 6px gap separates them between the round caps. One CSS transition carries the entrance and every later change, so a new value moves from the old one and never sweeps back through zero. The centre number, the legend values and their shares count on the same curve.
Use it for
- One amount against a known whole: budget spent, a weekly goal, beds or seats in use.
- A card where the split between used and left matters as much as the number itself.
Look elsewhere when
- More than two parts: use the donut chart.
- Values without a natural maximum, such as visits: use a bar chart or a stat card.
- Change over time: use a line or bar chart.
Usage
import { GaugeChart } from './GaugeChart.jsx'
export function BudgetCard() {
return (
<GaugeChart
title="Monthly budget"
qualifier="November"
value={1846}
max={2600}
center={2600}
caption="Budget"
valueLabel="Spent"
restLabel="Left"
formatValue={(n) => `$${n.toLocaleString('en-US')}`}
footnote={<><b>Eating out is under plan</b>Groceries went $64 over.</>}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
title / qualifier | string | — | Card title (15px semibold) and grey words after it. |
icon | ReactNode | — | An 18px icon in a 32px square tinted with the card colour. |
onAction / actionIcon / actionLabel / action | () => void / 'open' | 'more' / string / ReactNode | - / 'open' | A round chevron or three-dot button at the right of the title row, its accessible name, or your own element instead. |
value | number | — | The measured amount; clamped to 0…max. The coloured arc shows value / max. |
max | number | 100 | The whole. The neutral arc and the second legend row show max − value. |
center | number | — | Number in the centre. Defaults to value; pass max to show the whole, such as the budget. |
caption | string | — | Grey line above the centre number. |
unit | string | — | Unit beside the centre number, such as h or kg. |
valueLabel / restLabel | string | text.value / text.rest | Names of the two legend rows, such as Spent and Left. |
footnote | ReactNode | — | Text under a hairline at the bottom; a leading <b> reads as its heading. |
tone | 1-8 | 1 | Which --ds-chart-N colour the arc uses. |
size | number | 196 | Width of the half ring in px (120-320); the height follows. |
thickness | number | 16 | Arc width in px. |
formatValue | (n) => string | n.toLocaleString('en-US') | Formats the centre and legend numbers; while counting it receives in-between values rounded to the target's decimals. |
formatPercent | (p) => string | `${Math.round(p)}%` | Formats the legend shares (0-100). |
text | object | — | Replaces built-in words (value, rest, open, more, meter); shallow-merged over the English defaults. |
label | string | — | Accessible name of the meter; defaults to the title. |
replayKey | any | — | Change it to play the sweep again from zero. |
...rest | HTMLAttributes<HTMLDivElement> | — | Other attributes go to the card. |
Accessibility
- The dial is role="meter" with aria-valuenow, min and max, and a valuetext that reads the value, the whole and the share.
- The legend repeats both numbers and shares as text, so colour is never the only cue.
- Hovering an arc or a legend row softens the other part; nothing is shown only on hover.
- With reduced motion the arcs and numbers appear in their final state at once.
Motion
When 30% of the card is on screen the value arc sweeps from the left over 900ms on cubic-bezier(0.22, 1, 0.36, 1) while the rest arc shrinks from full; the centre number counts up and the legend counts the value up and the rest down on the same curve. Later changes take the same path from the current value; hover softening takes 160ms.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
GaugeChart.jsxgauge-chart.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



