Value Swap
A number, price or status slides out vertically and the new value slides in at an exact frame, holding its width so the layout never shifts. A free, MIT-licensed Remotion text animation.
In Remotion, Value Swap replaces a value in place, such as an old price with a new one, with a vertical slide, and holds the width of the longest value so nothing around it shifts. Use it inline inside your own text when a value changes at a specific story beat.
$ pnpm dlx shadcn@latest add @remocn/value-swapHow to build this in Remotion
You don't need AnimatePresence, @remotion/transitions or two absolutely positioned spans. Install the component and drop it inside your own text:
npx shadcn@latest add @remocn/value-swapIt renders an inline span that inherits the surrounding typography. On each frame listed in at, the old value slides up by distance pixels and fades while the new one rides in from below over duration frames. An invisible sizer as wide as the longest value holds the line, so the words around it never move.
Good to know
- Timing: each swap starts on a frame you list in
atand slides fordurationframes (10 by default), counted in 30 fps frames at any composition frame rate, see Frame rate. - Installs:
remotionfrom npm, plus the remocn helpersglide,frame-rate,timeline. The shadcn CLI copies the source into your project. - It renders an inline
spanthat inherits your typography, so it needs no font of its own.directionsets whether values rollupordown.
Usage
ValueSwap renders an inline span that inherits the surrounding typography and swaps its content at the exact frames you pass in at — the outgoing value slides up and fades as the incoming one rides in from below, one continuous upward motion, while an invisible sizer holds the width of the longest value so the layout never shifts. It is the string analog of rolling-number for arbitrary text.
import { ValueSwap } from "@/components/remocn/value-swap";
export const MyScene = () => (
<span style={{ fontSize: 40, fontWeight: 600 }}>
<ValueSwap values={["$99", "$199"]} at={45} />
</span>
);Chain more than one swap by passing an array of frames, one per transition:
<ValueSwap values={["Draft", "In review", "Shipped"]} at={[30, 60]} />A tight before/after pair reads best with a snappier swap — try duration={9} distance={9}. direction="down" mirrors the motion for downward narratives — a price dropping, a rank falling.
rolodex-flip is a 3D card flip with its own rhythm (interval) — reach for it when values cycle as a montage; ValueSwap is a flat vertical slide at explicit frames — reach for it for a point change (before → after, a status or price flip); rolling-number animates numeric digits individually.
Props7
| Prop | Type | Default |
|---|---|---|
| values | string[]— Values in order. Two or more. | |
| at | number | number[]— Frame of each swap. A number for a pair, an array of length values.length - 1 for a chain. | |
| duration | number10 Frames per swap. | |
| distance | number12 Vertical travel in pixels. | |
| direction | "up" | "down""up" Direction of the through-motion. | |
| className | string— Passed to the wrapper span. | |
| style | CSSProperties— Merged onto the wrapper span. | |
- valuesstring[]
Values in order. Two or more.
Default
— - atnumber | number[]
Frame of each swap. A number for a pair, an array of length values.length - 1 for a chain.
Default
— - durationnumber
Frames per swap.
Default
10 - distancenumber
Vertical travel in pixels.
Default
12 - direction"up" | "down"
Direction of the through-motion.
Default
"up" - classNamestring
Passed to the wrapper span.
Default
— - styleCSSProperties
Merged onto the wrapper span.
Default
—
Common questions
How do I animate a number or status changing without moving the layout?
Install Value Swap with npx shadcn@latest add @remocn/value-swap, pass values and the swap frame in at. The width of the longest value is reserved, so nothing shifts.
Can the value slide down instead of up?
Yes, pass direction="down", for example for a price drop.
Can I chain more than two values?
Yes. Pass three or more values and one frame per swap in at.
Related effects
- Rolodex Flip: values cycle as a 3D card flip.
- Rolling Number: a number counts up digit by digit.
- Number Wheel: digits roll on wheels.
- Inline Word Roll: a rotating word after a fixed prefix.