Slot Machine Roll

Each character of a price or value scrolls vertically like a slot machine reel from the old string to the new one, left to right, so $99 rolls over to $199 with the dollar sign and symbols kept. A free, MIT-licensed Remotion text animation.

In Remotion, Slot Machine Roll makes a price like $29 roll over to $49 with each character scrolling vertically like a slot machine reel: the old character slides up out of its window and the new one rolls in from below, column by column, left to right. Symbols such as $, % and × are ordinary characters in the string, so they roll or stay put like any digit.

Installation
$ pnpm dlx shadcn@latest add @remocn/slot-machine-roll

How to roll a price over like a slot machine in Remotion

You don't need an odometer package or a hand-built spring() per digit. Install the component and pass the old and new value as strings:

bash
npx shadcn@latest add @remocn/slot-machine-roll
  • Every character of from and to gets its own column, a window one character tall. Inside it the old character sits above the new one, and a spring() (damping 14) scrolls the strip up by one line, so the old character leaves at the top and the new one lands from below.
  • Columns start 4 frames apart from left to right; each roll settles in about 21 frames at 30 fps. With $99 → $199 (four columns) the last column starts at frame 12.
  • The reel holds exactly two characters per column, the old and the new one. There is no fixed character set and no spin through intermediate digits: any character works, including $, %, ×, , and letters.
  • When from and to differ in length, the shorter one is padded with spaces on the left, so the values line up on the right. In $99 → $199 the first column rolls from a blank to $, and a × that exists only in the longer string rolls in from (or out to) a blank.
  • If a character is the same in both strings, its column still scrolls, but the same glyph replaces itself, so it reads as standing still.

For a large pure integer such as 1,240,000, use Rolling Number, which animates each decimal place as a composed odometer.

Good to know

  • Length: 90 frames at 30 fps (180 at 60 fps) for the demo, including the hold; the roll itself is done well before that. The Usage example below is a 60 fps composition, so the numbers it hands to Remotion are doubled, see Frame rate.
  • Timing: speed is the only tempo prop. There are no props for easing, stagger or roll duration; the timing prop moves, trims or stretches single columns by their ids (column:0, column:1…), and the constants STAGGER and ROLL live in the copied timeline.ts.
  • Background: the component fills the frame with white, and there is no background prop. Edit the fill in the copied file to change or remove it.
  • Font: no font is loaded. The text uses the --font-geist-sans CSS variable with a system sans fallback; pass className to set your own font on the text, and load that font in your project.
  • Installs: remotion from npm, plus the remocn helpers glide, frame-rate, timeline. The shadcn CLI copies the source into your project.

Usage

tsx
// src/Root.tsx
import { Composition } from "remotion";
import { SlotMachineRoll } from "@/components/remocn/slot-machine-roll";
 
const SlotMachineRollScene = () => (
  <SlotMachineRoll from="$99" to="$199" fontSize={120} />
);
 
export const RemotionRoot = () => (
  <Composition
    id="SlotMachineRoll"
    component={SlotMachineRollScene}
    durationInFrames={180}
    fps={60}
    width={1280}
    height={720}
  />
);

Props7

PropTypeDefault
from
string"$99"

Starting value shown before the reel rolls

to
string"$199"

Target value the reel settles on

fontSize
number120

Font size in pixels. Used to compute reel travel distance.

color
string"#171717"

Text color

fontWeight
number700

CSS font-weight

speed
number1

Multiplier for animation speed

className
string—

Optional className passed to the outer text span

  • fromstring

    Starting value shown before the reel rolls

    Default"$99"

  • tostring

    Target value the reel settles on

    Default"$199"

  • fontSizenumber

    Font size in pixels. Used to compute reel travel distance.

    Default120

  • colorstring

    Text color

    Default"#171717"

  • fontWeightnumber

    CSS font-weight

    Default700

  • speednumber

    Multiplier for animation speed

    Default1

  • classNamestring

    Optional className passed to the outer text span

Common questions

How do I make a price like $29 roll over to $49 in Remotion?

Install Slot Machine Roll with npx shadcn@latest add @remocn/slot-machine-roll and render <SlotMachineRoll from="$29" to="$49" />. Each character scrolls vertically to its new value, one column after another, and the $ stays in place.

Does it work with %, × and other symbols?

Yes. The strings are split into characters, and every character, symbol or digit, gets its own reel window. from="2×" and to="10×" works; the shorter value is padded with a blank on the left.

Does each digit spin through 0 to 9 like a real slot machine?

No. Each column scrolls once, from the old character to the new one. For a counter that counts up through the values, use Rolling Number or Number Wheel.

Can I change the background color?

Not with a prop: the background is white in the copied file. Edit it there, or set color to change the text color.

  • Rolling Number: an odometer that counts up a large integer.
  • Value Swap: a number, price or status slides out and is replaced, with no layout shift.
  • Number Wheel: a number eases to a target value.