cnippet/ui
  1. motion
  2. text animations
  3. sliding number

text animations

Sliding Number

Each digit slides up or down independently using spring physics when its value changes — an odometer-style display for live or user-driven numbers.

Installation

Usage

Anatomy

Good to know

  • It animates whenever value changes. Update value from state.
  • padStart adds a leading zero to single-digit numbers, useful for clocks and timers.
  • decimalSeparator sets the character used for decimals (default ".").
  • When the user has turned on reduced motion, digits jump to the new value instead of sliding.

Props

Examples

Increment / Decrement

Increment and decrement buttons drive a single SlidingNumber. Each digit column slides independently so only the changed place animates.

Live Clock

Hours, minutes, and seconds each rendered as a separate SlidingNumber with padStart. The seconds column slides every tick while higher columns stay still.

Pricing Plan Switcher

Switching between plan tiers updates both price and seat count simultaneously. The odometer motion makes the price change feel tangible rather than instant.