Rolling Number

A number whose digits roll to a new value, as an odometer, for a total, a balance or a count that changes while it is watched.

import { RollingNumber } from "@plexui/vue/components/RollingNumber";

A rolling number turns each changed digit to its new value, as the wheels of an odometer do, so a total or a count that changes in front of the reader shows the change. Use it where a number moves while it is watched, such as a total as items are added; a number that only loads once needs none.

Examples

Overview

format
$1,284.00

In text

3 items in your bag

API

RollingNumber

PropTypeDefaultDescription
valuenumber—The number shown; a new value rolls each changed digit to it
localesstring | string[]"en-US"The locale the number is written in; fixed rather than the browser's, so the server writes it as the browser does. Its own digits roll, such as Arabic-Indic
formatIntl.NumberFormatOptions—How it is written: a currency, a percent, fraction digits, grouping
classstring—Applied to the root span; set the size and weight here

Other attributes fall through to the root <span>. The written number is in a visually hidden span; the reels are aria-hidden.

Styling

  • --rolling-number-duration: how long a digit rolls (defaults to 600ms)
  • --rolling-number-ease: its easing (defaults to --cubic-move)