Skip to content
WANCRAFT

G.28Data & Feedback

Metric Ticker

A dashboard metric with rolling or tweened updates, an honest delta badge and a live sparkline.

ReactCSSSVGTailwindintermediate

Overview

Metric Ticker displays a single KPI the way a trading desk would: digits roll like an odometer (or tween smoothly) from the previous value to the new one, and never restart from zero on update. The delta badge combines an arrow, a signed percentage and colour, with optional inversion for metrics where down is good (latency, cost, churn). Formatting is locale-aware through Intl.NumberFormat for plain numbers, currencies and percentages, a sparkline accumulates recent values, and updates are announced through a polite live region.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/metric-ticker.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/metric-ticker.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/metric-ticker.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
1 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { MetricTicker } from "@/components/ui/metric-ticker";

export function MetricTickerExample() {
  return (
    <MetricTicker label="Active users" value={18240} />
  );
}

03Props

PropTypeDefaultDescription
valuenumber—Current value. For percent, pass a fraction (0.124 → 12.4%).
labelstring—Metric name; also the accessible name of the group.
format"number" | "currency" | "percent""number"Intl.NumberFormat style.
currencystring"USD"ISO 4217 code for currency format.
decimalsnumber0Fixed fraction digits.
localestring"en-US"BCP 47 locale.
deltanumber—Relative change to display (0.024 → +2.40%). Defaults to the change from the previous value.
invertDeltabooleanfalseTreat decreases as favourable (green).
animation"roll" | "tween""roll"Odometer digits or a tweened number.
durationnumber600Transition length in ms.
size"sm" | "md" | "lg""md"Value size.
sparklinebooleantrueSparkline of recent values (appears after the first update unless seeded).
historynumber[]—Seed values for the sparkline (oldest first); read on mount.
historyLengthnumber24Points kept for the sparkline.
accentstring"#FF7448"Sparkline colour.
captionstring—Small text under the value.
announcebooleantrueAnnounce updates via aria-live="polite".

04Features

  • 01Odometer digits or tween — always from the previous value
  • 02Delta badge with arrow, sign and colour; invertible
  • 03Number, currency and percent via Intl.NumberFormat
  • 04Self-accumulating sparkline with optional seed history
  • 05Subtle directional wash on each update
motion · tweeninput · click

05Accessibility

  • The animated digits are aria-hidden; the formatted value is provided as text for assistive technology.
  • Updates are announced through a polite, atomic live region (e.g. “Revenue $48,213.37, up 1.20%”) — nothing is announced on first render.
  • Direction is conveyed by an arrow, a sign and text (“up 1.20% (favourable)”), not colour alone.
  • With prefers-reduced-motion values change instantly and the update wash is skipped.