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.
$ pnpm dlx shadcn@latest add @remocn/select-replaceHow 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:
npx shadcn@latest add @remocn/select-replacetextis the starting sentence;editsis a list of{ from, to }pairs applied in order. For each one a caret moves tofrom, a selection band sweeps over it, holds forholdframes, andtois typed in key by key.- Typed words are set in an italic serif (Newsreader) in the
accentcolor; the rest of the line usesfontFamily(Geist by default). Both fonts load through@remotion/google-fontsinside the component, so there is no font setup step. To change the typed words beyondaccentandfontWeight, edit the copied file. - The
timingprop moves or stretches theintro, eachselect:<n>(caret and highlight) and eachtype:<n>(delete and retype) by id, in 30 fps frames. - The line is measured on a canvas, so it recenters as its width changes instead of reflowing; motion uses
interpolate()withEasing.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
// 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.
Props13
| Prop | Type | Default |
|---|---|---|
| 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. | |
| timing | Timing<"intro" | `select:${number}` | `type:${number}`>— Moves, trims or stretches the intro, each selection and each retyping by id, in 30 fps frames. | |
- 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.
Default
9 - fontWeightnumber
Weight of the line; typed words stay in the italic serif.
Default
500 - 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.
Default
1 - delaynumber
Frames to hold the first frame before anything moves.
Default
0 - theme"dark" | "light"
Ships light and dark; picks the palette.
Default
"dark" - speednumber
Playback speed multiplier for the whole timeline.
Default
1 - timingTiming<"intro" | `select:${number}` | `type:${number}`>
Moves, trims or stretches the intro, each selection and each retyping by id, in 30 fps frames.