Select Replace

A phrase in a sentence is selected like text in an editor (highlight band), deleted, and new italic serif words are typed in its place, e.g. turning a slow plan into a fast one. A free, MIT-licensed Remotion text animation.

In Remotion, Select Replace shows a sentence, moves a caret to a phrase, sweeps a selection highlight over it like a text editor, deletes it and types new styled words in its place, one edit after another. Use it to rewrite a slow plan into a fast one (Draft it next week. becomes Ship it tonight.) in a product or writing-tool video.

Installation
$ pnpm dlx shadcn@latest add @remocn/select-replace

How to animate text being selected, deleted and retyped in Remotion

A phrase selected like in a text editor, deleted, then retyped with new styled words is one component. Install it and pass the sentence and the edits:

bash
npx shadcn@latest add @remocn/select-replace
  • text is the starting sentence; edits is a list of { from, to } pairs applied in order. For each one a caret moves to from, a selection band sweeps over it, holds for hold frames, and to is typed in key by key.
  • Typed words are set in an italic serif (Newsreader) in the accent color; the rest of the line uses fontFamily (Geist by default). Both fonts load through @remotion/google-fonts inside the component, so there is no font setup step. To change the typed words beyond accent and fontWeight, edit the copied file.
  • The line is measured on a canvas, so it recenters as its width changes instead of reflowing; motion uses interpolate() with Easing.bezier.

For a single typo fixed in place use Typo Fix; for a code-style diff use Diff Swap.

Good to know

  • Length: 130 frames of motion at 30 fps (260 at 60 fps) with the two default edits; each extra edit adds time. That is the minimum for its Sequence; add your own hold on top. The Usage example below is a 60 fps composition with a hold: 340 frames at 60 fps is 170 at 30 fps, 130 of motion plus 40 of hold. The component's own props counted in frames stay in 30 fps frames at any frame rate, see Frame rate.
  • Fonts: Geist for the line and Newsreader italic for the typed words, both loaded with @remotion/google-fonts.

Usage

tsx
// src/Root.tsx
import { Composition } from "remotion";
import { SelectReplace } from "@/components/remocn/select-replace";
 
const SelectReplaceScene = () => (
  <SelectReplace text="Draft it next week." edits={[{ from: "Draft", to: "Ship" }, { from: "next week", to: "tonight" }]} />
);
 
export const RemotionRoot = () => (
  <Composition
    id="SelectReplace"
    component={SelectReplaceScene}
    durationInFrames={340}
    fps={60}
    width={1280}
    height={720}
  />
);

The text shows, then each edits item selects a from phrase and swaps in its to replacement with a highlight. Pass text and edits with the phrases you want changed. It ships in light and dark through the theme prop.

Props12

PropTypeDefault
text
string"Draft it next week."

Starting sentence containing every `from` phrase.

edits
SelectReplaceEdit[]—

List of `{ from, to }` replacements applied in order.

hold
number9

Frames the selection holds before it is typed over.

fontWeight
number500

Weight of the line; typed words stay in the italic serif.

accent
string"#3B5BFD"

Accent color override; falls back to the theme accent.

ink
string—

Text color; overrides the theme ink.

background
string—

Background fill; pass "transparent" to drop it.

fontFamily
string"Geist"

Typeface for the line; typed words keep the italic serif. Load the font in your project first.

scale
number1

Size of the foreground around the frame's center; the background stays put.

delay
number0

Frames to hold the first frame before anything moves.

theme
"dark" | "light""dark"

Ships light and dark; picks the palette.

speed
number1

Playback speed multiplier for the whole timeline.

  • textstring

    Starting sentence containing every `from` phrase.

    Default"Draft it next week."

  • editsSelectReplaceEdit[]

    List of `{ from, to }` replacements applied in order.

  • holdnumber

    Frames the selection holds before it is typed over.

    Default9

  • fontWeightnumber

    Weight of the line; typed words stay in the italic serif.

    Default500

  • accentstring

    Accent color override; falls back to the theme accent.

    Default"#3B5BFD"

  • inkstring

    Text color; overrides the theme ink.

  • backgroundstring

    Background fill; pass "transparent" to drop it.

  • fontFamilystring

    Typeface for the line; typed words keep the italic serif. Load the font in your project first.

    Default"Geist"

  • scalenumber

    Size of the foreground around the frame's center; the background stays put.

    Default1

  • delaynumber

    Frames to hold the first frame before anything moves.

    Default0

  • theme"dark" | "light"

    Ships light and dark; picks the palette.

    Default"dark"

  • speednumber

    Playback speed multiplier for the whole timeline.

    Default1