Digit Swap

Rolls only the digits that change.

$96/mo

12 seats

•••• •••• •••• 4242

Installation

pnpm dlx shadcn@latest add @paneui/digit-swap

Usage

Examples

Auto Direction

Odometer

Fixed Direction

Replay

Motion

Glyphs slide 60% and blur 2px while fading, with an ease-out curve. With reduced motion they only cross-fade, capped at 150ms and with no stagger.

Accessibility

The full value is rendered once as screen-reader text; the animated glyphs are aria-hidden.

API Reference

DigitSwap

Fixed-slot characters that roll when they change. Digits sit in 1ch slots keyed from the right, so nothing jitters. Also accepts every prop of span.

value*
string | number
Number or pre-formatted string ("$1,204", "•••• 4242"). Each character gets its own slot.
direction= "auto"
"up" | "down" | "auto"
Where new glyphs enter from. auto picks up when the numeric value grows and down when it shrinks.
duration= 0.32
number
Seconds per glyph roll.
stagger= 0.02
number
Seconds between neighbouring glyphs.
staggerFrom= "start"
"start" | "end"
Which end the stagger starts from. end ripples right to left.
animationKey
string | number
Change it to replay every glyph even when the characters are the same.
suffixLength= 0
number
Number of trailing characters that get suffixClassName (units, cents, /mo).
glyphClassName
string
Class for each animated glyph.
suffixClassName
string
Class for the trailing suffixLength slots.
PropTypeDefaultDescription
value*string | number—Number or pre-formatted string ("$1,204", "•••• 4242"). Each character gets its own slot.
direction"up" | "down" | "auto""auto"Where new glyphs enter from. auto picks up when the numeric value grows and down when it shrinks.
durationnumber0.32Seconds per glyph roll.
staggernumber0.02Seconds between neighbouring glyphs.
staggerFrom"start" | "end""start"Which end the stagger starts from. end ripples right to left.
animationKeystring | number—Change it to replay every glyph even when the characters are the same.
suffixLengthnumber0Number of trailing characters that get suffixClassName (units, cents, /mo).
glyphClassNamestring—Class for each animated glyph.
suffixClassNamestring—Class for the trailing suffixLength slots.
data-direction
up or down: the direction of the latest roll.
Data attributeDescription
data-directionup or down: the direction of the latest roll.