Number flow
Animated numbers where only the changed digits spin, with any Intl format and locale.
Used in Pro blocks: Artifact, Diff Review, Test Results, and 1 more
pnpm dlx shadcn@latest add https://hextaui.com/r/number-flow.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add cnCopy and paste the following code into your project.
components/ui/number-flow.tsx lib/motion.ts Update the import paths to match your project setup.
Each digit is its own column. Going from 22 to 23 spins only the ones digit; the tens digit stays still. Digits that appear or disappear, like the third digit in 99 → 100, slide their width in or out.
trend sets which way digits spin. auto spins up when the value grows and down when it shrinks, up and down force a direction, and shortest takes the nearest way round the wheel.
format and locales take any Intl.NumberFormat options. Currency symbols, separators and signs stay still while the digits move, and non-Latin numerals spin in their own script.
Tune the motion with duration and easing, or turn it off with animated={false}. Reduced motion settings turn it off automatically.
A new value mid-spin continues from where each digit is, so rapid updates never jump. onAnimationsStart and onAnimationsFinish fire once per batch of digits.
It renders an inline <span> that sits on the text baseline, and tabular digits keep its width steady while digits spin. BadgeCount uses it for counts that cap at a maximum.
Numbers always read left to right, even inside a right-to-left layout, matching how browsers render them.
- Screen readers read the real formatted number. The spinning columns are hidden from assistive tech, and characters that are leaving are hidden while they animate out.
- It is not a live region. Wrap it in an element with
aria-live="polite"when changes should be announced. - With reduced motion enabled, values update instantly with no spin.
Accepts every <span> attribute except children and prefix.
| Prop | Type | Default |
|---|---|---|
valueRequired. | number | – |
locales | Intl.LocalesArgument | "en-US" |
formatPassed to Intl.NumberFormat. | Intl.NumberFormatOptions | – |
prefixStatic text before the number. | string | – |
suffixStatic text after the number. | string | – |
trend | "auto" | "up" | "down" | "shortest" | "auto" |
durationSpin duration in milliseconds. | number | 600 |
easingAny CSS easing value. | string | easeSpring |
animated | boolean | true |
onAnimationsStartCalled when a batch of digits starts moving. | () => void | – |
onAnimationsFinishCalled when the latest batch settles. Skipped if a newer value interrupts it. | () => void | – |
| Attribute | Description |
|---|---|
data-slot="number-flow" | The root span. |
data-slot="number-flow-digit" | Each digit cell. |
data-slot="number-flow-symbol" | Separators, signs, symbols, prefix and suffix. |
data-slot="number-flow-column" | The spinning column inside a digit cell. |
data-digit | The digit a column is resting on, 0–9. |
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- AvatarUser photos with an initials fallback, status badges and stacked groups that collapse into a count.
- BadgeStatus labels with colored dots, removable tags that slide closed and counts that roll to their new value.
- CardA surface for grouping content, with three variants, edge-to-edge media, concentric radii and whole-card links.
- ChartRecharts charts with themed colors, a tooltip and legend that read labels from one config, and keyboard navigation with a visible focus ring.
- Data tableA table for real data, with sorting, search, row selection, pinned columns, a sticky header and pagination.
Used in Pro blocks
Blocks that build on Number flow.
- ArtifactThe panel beside an AI chat that shows what the model made. Handles content still streaming, a sandboxed preview and versions you can restore.
- Diff ReviewA review of an agent’s file edits before they land. Handles accept or reject per change, comments back to the agent and edits still streaming.
- Test ResultsAn agent’s test run, shown as it happens. Tests stream in and fold into a summary, with every failure left open and its diff in view.
- Prompt InputA chat composer that grows as you type. Handles file uploads, @ and / menus at the caret and messages typed while a reply streams.
Every block comes with HextaUI Pro, and Prompt Input is free.