Skip to content
Browse documentation

How far to free shipping, and the moment you get there: the fill runs into a satin ribbon stretched across the bar at the goal and bows it until it snaps.

Used forCart drawersReward tiersFundraisingLoyalty points

Install with the shadcn CLI

$ npx shadcn@latest add https://hairlineui.com/r/goal-tape.json

Registered the namespace? Then it’s shadcn add @hairline/goal-tape. Set it up

Templates

Need the whole page?

61 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 6 are free.

All 61 templates

Where it’s used

  • Cart drawers

    How much more for free shipping, under the subtotal.

  • Reward tiers

    Spend thresholds that unlock a gift, a discount, then free delivery.

  • Fundraising

    A campaign goal, with stretch goals after it.

  • Loyalty points

    Points toward the next perk on an account page.

What it handles for you

A free-shipping bar that only fills and turns green gives no moment for the thing the shopper just did.

Instead of wiring upfree shipping barprogress barspend threshold bannerconfetti on unlockreward tier meter
  1. The amount to go, in words

    The line above says how much more and for what, and rolls to the unlocked line at the goal.

  2. A moment at the goal

    The ribbon bows under the fill and snaps, with no confetti over your cart.

  3. Going back under

    Take an item out and the ribbon ties itself again, so the state always matches the total.

  4. Several goals

    Pass a list and each goal gets its own ribbon and caption, in order.

  5. Any currency or unit

    Amounts are written with Intl.NumberFormat from your format and locale.

  6. Screen readers

    The lane is a meter with the total; each goal reached is announced once.

Overview

A free-shipping bar is usually a thin line that fills up, and reaching the goal turns it green or throws confetti over the cart. Goal tape is a finish line seen from above. A recessed lane fills with your colour as the total grows, and at each goal a satin ribbon is stretched across it between two pins. Add the item that gets you there and the fill’s nose runs into the ribbon and bows it forward until it snaps: the two halves whip back towards their pins and curl up beside them, the satin catching the light as it twists, while the line above rolls from “Add $6.50 more for free shipping” to “You’ve unlocked free shipping”. Take the item back out and the two ends swing out, meet in the middle and tie, leaving a small knot. Several goals each get their own ribbon (free shipping, then a free gift). The total is yours: it shows whatever value you pass, glides to each new one on a spring, and needs nothing else from your cart.

States

filling
A new total glides the fill on a spring (stiffness 150, a slight overshoot); the line above rolls the amount still to go.
bow
Past a goal, the fill’s nose pushes the ribbon’s middle forward; it bows up to 13px.
snap
At 13px of bow, or once the fill comes to rest past the goal, the ribbon snaps: each half is thrown forward and back towards its pin, its length contracting to about a third in 60ms, then curls and settles. The line morphs to “You’ve unlocked …” and the goal’s caption gains a check.
retie
Back under a goal, the free ends are drawn to the middle of the lane and grow back to full length; when they meet the ribbon is whole again with a small knot.
at rest
Nothing moves once the ropes settle; ribbons already broken on first show lie curled by their pins.
reduced motion
The fill jumps to the total, and ribbons are simply whole or gone.

Usage

usage.tsx
import { GoalTape } from "@/components/goal-tape";<GoalTape  value={subtotal}  goal={50}  label="free shipping"  format={{ style: "currency", currency: "USD" }}/>

Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.

Works with

In a cart drawer

The subtotal comes from your cart; the tiers come from your shipping and promotion settings.

example.tsx
"use client";import { GoalTape } from "@/components/goal-tape";import { useCart } from "@/lib/cart"; // your cartexport function CartRewards() {  const { subtotal, currency } = useCart();  return (    <GoalTape      value={subtotal}      format={{ style: "currency", currency }}      goals={[        { at: 50, label: "free shipping" },        { at: 100, label: "a free tote", color: "var(--chart-3)" },      ]}    />  );}

Props

value
number
The running total: a subtotal, money raised, points.
goals
{ at, label, color? }[]
Each goal and what it unlocks, read in a sentence (“free shipping”). Any order.
goal / label
number / string
A single goal, instead of goals.
format / locales
Intl.NumberFormatOptions / string
How amounts are written, e.g. { style: "currency", currency: "USD" }.
messages= "Add ", " more for ", "You’ve unlocked "
{ add?, more?, unlocked? }
The words around the amount and the label.
sound= false
boolean
A soft snap as a ribbon breaks and a tick as it ties.

Accessibility and motion

  • The lane is a role="meter" with the total as its value and the sentence as its name. Reaching a goal is announced once from a polite status region; the rolling amount isn’t announced on every change.
  • Ribbons take your chart colours in turn, or a gold satin when your theme’s chart colours are greys. The fill is your primary, the pins are mixed from your foreground and background.
  • Each ribbon half is a twelve-point rope (Verlet, six constraint passes a step) drawn on one canvas around the lane; the frame loop runs only while the fill moves or a rope is still settling.
  • The fill moves by transform on its own layer. Reduced motion drops the springs and ropes: the fill jumps and ribbons are simply whole or gone.

Requirements

React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

The CLI also installs Number roll, Text morph.

Source

"use client";import * as React from "react";import { Check } from "lucide-react";import { NumberRoll } from "./number-roll";import { TextMorph } from "./text-morph";import { createSpring, type Spring } from "./ui-interaction-motion";import { playSound } from "./ui-sounds";/* ───────────────────────────────────────────────────────── * GOAL TAPE: how far to the next reward, and the moment you * reach it * *   lane      a recessed lane fills with your colour as the total *             grows; at each goal a satin ribbon is stretched *             across it between two pins, like a finish line *             seen from above *   break     crossing a goal, the fill's nose runs into the *             ribbon and bows it forward until it snaps; the two *             halves whip back towards their pins and curl, the *             satin catching the light as it twists, and the *             line above rolls to "You've unlocked free shipping" *   retie     drop back under a goal and the two ends swing out, *             meet in the middle and tie, leaving a small knot * * The total is yours (a cart, a fundraiser, points); the bar only * shows it. The ribbons are a little rope simulation on one * canvas that sleeps once they come to rest. * ───────────────────────────────────────────────────────── */export interface GoalTapeGoal {  /** The total at which it unlocks. */  at: number;  /** Read in a sentence: "free shipping", "a free tote". */  label: string;  /** The ribbon: any CSS colour. Defaults to your chart colours in turn. */  color?: string;}export interface GoalTapeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {  /** The running total: the cart's subtotal, money raised, points earned. */  value: number;  /** One or more goals, any order. Or use goal and label for a single one. */  goals?: GoalTapeGoal[];  goal?: number;  label?: string;  /** How amounts are written, e.g. { style: "currency", currency: "USD" }. */  format?: Intl.NumberFormatOptions;  locales?: string | string[];  /** The two sentences, if yours read differently. */  messages?: { add?: string; more?: string; unlocked?: string };  /** A soft snap as a ribbon breaks, off by default. */  sound?: boolean;}const TRACK = 16; // lane heightconst PAD_X = 18; // the canvas reaches past the lane for the pins and the ribbon endsconst PAD_Y = 40;const PIN = 12; // how far the pins stand off the lane's edgesconst BREAK = 16; // how far the ribbon bows before it snapsconst HEADROOM = 1.16; // the lane runs on past the last goal, so the fill can break its ribbonconst SEGMENTS = 11;const EASE = "cubic-bezier(0.16,1,0.3,1)";const reducedQuery = "(prefers-reduced-motion: reduce)";const subscribeReduced = (onChange: () => void) => {  const query = window.matchMedia(reducedQuery);  query.addEventListener("change", onChange);  return () => query.removeEventListener("change", onChange);};const useReducedMotion = () => React.useSyncExternalStore(subscribeReduced, () => window.matchMedia(reducedQuery).matches, () => false);const subscribeNothing = () => () => {};const useHydrated = () => React.useSyncExternalStore(subscribeNothing, () => true, () => false);const clamp = (v: number, a: number, b: number) => (v < a ? a : v > b ? b : v);/* ── colours, mixed in JS so any colour format works ── */type RGB = [number, number, number];const mix = (a: RGB, b: RGB, t: number): RGB => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];const css = (c: RGB, alpha = 1) => `rgba(${Math.round(c[0])},${Math.round(c[1])},${Math.round(c[2])},${alpha})`;const lum = (c: RGB) => (0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]) / 255;const chroma = (c: RGB) => (Math.max(...c) - Math.min(...c)) / 255;let probe: CanvasRenderingContext2D | null = null;function toRgb(color: string, fallback: RGB): RGB {  if (typeof document === "undefined" || !color) return fallback;  probe ??= document.createElement("canvas").getContext("2d", { willReadFrequently: true });  if (!probe) return fallback;  probe.clearRect(0, 0, 1, 1);  probe.fillStyle = "#000";  probe.fillStyle = color;  probe.fillRect(0, 0, 1, 1);  const [r, g, b, a] = probe.getImageData(0, 0, 1, 1).data;  return a === 0 ? fallback : [r, g, b];}/** Satin ribbons: theme colours, or a gold one when the theme's chart colours are greys. */const GOLD: RGB = [205, 152, 34];/* ── the ribbons ── */type Rope = { x: Float32Array; y: Float32Array; px: Float32Array; py: Float32Array; rest: number; born: number; awake: boolean; still: number };type Tape = {  x: number; // where the goal sits along the lane, px  phase: "intact" | "stretch" | "broken" | "retie";  bow: number;  ropes: [Rope, Rope] | null;  knot: number; // 0–1, shown once it has been tied again  color: RGB;};interface Engine {  canvas: HTMLCanvasElement | null;  fill: HTMLDivElement | null;  width: number;  max: number;  dpr: number;  value: Spring | null;  tapes: Tape[];  frame: number;  last: number;  metal: RGB;  hi: RGB;  lo: RGB;  bg: RGB;  dark: boolean;  reduced: boolean;  sound: boolean;  onBreak: (i: number) => void;  onTie: (i: number) => void;  stripes: HTMLDivElement | null;}const laneY = () => PAD_Y + TRACK / 2;const pins = (t: Tape): [number, number, number, number] => [PAD_X + t.x, PAD_Y - PIN, PAD_X + t.x, PAD_Y + TRACK + PIN];function makeRope(ax: number, ay: number, bx: number, by: number, born: number): Rope {  const n = SEGMENTS + 1;  const rope: Rope = { x: new Float32Array(n), y: new Float32Array(n), px: new Float32Array(n), py: new Float32Array(n), rest: 0, born, awake: true, still: 0 };  for (let i = 0; i < n; i++) {    const t = i / SEGMENTS;    rope.x[i] = rope.px[i] = ax + (bx - ax) * t;    rope.y[i] = rope.py[i] = ay + (by - ay) * t;  }  rope.rest = Math.hypot(bx - ax, by - ay) / SEGMENTS;  return rope;}/** Snaps a bowed ribbon: two halves from the pins to where the nose met it, thrown forward and back towards their pins. */function snap(e: Engine, t: Tape, speed: number, now: number) {  const [tx, ty, bx, by] = pins(t);  const cx = PAD_X + t.x + t.bow;  const cy = laneY();  const top = makeRope(tx, ty, cx, cy - 0.6, now);  const bottom = makeRope(bx, by, cx, cy + 0.6, now);  const forward = clamp(speed, 90, 520) * 0.85;  for (const [rope, side] of [    [top, -1],    [bottom, 1],  ] as const) {    for (let i = 1; i <= SEGMENTS; i++) {      const k = i / SEGMENTS;      // Velocity in px per step (1/120 s): forward with the nose, back towards its own pin, with a little twist.      const vx = (forward * k * k + (Math.random() - 0.5) * 110 * k) / 120;      const vy = (side * 240 * k + (Math.random() - 0.5) * 40) / 120;      rope.px[i] = rope.x[i] - vx;      rope.py[i] = rope.y[i] - vy;    }  }  t.ropes = [top, bottom];  t.phase = "broken";  t.bow = 0;  t.knot = 0;  if (e.sound) playSound("pop", 0.3);}/** One step of the rope: Verlet with damping, a rest length that contracts after the snap (or grows back to retie). */function stepRope(rope: Rope, t: Tape, now: number, tying: boolean) {  const n = SEGMENTS + 1;  const age = (now - rope.born) / 1000;  const full = rope.rest;  const target = tying ? full : full * (0.56 + 0.44 * Math.exp(-age / 0.07));  const damp = tying ? 0.86 : age < 0.3 ? 0.982 : 0.93;  const cx = PAD_X + t.x;  const cy = laneY();  let moving = 0;  for (let i = 1; i < n; i++) {    const vx = (rope.x[i] - rope.px[i]) * damp;    const vy = (rope.y[i] - rope.py[i]) * damp;    rope.px[i] = rope.x[i];    rope.py[i] = rope.y[i];    rope.x[i] += vx;    rope.y[i] += vy;    moving = Math.max(moving, Math.abs(vx) + Math.abs(vy));  }  if (!tying) {    // Thrown ends come to lie the way they were thrown: trailing forward, out to their own side of the lane.    const side = rope.y[0] < cy ? -1 : 1;    for (let i = 1; i < n; i++) {      const k = i / (n - 1);      rope.x[i] += 0.05 * k;      rope.y[i] += side * 0.06 * k;    }  }  if (tying) {    // The free end is drawn to the middle of the lane, where the two ends meet.    const j = n - 1;    rope.x[j] += (cx - rope.x[j]) * 0.22;    rope.y[j] += (cy - rope.y[j]) * 0.22;  }  for (let it = 0; it < 6; it++) {    for (let i = 0; i < n - 1; i++) {      const dx = rope.x[i + 1] - rope.x[i];      const dy = rope.y[i + 1] - rope.y[i];      const d = Math.hypot(dx, dy) || 1e-4;      const diff = (d - target) / d;      if (i === 0) {        rope.x[1] -= dx * diff;        rope.y[1] -= dy * diff;      } else {        rope.x[i] += dx * diff * 0.5;        rope.y[i] += dy * diff * 0.5;        rope.x[i + 1] -= dx * diff * 0.5;        rope.y[i + 1] -= dy * diff * 0.5;      }    }  }  rope.still = moving < 0.02 ? rope.still + 1 : 0;  rope.awake = tying || rope.still < 24 || age < 0.5;}/** A length of satin: each segment shaded by how it faces the light, so a twist reads as a twist. */function ribbon(ctx: CanvasRenderingContext2D, xs: ArrayLike<number>, ys: ArrayLike<number>, n: number, color: RGB, dark: boolean) {  ctx.lineCap = "round";  ctx.lineJoin = "round";  for (let i = 0; i < n - 1; i++) {    const dx = xs[i + 1] - xs[i];    const dy = ys[i + 1] - ys[i];    const facing = Math.abs(Math.cos(Math.atan2(dy, dx) - Math.PI / 2 - 0.5));    const lit = facing ** 3;    const shade = mix(mix(color, [0, 0, 0], (1 - facing) * (dark ? 0.35 : 0.28)), [255, 255, 255], lit * 0.32);    ctx.beginPath();    ctx.moveTo(xs[i], ys[i]);    ctx.lineTo(xs[i + 1], ys[i + 1]);    ctx.strokeStyle = css(shade);    ctx.lineWidth = 5;    ctx.stroke();    if (lit > 0.4) {      ctx.beginPath();      ctx.moveTo(xs[i], ys[i]);      ctx.lineTo(xs[i + 1], ys[i + 1]);      ctx.strokeStyle = css([255, 255, 255], (lit - 0.4) * 0.6);      ctx.lineWidth = 1.4;      ctx.stroke();    }  }}function pinHead(ctx: CanvasRenderingContext2D, e: Engine, x: number, y: number) {  ctx.save();  ctx.shadowColor = css([0, 0, 0], e.dark ? 0.55 : 0.25);  ctx.shadowBlur = 2.5;  ctx.shadowOffsetY = 1;  ctx.beginPath();  ctx.arc(x, y, 4, 0, Math.PI * 2);  const g = ctx.createRadialGradient(x - 1.3, y - 1.4, 0.3, x, y, 4.1);  g.addColorStop(0, css(e.hi));  g.addColorStop(0.55, css(e.metal));  g.addColorStop(1, css(e.lo));  ctx.fillStyle = g;  ctx.fill();  ctx.restore();}function draw(e: Engine) {  const canvas = e.canvas;  const ctx = canvas?.getContext("2d");  if (!canvas || !ctx) return;  const W = e.width + PAD_X * 2;  const H = TRACK + PAD_Y * 2;  if (canvas.width !== Math.round(W * e.dpr) || canvas.height !== Math.round(H * e.dpr)) {    canvas.width = Math.round(W * e.dpr);    canvas.height = Math.round(H * e.dpr);  }  ctx.setTransform(e.dpr, 0, 0, e.dpr, 0, 0);  ctx.clearRect(0, 0, W, H);  const cy = laneY();  for (const t of e.tapes) {    const [tx, ty, bx, by] = pins(t);    if (t.phase === "broken" || t.phase === "retie") {      for (const rope of t.ropes ?? []) ribbon(ctx, rope.x, rope.y, SEGMENTS + 1, t.color, e.dark);    } else {      // Whole: straight across the lane, or bowed around the nose that's pushing it.      const nx = tx + t.bow;      const xs = [tx, (tx + nx) / 2 + t.bow * 0.15, nx, (bx + nx) / 2 + t.bow * 0.15, bx];      const ys = [ty, (ty + cy) / 2, cy, (by + cy) / 2, by];      ribbon(ctx, xs, ys, 5, t.color, e.dark);      if (t.knot > 0.01) {        ctx.beginPath();        ctx.ellipse(nx, cy, 3.2 * t.knot, 2.6 * t.knot, 0.3, 0, Math.PI * 2);        ctx.fillStyle = css(mix(t.color, [0, 0, 0], 0.22));        ctx.fill();        ctx.beginPath();        ctx.ellipse(nx - 0.8, cy - 0.8, 1.2 * t.knot, 0.8 * t.knot, 0.3, 0, Math.PI * 2);        ctx.fillStyle = css([255, 255, 255], 0.35);        ctx.fill();      }    }    pinHead(ctx, e, tx, ty);    pinHead(ctx, e, bx, by);  }}/** One frame: the fill's nose against each ribbon, the ropes, the paint. Runs while anything moves. */function frame(e: Engine, now: number) {  e.frame = 0;  const dt = clamp((now - e.last) / 1000, 0, 0.05);  e.last = now;  const value = e.value?.get() ?? 0;  const speed = Math.abs(e.value?.getVelocity() ?? 0) * (e.width / Math.max(1e-6, e.max));  const nose = clamp(value / Math.max(1e-6, e.max), 0, 1) * e.width;  if (e.fill) e.fill.style.transform = `translate3d(${nose - e.width}px, 0, 0)`;  if (e.stripes) e.stripes.style.transform = `translate3d(${e.width - nose}px, 0, 0)`;  let busy = Boolean(e.value && (e.value.getVelocity() !== 0 || Math.abs(e.value.get() - e.value.getTarget()) > 1e-6));  e.tapes.forEach((t, i) => {    const past = nose - t.x;    if (t.phase === "intact" || t.phase === "stretch") {      if (past > 0.2) {        t.phase = "stretch";        t.bow = Math.min(past, BREAK + 4);        const resting = !busy || (e.value && Math.abs(e.value.getVelocity()) < 0.002 * e.max);        if (e.reduced || past >= BREAK || resting) {          if (e.reduced) {            t.phase = "broken";            t.ropes = null;            t.bow = 0;          } else snap(e, t, speed, now);          e.onBreak(i);        }      } else if (t.phase === "stretch") {        t.phase = "intact";        t.bow = 0;      }    } else if (past < -0.5 && t.phase === "broken") {      if (e.reduced || !t.ropes) {        t.phase = "intact";        t.knot = 1;        e.onTie(i);      } else {        t.phase = "retie";        t.ropes.forEach((r) => (r.born = now));      }    } else if (t.phase === "retie") {      if (past > 0.2) {        // Over the goal again before the ends met: they spring back.        t.phase = "broken";        t.ropes?.forEach((r) => {          r.born = now;          r.awake = true;        });      } else if (t.ropes) {        const cx = PAD_X + t.x;        const cy = laneY();        const met = t.ropes.every((r) => Math.hypot(r.x[SEGMENTS] - cx, r.y[SEGMENTS] - cy) < 1.2);        if (met) {          t.phase = "intact";          t.ropes = null;          t.knot = 0.01;          e.onTie(i);          if (e.sound) playSound("tick", 0.25);        }      }    }    if (t.ropes) {      const tying = t.phase === "retie";      for (let s = 0; s < Math.max(1, Math.round(dt * 120)); s++) t.ropes.forEach((r) => stepRope(r, t, now, tying));      if (t.ropes.some((r) => r.awake)) busy = true;    }    if (t.phase === "intact" && t.knot > 0 && t.knot < 1) {      t.knot = Math.min(1, t.knot + dt * 6);      busy = true;    }  });  draw(e);  if (busy) e.frame = requestAnimationFrame((ts) => frame(e, ts));}function kick(e: Engine) {  if (e.frame || !e.canvas) return;  e.last = performance.now();  e.frame = requestAnimationFrame((ts) => frame(e, ts));}/* ── the component ── */export function GoalTape({ value, goals: goalsProp, goal, label, format, locales, messages, sound = false, className = "", ...props }: GoalTapeProps) {  const reduced = useReducedMotion();  const hydrated = useHydrated();  const goals = React.useMemo(() => {    const list = goalsProp ?? (goal !== undefined ? [{ at: goal, label: label ?? "the reward" }] : []);    return [...list].sort((a, b) => a.at - b.at);  }, [goalsProp, goal, label]);  const last = goals.length ? goals[goals.length - 1].at : 1;  const max = last * HEADROOM;  const laneRef = React.useRef<HTMLDivElement>(null);  const fillRef = React.useRef<HTMLDivElement>(null);  const stripesRef = React.useRef<HTMLDivElement>(null);  const canvasRef = React.useRef<HTMLCanvasElement>(null);  const probes = React.useRef<(HTMLSpanElement | null)[]>([]);  const engineRef = React.useRef<Engine | null>(null);  const [announce, setAnnounce] = React.useState("");  const text = { add: "Add ", more: " more for ", unlocked: "You’ve unlocked ", ...messages };  // The line changes when a ribbon actually snaps (or ties), not the moment the total crosses the goal.  const [snapped, setSnapped] = React.useState<Record<number, boolean>>(() => Object.fromEntries(goals.map((g) => [g.at, value >= g.at])));  const isSnapped = (g: GoalTapeGoal) => snapped[g.at] ?? value >= g.at;  const next = goals.find((g) => !isSnapped(g));  const reached = goals.filter((g) => isSnapped(g));  const remaining = next ? Math.max(0, next.at - value) : 0;  const locale = locales ?? (hydrated ? undefined : "en-US");  const formatter = React.useMemo(() => new Intl.NumberFormat(locale, format), [locale, format]);  const whole = React.useMemo(() => new Intl.NumberFormat(locale, { ...format, minimumFractionDigits: 0, maximumFractionDigits: 0 }), [locale, format]);  const engine = React.useCallback((): Engine => {    if (!engineRef.current) {      engineRef.current = {        canvas: null,        fill: null,        width: 0,        max: 1,        dpr: 1,        value: null,        tapes: [],        frame: 0,        last: 0,        metal: [180, 184, 190],        hi: [250, 250, 252],        lo: [110, 114, 120],        bg: [255, 255, 255],        dark: false,        reduced: false,        sound: false,        onBreak: () => {},        onTie: () => {},        stripes: null,      };    }    return engineRef.current;  }, []);  React.useLayoutEffect(() => {    const e = engine();    e.canvas = canvasRef.current;    e.fill = fillRef.current;    e.stripes = stripesRef.current;    e.value = createSpring(value, { stiffness: 150, damping: 17 }, () => kick(e), 0.0005 * Math.max(1, max));    return () => {      e.value?.stop();      cancelAnimationFrame(e.frame);      e.frame = 0;    };    // The spring is made once; later values re-aim it below.  }, [engine]); // eslint-disable-line react-hooks/exhaustive-deps  React.useEffect(() => {    const e = engine();    e.reduced = reduced;    e.sound = sound;    e.max = max;    e.onBreak = (i) => {      const g = goals[i];      if (!g) return;      setSnapped((was) => (was[g.at] ? was : { ...was, [g.at]: true }));      setAnnounce(`${text.unlocked}${g.label}`);    };    e.onTie = (i) => {      const g = goals[i];      if (g) setSnapped((was) => (was[g.at] === false ? was : { ...was, [g.at]: false }));    };  });  // Ribbons: one per goal, placed along the lane; their phases survive a re-measure.  React.useLayoutEffect(() => {    const e = engine();    const lane = laneRef.current;    if (!lane) return;    const place = () => {      e.width = lane.clientWidth;      e.dpr = Math.min(3, window.devicePixelRatio || 1);      const colors = goals.map((g, i) => {        const c = toRgb(probes.current[i] ? getComputedStyle(probes.current[i]!).color : "", GOLD);        return chroma(c) < 0.12 ? GOLD : c;      });      const v = e.value?.get() ?? value;      e.tapes = goals.map((g, i) => {        const was = e.tapes[i];        const x = (g.at / Math.max(1e-6, max)) * e.width;        if (was) return { ...was, x, color: colors[i] };        return { x, phase: v >= g.at ? "broken" : "intact", bow: 0, ropes: null, knot: 0, color: colors[i] } as Tape;      });      // Ribbons already broken when it first shows lie curled by their pins, at rest.      e.tapes.forEach((t) => {        if (t.phase === "broken" && !t.ropes && !e.reduced) {          // Settled the way a live snap ends: the halves contracted and trailing forward, out to their sides.          const [tx, ty, bx, by] = pins(t);          const top = makeRope(tx, ty, tx + 2, laneY() - 1, -1e6);          const bottom = makeRope(bx, by, bx + 2, laneY() + 1, -1e6);          for (const r of [top, bottom]) for (let k = 0; k < 320; k++) stepRope(r, t, 0, false);          top.awake = bottom.awake = false;          t.ropes = [top, bottom];        }      });      kick(e);      draw(e);    };    place();    const observer = new ResizeObserver(place);    observer.observe(lane);    return () => observer.disconnect();  }, [engine, goals, max]); // eslint-disable-line react-hooks/exhaustive-deps  // Theme colours for the pins and ribbons, read again when the theme changes.  React.useEffect(() => {    const e = engine();    const read = () => {      const fg = toRgb(probes.current[goals.length] ? getComputedStyle(probes.current[goals.length]!).color : "", [20, 20, 20]);      const bg = toRgb(probes.current[goals.length + 1] ? getComputedStyle(probes.current[goals.length + 1]!).color : "", [255, 255, 255]);      e.dark = lum(bg) < 0.5;      e.bg = bg;      e.metal = e.dark ? mix(bg, fg, 0.62) : mix(bg, fg, 0.3);      e.hi = mix(e.metal, [255, 255, 255], 0.75);      e.lo = mix(e.metal, [0, 0, 0], 0.4);      e.tapes.forEach((t, i) => {        const c = toRgb(probes.current[i] ? getComputedStyle(probes.current[i]!).color : "", GOLD);        t.color = chroma(c) < 0.12 ? GOLD : c;      });      draw(e);    };    read();    const observer = new MutationObserver(read);    observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "style", "data-theme"] });    const media = window.matchMedia("(prefers-color-scheme: dark)");    media.addEventListener("change", read);    return () => {      observer.disconnect();      media.removeEventListener("change", read);    };  }, [engine, goals]);  // A new total: the fill glides to it on a spring (a slight push past a goal is what breaks the ribbon).  React.useEffect(() => {    const e = engine();    if (!e.value) return;    if (reduced) e.value.jump(value);    else e.value.set(value);    kick(e);  }, [engine, value, reduced]);  const unlockedAll = !next && goals.length > 0;  const lastReached = reached[reached.length - 1];  return (    <div className={`w-full ${className}`} {...props}>      {goals.map((g, i) => (        <span key={g.at} ref={(el) => void (probes.current[i] = el)} hidden style={{ color: g.color ?? `var(--chart-${(i % 4) + 2})` }} />      ))}      <span ref={(el) => void (probes.current[goals.length] = el)} hidden className="text-foreground" />      <span ref={(el) => void (probes.current[goals.length + 1] = el)} hidden className="text-background" />      <p className="flex min-h-6 flex-wrap items-baseline text-[13.5px] text-foreground">        {unlockedAll ? (          <span className="font-medium">            <TextMorph>{`${text.unlocked}${lastReached?.label ?? ""}`}</TextMorph>          </span>        ) : (          <>            <TextMorph>{text.add}</TextMorph>            <span className="font-medium tabular-nums">              <NumberRoll value={remaining} format={format} locales={locales} />            </span>            <TextMorph>{`${text.more}${next?.label ?? ""}`}</TextMorph>          </>        )}      </p>      <div className="relative mt-6" style={{ height: TRACK }}>        <div          ref={laneRef}          role="meter"          aria-label={next ? `${text.add}${formatter.format(remaining)}${text.more}${next.label}` : `${text.unlocked}${lastReached?.label ?? ""}`}          aria-valuemin={0}          aria-valuemax={last}          aria-valuenow={Math.min(value, last)}          aria-valuetext={formatter.format(value)}          className="absolute inset-0 overflow-clip rounded-full bg-background shadow-[inset_0_0_0_1px_var(--border),inset_0_1.5px_3px_rgb(0_0_0/0.09)] dark:shadow-[inset_0_0_0_1px_var(--border),inset_0_1.5px_3px_rgb(0_0_0/0.45)]"        >          <div            aria-hidden            className="absolute inset-0"            style={{ backgroundImage: "repeating-linear-gradient(90deg, color-mix(in oklab, var(--foreground) 9%, transparent) 0 2px, transparent 2px 4px)" }}          />          <div            ref={fillRef}            className="absolute inset-y-0 left-0 w-full overflow-clip rounded-full bg-[color-mix(in_oklab,var(--primary)_22%,var(--background))]"            style={{ transform: "translate3d(-100%, 0, 0)", willChange: "transform" }}          >            <div              ref={stripesRef}              className="absolute inset-0"              style={{ backgroundImage: "repeating-linear-gradient(90deg, var(--primary) 0 2px, transparent 2px 4px)", transform: "translate3d(100%, 0, 0)", willChange: "transform" }}            />          </div>        </div>        <canvas          ref={canvasRef}          aria-hidden          className="pointer-events-none absolute"          style={{ left: -PAD_X, top: -PAD_Y, width: `calc(100% + ${PAD_X * 2}px)`, height: TRACK + PAD_Y * 2 }}        />      </div>      <div className="relative mt-[26px] h-5 text-[12px]">        {goals.map((g) => {          const met = value >= g.at;          const pct = (g.at / max) * 100;          return (            <span              key={g.at}              className={`absolute top-0 flex items-center gap-1 whitespace-nowrap transition-colors duration-300 ${met ? "text-foreground" : "text-muted-foreground"}`}              style={{ left: `${pct}%`, transform: pct < 22 ? "translateX(12px)" : "translateX(calc(-100% - 12px))" }}            >              <span                aria-hidden                className="grid overflow-clip"                style={{ gridTemplateColumns: met ? "1fr" : "0fr", opacity: met ? 1 : 0, transition: `grid-template-columns 360ms ${EASE}, opacity 260ms ${EASE}` }}              >                <span className="min-w-0">                  <Check className="mr-0.5 size-3.5 text-emerald-600 dark:text-emerald-400" />                </span>              </span>              <span className="tabular-nums">{(Number.isInteger(g.at) ? whole : formatter).format(g.at)}</span>              <span className="text-muted-foreground">·</span>              <span className="inline-block first-letter:uppercase">{g.label}</span>            </span>          );        })}      </div>      <span className="sr-only" role="status" aria-live="polite">        {announce}      </span>    </div>  );}

Registry item: /r/goal-tape.json