Word swap

One word changes inside a sentence that stays still, so the viewer sees exactly what is different.

Rendered video, with motion blur.

Built for teamsfoundersdesigners
0.00 / 6.00 s

Live preview, driven by the code below. No motion blur.

What it does

The old word lifts away and fades while the new one rises into its place; the rest of the sentence stays put.

Curve

Cubic out

Values

S is the frame's short side, 1080 px at 1080p. Unmeasured inputs in the preview are illustrations, not rules.

FactValue
Purpose
Emphasis
Acts on
Word
Typical length
0.5 to 0.6 s (15 to 18 frames at 30 fps), per swap
Caution
One changing slot per sentence; the rest of the line never moves except to make room.
PropertyValue
Old word
Leaves up 0.4 em and fades in 0.25 s, ease-in cubic
New word
Enters from 0.4 em below in 0.35 s, ease-out cubic, starting 0.1 s before the old word has gone
Rest of the line
Slides to its new place in 0.35 s, ease-in-out cubic, only if the width changes
Hold
Hold formula: 0.75 s + words / 2.5 + 0.5 s, minimum 1.2 s
Export samples
12; 1 when still

Starting values from research. Measure against a reference before relying on them.

Code

ts
export const seg = (t: number, a: number, b: number) => Math.max(0, Math.min(1, (t - a) / (b - a)));

export const lerp = (a: number, b: number, k: number) => a + (b - a) * k;

export const out = (k: number) => (k >= 1 ? 1 : 1 - Math.pow(2, -10 * k));

export const io = (k: number) => (k < 0.5 ? 16 * k ** 5 : 1 - Math.pow(-2 * k + 2, 5) / 2);

export const inn = (k: number) => k * k * k;

export const cubicOut = (k: number) => 1 - Math.pow(1 - k, 3);

export const h = (i: number, j: number) => { const x = Math.sin(i * 127.1 + j * 311.7) * 43758.5453; return x - Math.floor(x); };

export const phase = (t: number, start = 0, duration = 0.6) => seg(t, start, start + duration);

export const easeInOut = (p: number) => p < 0.5 ? 4 * p ** 3 : 1 - (-2 * p + 2) ** 3 / 2;

export const holdTime = (words: number) => Math.max(1.2, 0.75 + words / 2.5 + 0.5);

export function wordSwapOut(t: number, start: number, em: number) {
  const k = inn(phase(t, start, 0.25));
  return { y: -0.4 * em * k, opacity: 1 - k };
}

export function wordSwapIn(t: number, start: number, em: number) {
  const p = phase(t, start + 0.15, 0.35);
  return { y: 0.4 * em * (1 - cubicOut(p)), opacity: cubicOut(p) };
}

export const wordSwapShift = (t: number, start: number, widthChange: number) => ({ x: widthChange * easeInOut(phase(t, start, 0.35)) });

Best practices

Use it forAvoid
Showing who a product is for, one audience at a time
More than one changing slot per sentence
A single changed value inside a fixed sentence
Moving the rest of the line except to make room

Reduced motion: a simple opacity fade over 0.2 s.