Ruby Press
A word in a sentence is pushed out and replaced by the next one from a list: each next word appears as a tiny annotation above the slot, then presses down into the line. A free, MIT-licensed Remotion text animation.
In Remotion, Ruby Press swaps one word of a sentence through a list: the next word appears as a tiny annotation above the slot, like ruby text, then grows and presses down into the line, pushing the current word out. Use it for a claim whose time frame keeps shrinking, or a localization beat that cycles through markets.
$ pnpm dlx shadcn@latest add @remocn/ruby-pressHow to replace a word in a sentence with a small annotation above it in Remotion
A word that gets pushed out of a sentence by the next one, which first shows as a small note above it, is one component. Install it and pass the sentence around the slot:
npx shadcn@latest add @remocn/ruby-pressbeforeis the lead text,wordsthe values for the slot,afterthe text after it.- The small annotations are the words themselves: each next entry of
wordsshows small above the slot, then presses down into the line. There is no separate gloss text prop. - The slot width animates from one word to the next, so the words after the slot slide over to make room. For a slot that keeps one width use Width Lock.
holdsets how long each word stays,presshow long a gloss takes to press down,staggerthe frames between words as the line rises in.- Word widths are measured on a canvas before the first frame, so you don't need
@remotion/layout-utils.
Good to know
- Length: 134 frames of motion at 30 fps with the three default words (268 at 60 fps). The Usage example runs 340 frames at 60 fps, which adds a hold.
- Length for your own list, in 30 fps frames: each swap takes
24 + press + holdframes (60 by default), and the last one ends 14 frames sooner, so N words need60 * (N - 1) + 14frames with the defaultholdandpress. The props counted in frames stay in 30 fps frames at any frame rate, see Frame rate. - Installs:
remotion,@remotion/google-fontsfrom npm, plus the remocn helpersglide,frame-rateandtimeline. The shadcn CLI copies the source into your project. - Font: loads Zen Kaku Gothic New itself through
@remotion/google-fonts. PassfontFamilyto use your own face, and load that font in your project.
Usage
// src/Root.tsx
import { Composition } from "remotion";
import { RubyPress } from "@/components/remocn/ruby-press";
const RubyPressScene = () => (
<RubyPress before="Subtitles for every market in" words={["a fortnight", "a morning", "one render"]} after="." />
);
export const RemotionRoot = () => (
<Composition
id="RubyPress"
component={RubyPressScene}
durationInFrames={340}
fps={60}
width={1280}
height={720}
/>
);Each entry in words is pressed down and swapped for the next inside a sentence built from before and after, with a small gloss rising above each. Pass before, words and after. It ships in light and dark through the theme prop.
Props14
| Prop | Type | Default |
|---|---|---|
| before | string"Subtitles for every market in" Text before the swapping word. | |
| words | string[]— Words pressed in order. | |
| after | string"." Text after the swapping word. | |
| hold | number14 Frames each state stays on screen before the next one. | |
| stagger | number3 Frames between words as the lead line rises in. | |
| press | number22 Frames the gloss takes to press down into the line. | |
| accent | string— Accent color override; falls back to the theme accent. | |
| ink | string— Text color; overrides the theme ink. | |
| background | string— Background color override; falls back to the theme background. | |
| fontFamily | string"Zen Kaku Gothic New" Typeface for the copy. 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. | |
| speed | number1 Playback speed multiplier for the whole timeline. | |
| theme | "dark" | "light""dark" Ships light and dark; picks the palette. | |
- beforestring
Text before the swapping word.
Default
"Subtitles for every market in" - wordsstring[]
Words pressed in order.
- afterstring
Text after the swapping word.
Default
"." - holdnumber
Frames each state stays on screen before the next one.
Default
14 - staggernumber
Frames between words as the lead line rises in.
Default
3 - pressnumber
Frames the gloss takes to press down into the line.
Default
22 - accentstring
Accent color override; falls back to the theme accent.
- inkstring
Text color; overrides the theme ink.
- backgroundstring
Background color override; falls back to the theme background.
- fontFamilystring
Typeface for the copy. Load the font in your project first.
Default
"Zen Kaku Gothic New" - 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 - speednumber
Playback speed multiplier for the whole timeline.
Default
1 - theme"dark" | "light"
Ships light and dark; picks the palette.
Default
"dark"