Interaction JS behaviour

Odometer

A number whose digits roll in masked columns — each digit on its own, upward when it grows and downward when it shrinks — in Persian digits, Intl-formatted, starting when it is seen.

Real scenarios

The component as it is used in a product — not a specimen grid.

Today’s sales, from the server

The figures roll in when they scroll into view. “Refresh” asks Livewire for new numbers: only the digits that changed move, upward when a figure grew and downward when it fell — refunds usually fall.

Orders 1,284
Revenue (toman) 48,250,000
Refunds 37

Visitors right now

Driven from the browser with set(): the count drifts every couple of seconds, so the last column rolls both ways.

312 online

Formatted with Intl

Any Intl.NumberFormat options: a dollar balance with cents, and a Persian percentage in Persian digits whatever the page language.

12,481 ۱

Important props

Important props
Prop Type Default What it does
value number 0 The value; whenever Livewire renders a new one the digits roll.
format array [] Intl.NumberFormat options — currency, percent, compact…
locale string app locale The digits’ language; fa gives Persian digits and the ٬ separator.
from / reveal number / bool 0 / true Where and when the first roll starts: with reveal it rolls from `from` once in view.

Snippet

<x-nx::odometer :value="$revenue" :format="['style' => 'currency', 'currency' => 'IRR', 'notation' => 'compact']" />