Live Number

A number that shows a change without pulling the eye: only the digits that changed cross-fade.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/live-number.json

Usage

import { LiveNumber } from "@/components/ui/live-number"

Examples

Default

Only the digits that changed move, 0.14em in the direction of the change. Screen readers hear the whole value once, never digit by digit.

1,284

Roll-in for a moment

variant="roll" lifts each changed digit in from below and lets it settle a little past its place, the last two trailing. For a total that lands once, not a value that ticks.

$4,820.00

API Reference

PropTypeDefaultDescription
value*numberNoneThe number to show.
formatIntl.NumberFormatOptionsNonePassed to Intl.NumberFormat: currency, percent, decimals.
localestring | string[]"en-US"Fixed so the server and the browser print the same string. Set it to the reader's locale when you know it.
variant"subtle" | "roll""subtle"subtle for a value that changes often; roll for a rare moment.
value*numberThe number to show.
formatIntl.NumberFormatOptionsPassed to Intl.NumberFormat: currency, percent, decimals.
localestring | string[] = "en-US"Fixed so the server and the browser print the same string. Set it to the reader's locale when you know it.
variant"subtle" | "roll" = "subtle"subtle for a value that changes often; roll for a rare moment.