A silky vertical odometer counter where every numerical digit slides independently inside a masked tabular-nums reel when switching currencies or receiving live balance updates.
'use client'
import { useState } from 'react'
export function OdometerNumber({ value }: { value: number }) {
const formatted = '$' + value.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
return (
<div className="inline-flex font-mono text-4xl font-semibold tabular-nums text-white" aria-live="polite">
{[...formatted].map((ch, idx) =>
/\d/.test(ch) ? (
<span key={idx} className="inline-block h-[1.1em] overflow-hidden">
<span
className="flex flex-col transition-transform duration-700 ease-out"
style={{ transform: `translateY(-${Number(ch) * 1.1}em)` }}
>
{[0,1,2,3,4,5,6,7,8,9].map((d) => <span key={d} className="h-[1.1em]">{d}</span>)}
</span>
</span>
) : (
<span key={idx} className="opacity-65">{ch}</span>
),
)}
</div>
)
}
export function TreasuryCounterDemo() {
const [balance, setBalance] = useState(128450.8)
return (
<div className="flex flex-col gap-4 rounded-2xl border border-white/10 bg-[#101624] p-6">
<OdometerNumber value={balance} />
<button
type="button"
onClick={() => setBalance((b) => Number((b + 1250.4).toFixed(2)))}
style={{ background: `linear-gradient(135deg, #10b981, #06b6d4)` }}
className="w-fit rounded-xl px-4 py-2 font-mono text-xs font-bold text-slate-950"
>
+$1,250.40
</button>
</div>
)
}Loading single-file HTML…
Build a single-file FinTech Odometer Rolling Balance Counter using pure HTML, CSS, and vanilla JS (zero dependencies) inspired by Stripe and Apple Stocks on a dark treasury surface (#080c14). - Odometer Mechanics: Render each numerical digit inside an overflow-hidden 1.08em slot containing a vertical 0–9 flex reel animated via translateY and cubic-bezier(0.22, 1, 0.36, 1) with font-variant-numeric: tabular-nums so digits never jitter horizontally. - Interactive Demo: Include currency switcher buttons (USD, EUR, GBP) and a live +$1,250.40 deposit button with an emerald APY pill (#10b981 → #06b6d4). - A11y: aria-live="polite" and prefers-reduced-motion instant-snap support.
WHY THIS WORKS IN PRODUCTION
- Each digit column slides smoothly in its own masked vertical 0–9 reel
- Tabular-nums alignment guarantees zero horizontal layout jitter
- Perfect for KPI dashboards, SaaS pricing toggles, and wallet balances
- 2.4 KB zero-dependency code + reusable <OdometerNumber /> React TSX
DROP-IN SPECS // WEB & MOBILE FIT








