# Score Gauge

> 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.

Category: Charts · Free · Updated 2026-11-10 · Live demo: https://www.motionkitui.com/components/score-gauge

## When to use it

Performance, SEO and accessibility reports, credit and health scores, dashboard summaries and onboarding progress.

## How it works

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.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/score-gauge.json
```

Or copy `components/motionkit/score-gauge.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| 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. |

## Accessibility

- **Keyboard: Not applicable.** A display, not a control.
- **Screen readers: Pass.** A meter with its label, value and range, and the band in words, such as "92 out of 100, good".
- **Reduced motion: Pass.** With reduced motion on, the arc and the number show the final score straight away.
- **Colour contrast: Pass.** The score's colours measure 7.4:1 or more on the site's dark, and the band is also given in words.

## Source

```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>
  );
}
```
