Skip to content
Get Kosh Pro
← All components
Motion

ComponentsFlow Number

Flow Number

Only the digits that changed roll.

  • CSS layer
  • Implemented
  • Free to install · MIT
₹12,48,210.50
motion prop

onSettle has fired 0 times. The prop can only calm this component further. The switch at the top of the page and your system setting still apply.

Why it moves this way

A count-up re-animates the whole number and hides what changed. Rolling only the changed digits makes the size of the change visible: one digit rolling is a small change, four digits rolling is a big one. The colour says which way it went.

Use it

PowerShell / install
npx shadcn@latest add https://kosh-hazel.vercel.app/r/flow-number.json
React / TypeScript
import { FlowNumber } from "@/kosh/flow-number/flow-number";

<FlowNumber data={balance} />

<FlowNumber
  data={balance}
  locale="en-IN"
  prefix="₹"
  format={{ minimumFractionDigits: 2, maximumFractionDigits: 2 }}
  onSettle={() => console.log("at rest")}
/>

Add the @kosh registry entry to components.json first, so the CLI can fetch motion-core as well. Then wrap your app in KoshProvider once, and import tokens.css and motion.css in your global stylesheet. Read the setup guide ↗ Read the source ↗

At each motion level

full
Each changed digit rolls to its new value in 300 ms, the short way round (9 to 0 is one step), 20 ms apart from the right. Changed digits flash the trend colour and cool back over 2.4 s.
reduced
Digits swap at once. The flash and the cool-down still run, because they are opacity only.
none
The new number, immediately. The digits that changed keep the trend colour until the next update.

Props

Flow Number props
PropTypeDefaultWhat it does
datanumberrequiredThe value to show. A different number triggers an update.
formatIntl.NumberFormatOptionsno fraction digitsPassed to Intl.NumberFormat.
localestring"en-US"Grouping and digit style.
prefixstringnoneShown before the number, for example "₹".
suffixstringnoneShown after the number, for example "%".
minCharsnumbernoneReserves room for at least this many characters, so a growing number never shifts the layout.
Shared by every Kosh component
PropTypeDefaultWhat it does
motion"auto" | "full" | "reduced" | "none""auto"Motion for this component only. The calmest of this prop, the provider and the operating system wins.
tone"ink" | "signal" | "muted""ink"Which colour carries the data.
onSettle() => voidnoneCalled once the component has come to rest after an update.
classNamestringnoneAdded to the root element.

Theme with CSS variables on any ancestor: --k-flow-up, --k-flow-down, --k-dur-roll, --k-dur-cool.

Accessibility

  • Screen readers get the formatted number as real text. The rolling digits are hidden from them.
  • It does not announce itself. A ticking number that speaks is noise. Put a status region beside it if a change needs announcing.
  • The signal colour is about 3:1 on a light canvas. For numbers under 24 px, set --k-flow-up to var(--k-signal-deep).

Limits and differences

  • The fade of a place that disappears (1,000 to 999) is positioned for a right-aligned number. Set minChars, or right-align it, when that matters.