Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: per word crossfade
dev_wandry26e7acc6bfbf
diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex dd0aef6a..54545236 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -176,6 +176,19 @@ Text effects, reveals, and kinetic type.]}/>+### Text Transitions++<ComponentCardGrid+ items={[+ {+ name: "PerWordCrossfade",+ description: "One phrase fades out as the next fades in, word by word",+ status: "stable",+ href: "/docs/typography/per-word-crossfade",+ },+ ]}+/>+## Environment & LightingBackgrounds, lighting, and atmosphere for your scenes.diff --git a/content/docs/typography/index.mdx b/content/docs/typography/index.mdxindex bd8f77af..16e26c81 100644--- a/content/docs/typography/index.mdx+++ b/content/docs/typography/index.mdx@@ -171,3 +171,18 @@ Every way text can move, fade, glitch, or stretch across the screen. From quiet},]}/>++## Text Transitions++Swap one phrase for another with motion.++<ComponentCardGrid+ items={[+ {+ name: "PerWordCrossfade",+ description: "One phrase fades out as the next fades in, word by word",+ status: "stable",+ href: "/docs/typography/per-word-crossfade",+ },+ ]}+/>diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex 053068e3..ea3e233a 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -13,6 +13,7 @@"blur-out-up","focus-blur-resolve","line-by-line-slide",+ "per-word-crossfade","staggered-fade-up","mask-reveal-up","tracking-in",diff --git a/content/docs/typography/per-word-crossfade.mdx b/content/docs/typography/per-word-crossfade.mdxnew file mode 100644index 00000000..573a640b--- /dev/null+++ b/content/docs/typography/per-word-crossfade.mdx@@ -0,0 +1,112 @@+---+title: Per-Word Crossfade+description: One phrase fades out as the next fades in, word by word+---++<ComponentPreview name="per-word-crossfade" />++## Installation++<InstallBlock name="per-word-crossfade" />++## Usage++```tsx+// src/Root.tsx+import { Composition } from "remotion";+import { PerWordCrossfade } from "@/components/remocn/per-word-crossfade";++const PerWordCrossfadeScene = () => (+ <PerWordCrossfade+ fromText="Beautifully simple."+ toText="Designed for focus."+ />+);++export const RemotionRoot = () => (+ <Composition+ id="PerWordCrossfade"+ component={PerWordCrossfadeScene}+ durationInFrames={90}+ fps={30}+ width={1280}+ height={720}+ />+);+```++The component transitions from one phrase to another, word by word. The fromText words drift up and fade out while the toText words fade in from below, overlapping for a calm keynote-style swap.++### With Backdrop++The component renders transparent — supply the background via `Backdrop`. It ships single-theme; edit the copied file to re-theme colors.++Pair with `Backdrop` to place the text inside a full-frame fill with a rounded, shadowed content frame:++```tsx+import { Composition } from "remotion";+import { PerWordCrossfade } from "@/components/remocn/per-word-crossfade";+import { Backdrop } from "@/components/remocn/backdrop";++const PerWordCrossfadeScene = () => (+ <Backdrop fill={{ type: "color", value: "#ffffff" }}>+ <PerWordCrossfade+ fromText="Beautifully simple."+ toText="Designed for focus."+ />+ </Backdrop>+);++export const RemotionRoot = () => (+ <Composition+ id="PerWordCrossfade"+ component={PerWordCrossfadeScene}+ durationInFrames={90}+ fps={30}+ width={1280}+ height={720}+ />+);+```++## Props++<PropsTable+ rows={[+ {+ name: "fromText",+ type: "string",+ required: true,+ description: "The outgoing phrase, shown first then exits.",+ },+ {+ name: "toText",+ type: "string",+ required: true,+ description: "The incoming phrase that fades in to replace it.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "72",+ description: "Font size in pixels",+ },+ {+ name: "fontWeight",+ type: "number",+ default: "600",+ description: "CSS font-weight",+ },+ {+ name: "color",+ type: "string",+ default: "\"#171717\"",+ description: "Text color (any valid CSS color)",+ },+ {+ name: "className",+ type: "string",+ description: "Optional className passed to the wrapper",+ },+ ]}+/>diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 63c078df..960dcd53 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -27,6 +27,8 @@ import { FocusBlurResolve } from "@/registry/remocn/focus-blur-resolve";import { focusBlurResolveConfig } from "@/registry/remocn/focus-blur-resolve/config";import { LineByLineSlide } from "@/registry/remocn/line-by-line-slide";import { lineByLineSlideConfig } from "@/registry/remocn/line-by-line-slide/config";+import { PerWordCrossfade } from "@/registry/remocn/per-word-crossfade";+import { perWordCrossfadeConfig } from "@/registry/remocn/per-word-crossfade/config";import { BrowserFlow } from "@/registry/remocn/browser-flow";import { browserFlowConfig } from "@/registry/remocn/browser-flow/config";import { ChatToPreviewLayout } from "@/registry/remocn/chat-to-preview-layout";@@ -220,6 +222,7 @@ const registry: Record<string, RegistryEntry> = {"blur-out-up": { Component: BlurOutUp, config: blurOutUpConfig },"focus-blur-resolve": { Component: FocusBlurResolve, config: focusBlurResolveConfig },"line-by-line-slide": { Component: LineByLineSlide, config: lineByLineSlideConfig },+ "per-word-crossfade": { Component: PerWordCrossfade, config: perWordCrossfadeConfig },typewriter: { Component: Typewriter, config: typewriterConfig },"inline-highlight": {Component: InlineHighlight,diff --git a/registry/remocn/per-word-crossfade/config.ts b/registry/remocn/per-word-crossfade/config.tsnew file mode 100644index 00000000..b392137a--- /dev/null+++ b/registry/remocn/per-word-crossfade/config.ts@@ -0,0 +1,36 @@+import {+ type ComponentConfig,+ FONT_WEIGHT_OPTIONS,+ FPS,+ H,+ W,+} from "@/lib/customizer-config";++export const perWordCrossfadeConfig: ComponentConfig = {+ componentName: "PerWordCrossfade",+ importPath: "@/components/remocn/per-word-crossfade",+ controls: {+ fromText: { type: "text", default: "Beautifully simple.", label: "From text" },+ toText: { type: "text", default: "Designed for focus.", label: "To text" },+ fontSize: {+ type: "number",+ default: 72,+ min: 12,+ max: 160,+ step: 1,+ label: "Font size",+ },+ color: { type: "color", default: "#171717", label: "Color" },+ fontWeight: {+ type: "select",+ default: "600",+ options: FONT_WEIGHT_OPTIONS,+ label: "Font weight",+ },+ },+ durationInFrames: 90,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#ffffff" },+};diff --git a/registry/remocn/per-word-crossfade/index.tsx b/registry/remocn/per-word-crossfade/index.tsxnew file mode 100644index 00000000..bd18f381--- /dev/null+++ b/registry/remocn/per-word-crossfade/index.tsx@@ -0,0 +1,151 @@+"use client";++import { Easing, interpolate, useCurrentFrame } from "remotion";++export interface PerWordCrossfadeProps {+ fromText: string;+ toText: string;+ fontSize?: number;+ color?: string;+ fontWeight?: number;+ speed?: number;+ className?: string;+}++export function PerWordCrossfade({+ fromText,+ toText,+ fontSize = 72,+ color = "#171717",+ fontWeight = 600,+ speed = 1,+ className,+}: PerWordCrossfadeProps) {+ const frame = useCurrentFrame() * speed;++ const fromWords = fromText.split(" ");+ const toWords = toText.split(" ");++ const enterDur = 21;+ const exitDur = 15;+ const enterStagger = 2;+ const exitStagger = 1;+ const overlapF = 5;+ const microDelayF = 2;++ const enterEasing = Easing.bezier(0.16, 1, 0.3, 1);+ const exitEasing = Easing.bezier(0.7, 0, 0.84, 0);++ const exitTotal = exitDur + (fromWords.length - 1) * exitStagger;+ const newStart = Math.max(0, exitTotal - overlapF + microDelayF);++ const fontStack =+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";++ return (+ <div+ className={className}+ style={{+ position: "absolute",+ inset: 0,+ background: "transparent",+ }}+ >+ <div+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span+ style={{+ fontSize,+ fontWeight,+ color,+ letterSpacing: "-0.03em",+ fontFamily: fontStack,+ }}+ >+ {fromWords.map((word, i) => {+ const local = frame - i * exitStagger;+ const opacity = interpolate(local, [0, exitDur], [1, 0], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: exitEasing,+ });+ const y = interpolate(local, [0, exitDur], [0, -6], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: exitEasing,+ });+ return (+ <span+ key={i}+ style={{+ display: "inline-block",+ marginRight: "0.25em",+ transformOrigin: "50% 55%",+ opacity,+ transform: `translateY(${y}px)`,+ }}+ >+ {word}+ </span>+ );+ })}+ </span>+ </div>++ <div+ style={{+ position: "absolute",+ inset: 0,+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span+ style={{+ fontSize,+ fontWeight,+ color,+ letterSpacing: "-0.03em",+ fontFamily: fontStack,+ }}+ >+ {toWords.map((word, j) => {+ const local = frame - newStart - j * enterStagger;+ const opacity = interpolate(local, [0, enterDur], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: enterEasing,+ });+ const y = interpolate(local, [0, enterDur], [8, 0], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: enterEasing,+ });+ return (+ <span+ key={j}+ style={{+ display: "inline-block",+ marginRight: "0.25em",+ transformOrigin: "50% 55%",+ opacity,+ transform: `translateY(${y}px)`,+ }}+ >+ {word}+ </span>+ );+ })}+ </span>+ </div>+ </div>+ );+}diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex cb3c82c2..ef892354 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -163,6 +163,22 @@}]},+ {+ "name": "per-word-crossfade",+ "type": "registry:component",+ "title": "Per-Word Crossfade",+ "description": "Words gently fade into place one after another, with a short vertical drift for a calm keynote rhythm.",+ "dependencies": [+ "remotion"+ ],+ "files": [+ {+ "path": "per-word-crossfade/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/per-word-crossfade.tsx"+ }+ ]+ },{"name": "typewriter","type": "registry:component",