A headline number that counts up beside a sparkline that draws itself, with a change badge and hover readout.
A score arc like a performance report's: it sweeps round as it scrolls into view while the number counts up, coloured by its band.
Customize
Usage
import { ScoreGauge } from "@/components/motionkit/score-gauge";
<ScoreGauge value={92} label="Performance" />Motion
The exact curves this component runs, plotted with Motion's own maths.
Arc and count
Scrolls into view
Performance, SEO and accessibility reports, credit and health scores, dashboard summaries and onboarding progress.
The arc is an SVG circle measured as 100 units round with pathLength, so its dash pattern can be written as a percentage. The circle is rotated so the gap sits at the bottom, a faint copy draws the track, and a Motion value runs from 0 to the score, driving both the dash length and the number in the middle. The colour comes from the band the score lands in. It's exposed as a meter, so assistive technology reads its label, value and band.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/score-gauge.jsonnpm install motionSave as components/motionkit/score-gauge.tsx.
"use client";
import { useEffect, useRef } from "react";
import { animate, motion, useInView, useMotionValue, useReducedMotion, useTransform } from "motion/react";
type Band = "poor" | "average" | "good";
type ScoreGaugeProps = {
/** The score, from 0 to `max`. */
value: number;
max?: number;
/** What's being scored, e.g. "Performance". Read out with the score. */
label?: string;
/** Scores below the first number are poor, below the second average, and the rest good (as a share of `max`, 0 to 1). */
thresholds?: [number, number];
/** Colours for each band. */
colors?: Partial<Record<Band, string>>;
/** How much of the circle the arc covers, in degrees. 360 is a full ring. */
sweep?: number;
/** Width and height in pixels. */
size?: number;
/** Seconds for the arc and the count. */
duration?: number;
/** Show the three bands and their ranges underneath. */
legend?: boolean;
className?: string;
};
const defaultColors: Record<Band, string> = { poor: "#D39A86", average: "#E9B872", good: "#5FAEB4" };
const bandNames: Record<Band, string> = { poor: "poor", average: "needs improvement", good: "good" };
const ease = [0.16, 1, 0.3, 1] as const;
/**
* A score arc like a performance report's: it sweeps round to the score as it scrolls into view while the number
* counts up, coloured by the band the score lands in. Exposed to assistive technology as a meter.
*/
export function ScoreGauge({
value,
max = 100,
label = "Performance",
thresholds = [0.5, 0.9],
colors,
sweep = 270,
size = 160,
duration = 1.4,
legend = true,
className = "",
}: ScoreGaugeProps) {
const palette = { ...defaultColors, ...colors };
const ref = useRef<HTMLDivElement>(null);
const inView = useInView(ref, { once: true, amount: 0.6 });
const reduceMotion = useReducedMotion();
const score = Math.min(max, Math.max(0, value));
const share = score / max;
const band: Band = share < thresholds[0] ? "poor" : share < thresholds[1] ? "average" : "good";
const color = palette[band];
// the arc is drawn on a circle measured as 100 units round, so lengths are simple percentages
const arc = Math.min(360, Math.max(30, sweep)) / 360;
const stroke = Math.max(6, size * 0.07);
const radius = 50 - (stroke / size) * 50;
const rotate = 90 + (360 - arc * 360) / 2;
const progress = useMotionValue(0);
const dash = useTransform(progress, (p) => `${p * arc * 100} 100`);
const shown = useTransform(progress, (p) => String(Math.round(p * max)));
useEffect(() => {
if (!inView) return;
if (reduceMotion) {
progress.set(share);
return;
}
const controls = animate(progress, share, { duration, ease });
return () => controls.stop();
}, [inView, reduceMotion, share, duration, progress]);
const pct = (n: number) => Math.round(n * max);
return (
<div ref={ref} className={`inline-flex flex-col items-center text-[#F6F1E8] ${className}`}>
<div
role="meter"
aria-label={label}
aria-valuemin={0}
aria-valuemax={max}
aria-valuenow={score}
aria-valuetext={`${score} out of ${max}, ${bandNames[band]}`}
className="relative"
style={{ width: size, height: size }}
>
<svg viewBox="0 0 100 100" className="size-full" style={{ transform: `rotate(${rotate}deg)` }} aria-hidden>
<circle cx="50" cy="50" r={radius} pathLength={100} fill="none" stroke="rgb(255 255 255 / 0.08)" strokeWidth={(stroke / size) * 100} strokeLinecap="round" strokeDasharray={`${arc * 100} 100`} />
<motion.circle
cx="50"
cy="50"
r={radius}
pathLength={100}
fill="none"
stroke={color}
strokeWidth={(stroke / size) * 100}
strokeLinecap="round"
style={{ strokeDasharray: dash, filter: `drop-shadow(0 0 ${size * 0.02}px ${color})` }}
/>
</svg>
<div aria-hidden className="absolute inset-0 flex flex-col items-center justify-center">
<motion.span className="font-semibold tabular-nums leading-none tracking-tight" style={{ fontSize: size * 0.28, color }}>
{shown}
</motion.span>
<span className="mt-1.5 text-[#94A9A7]" style={{ fontSize: Math.max(11, size * 0.08) }}>
{label}
</span>
</div>
</div>
{legend && (
<ul className="mt-3 flex flex-wrap justify-center gap-x-4 gap-y-1 text-xs text-[#94A9A7]">
{(
[
["poor", `0–${pct(thresholds[0]) - 1}`],
["average", `${pct(thresholds[0])}–${pct(thresholds[1]) - 1}`],
["good", `${pct(thresholds[1])}–${max}`],
] as const
).map(([name, range]) => (
<li key={name} className={`flex items-center gap-1.5 ${name === band ? "text-[#DCE3E2]" : ""}`}>
<span className="size-2 rounded-full" style={{ backgroundColor: palette[name] }} />
<span className="tabular-nums">{range}</span>
</li>
))}
</ul>
)}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | The score, from 0 to max. |
| max | number | 100 | The top of the scale. |
| label | string | "Performance" | What's being scored, shown under the number. |
| thresholds | [number, number] | [0.5, 0.9] | Where poor ends and good begins, as shares of max. |
| colors | Partial<Record<Band, string>> | — | Colours for the poor, average and good bands. |
| sweep | number | 270 | How much of the circle the arc covers, in degrees; 360 for a full ring. |
| size | number | 160 | Width and height in pixels. |
| duration | number | 1.4 | Seconds for the arc and the count. |
| legend | boolean | true | Show the three bands and their ranges underneath. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/score-gauge.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, the arc and the number show the final score straight away.
A headline number that counts up beside a sparkline that draws itself, with a change badge and hover readout.
Segments draw themselves in on scroll; hover, tap or tab to one to lift it and read its value and share in the middle.
A responsive area chart that draws itself in, then follows the pointer, a finger or the arrow keys with a crosshair and tooltip.