Skip to content

πŸŽ₯ Make videos programmatically with React

Use code examples as skills for code generation, remove examples from guidance markdown files

ASchwad97a885d667cd
diff --git a/bun.lock b/bun.lock
index 018f709eff..24db894f1c 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1717,6 +1717,7 @@
"eslint-config-next": "15.1.6",
"postcss": "8.4.47",
"prettier": "3.6.0",
+ "raw-loader": "^4.0.2",
"tailwindcss": "4.0.3",
"tw-animate-css": "1.4.0",
"typescript": "5.9.3",
@@ -6346,6 +6347,8 @@
"raw-body": ["[email protected]", "", { "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", "iconv-lite": "0.6.3", "unpipe": "1.0.0" } }, "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g=="],
+ "raw-loader": ["[email protected]", "", { "dependencies": { "loader-utils": "^2.0.0", "schema-utils": "^3.0.0" }, "peerDependencies": { "webpack": "^4.0.0 || ^5.0.0" } }, "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA=="],
+
"rc": ["[email protected]", "", { "dependencies": { "deep-extend": "0.6.0", "ini": "1.3.8", "minimist": "1.2.6", "strip-json-comments": "2.0.1" }, "bin": { "rc": "./cli.js" } }, "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw=="],
"react": ["[email protected]", "", {}, "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA=="],
@@ -9342,6 +9345,10 @@
"raw-body/iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": "2.1.2" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],
+ "raw-loader/loader-utils": ["[email protected]", "", { "dependencies": { "big.js": "5.2.2", "emojis-list": "3.0.0", "json5": "2.2.3" } }, "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A=="],
+
+ "raw-loader/schema-utils": ["[email protected]", "", { "dependencies": { "@types/json-schema": "7.0.15", "ajv": "6.12.6", "ajv-keywords": "3.5.2" } }, "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg=="],
+
"rc/ini": ["[email protected]", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],
"rc/strip-json-comments": ["[email protected]", "", {}, "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="],
diff --git a/packages/template-prompt-to-motion-graphics/next.config.js b/packages/template-prompt-to-motion-graphics/next.config.js
index 91ef62f0db..e771b3184d 100644
--- a/packages/template-prompt-to-motion-graphics/next.config.js
+++ b/packages/template-prompt-to-motion-graphics/next.config.js
@@ -1,6 +1,23 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
+ // Turbopack config for Next.js 16+
+ turbopack: {
+ rules: {
+ "*.md": {
+ loaders: ["raw-loader"],
+ as: "*.js",
+ },
+ },
+ },
+ // Webpack config for fallback
+ webpack: (config) => {
+ config.module.rules.push({
+ test: /\.md$/,
+ type: "asset/source",
+ });
+ return config;
+ },
};
module.exports = nextConfig;
diff --git a/packages/template-prompt-to-motion-graphics/package.json b/packages/template-prompt-to-motion-graphics/package.json
index 1438e7e737..4156fa7ff6 100644
--- a/packages/template-prompt-to-motion-graphics/package.json
+++ b/packages/template-prompt-to-motion-graphics/package.json
@@ -71,6 +71,7 @@
"eslint-config-next": "15.1.6",
"postcss": "8.4.47",
"prettier": "3.6.0",
+ "raw-loader": "^4.0.2",
"tailwindcss": "4.0.3",
"tw-animate-css": "1.4.0",
"typescript": "5.9.3",
diff --git a/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts b/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts
index d905d62cf3..1820a23936 100644
--- a/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts
+++ b/packages/template-prompt-to-motion-graphics/src/app/api/generate/route.ts
@@ -139,6 +139,8 @@ export async function POST(req: Request) {
schema: z.object({ valid: z.boolean() }),
});
+ console.log("Validation result:", validationResult.object.valid ? "valid" : "invalid");
+
if (!validationResult.object.valid) {
return new Response(
JSON.stringify({
diff --git a/packages/template-prompt-to-motion-graphics/src/examples/code/gold-price-chart.ts b/packages/template-prompt-to-motion-graphics/src/examples/code/gold-price-chart.ts
new file mode 100644
index 0000000000..5f114149b7
--- /dev/null
+++ b/packages/template-prompt-to-motion-graphics/src/examples/code/gold-price-chart.ts
@@ -0,0 +1,195 @@
+import { RemotionExample } from "./index";
+
+export const goldPriceChartCode = `import { useCurrentFrame, useVideoConfig, AbsoluteFill, spring } from "remotion";
+
+export const MyAnimation = () => {
+ /*
+ * Elegant animated bar chart showing gold prices with Y-axis, staggered spring animations, and full-width layout.
+ */
+ const frame = useCurrentFrame();
+ const { fps, height: videoHeight } = useVideoConfig();
+
+ const TITLE = "Gold Price 2024";
+ const UNIT = "USD per troy ounce";
+ const COLOR_BAR = "#D4AF37";
+ const COLOR_TEXT = "#ffffff";
+ const COLOR_MUTED = "#888888";
+ const COLOR_BG = "#0a0a0a";
+ const COLOR_AXIS = "#333333";
+
+ const PADDING = 50;
+ const HEADER_HEIGHT = 70;
+ const LABEL_HEIGHT = 32;
+ const BAR_GAP = 8;
+ const BAR_RADIUS = 4;
+ const TITLE_FONT_SIZE = 24;
+ const LABEL_FONT_SIZE = 11;
+ const VALUE_FONT_SIZE = 11;
+ const AXIS_FONT_SIZE = 12;
+ const STAGGER_DELAY = 5;
+ const HEADER_START_FRAME = 0;
+ const BARS_START_FRAME = 10;
+ const SPRING_DAMPING = 18;
+ const SPRING_STIFFNESS = 80;
+
+ const data = [
+ { month: "Jan", price: 2039 },
+ { month: "Feb", price: 2024 },
+ { month: "Mar", price: 2160 },
+ { month: "Apr", price: 2330 },
+ { month: "May", price: 2327 },
+ { month: "Jun", price: 2339 },
+ { month: "Jul", price: 2426 },
+ { month: "Aug", price: 2503 },
+ { month: "Sep", price: 2634 },
+ { month: "Oct", price: 2735 },
+ { month: "Nov", price: 2672 },
+ { month: "Dec", price: 2650 },
+ ];
+
+ const minPrice = 1900;
+ const maxPrice = 2800;
+ const priceRange = maxPrice - minPrice;
+ const chartHeight = videoHeight - (PADDING * 2) - HEADER_HEIGHT - LABEL_HEIGHT;
+ const yAxisSteps = [1900, 2100, 2300, 2500, 2700];
+
+ const headerOpacity = spring({
+ frame: frame - HEADER_START_FRAME,
+ fps,
+ config: { damping: 20, stiffness: 100 },
+ });
+
+ return (
+ <AbsoluteFill
+ style={{
+ backgroundColor: COLOR_BG,
+ padding: PADDING,
+ display: "flex",
+ flexDirection: "column",
+ fontFamily: "Inter, sans-serif",
+ }}
+ >
+ {/* Header */}
+ <div style={{ height: HEADER_HEIGHT, opacity: headerOpacity, marginBottom: 10 }}>
+ <div style={{ color: COLOR_TEXT, fontSize: TITLE_FONT_SIZE, fontWeight: 600 }}>{TITLE}</div>
+ <div style={{ color: COLOR_MUTED, fontSize: 14, marginTop: 4 }}>{UNIT}</div>
+ </div>
+
+ {/* Chart container */}
+ <div style={{ display: "flex", alignItems: "flex-end", width: "100%", flex: 1 }}>
+ {/* Y-Axis */}
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "column",
+ justifyContent: "space-between",
+ height: chartHeight,
+ paddingRight: 12,
+ marginBottom: LABEL_HEIGHT,
+ }}
+ >
+ {yAxisSteps.slice().reverse().map((step) => (
+ <div
+ key={step}
+ style={{
+ color: COLOR_MUTED,
+ fontSize: AXIS_FONT_SIZE,
+ textAlign: "right",
+ minWidth: 40,
+ }}
+ >
+ {step.toLocaleString()}
+ </div>
+ ))}
+ </div>
+
+ {/* Chart area */}
+ <div
+ style={{
+ display: "flex",
+ alignItems: "flex-end",
+ gap: BAR_GAP,
+ height: chartHeight,
+ flex: 1,
+ borderLeft: \`1px solid \${COLOR_AXIS}\`,
+ borderBottom: \`1px solid \${COLOR_AXIS}\`,
+ paddingLeft: 8,
+ }}
+ >
+ {data.map((item, i) => {
+ const delay = i * STAGGER_DELAY;
+ const progress = spring({
+ frame: frame - delay - BARS_START_FRAME,
+ fps,
+ config: { damping: SPRING_DAMPING, stiffness: SPRING_STIFFNESS },
+ });
+
+ const normalizedHeight = ((item.price - minPrice) / priceRange) * chartHeight;
+ const height = normalizedHeight * progress;
+
+ return (
+ <div
+ key={i}
+ style={{
+ textAlign: "center",
+ flex: 1,
+ height: "100%",
+ display: "flex",
+ flexDirection: "column",
+ justifyContent: "flex-end",
+ }}
+ >
+ <div
+ style={{
+ width: "100%",
+ height,
+ backgroundColor: COLOR_BAR,
+ borderRadius: \`\${BAR_RADIUS}px \${BAR_RADIUS}px 0 0\`,
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "flex-start",
+ paddingTop: 6,
+ minHeight: height > 0 ? 4 : 0,
+ }}
+ >
+ {height > 30 && (
+ <span
+ style={{
+ color: COLOR_BG,
+ fontSize: VALUE_FONT_SIZE,
+ fontWeight: 600,
+ opacity: progress,
+ }}
+ >
+ {item.price.toLocaleString()}
+ </span>
+ )}
+ </div>
+ <div
+ style={{
+ color: COLOR_MUTED,
+ fontSize: LABEL_FONT_SIZE,
+ marginTop: 8,
+ height: LABEL_HEIGHT - 8,
+ }}
+ >
+ {item.month}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};`;
+
+export const goldPriceChartExample: RemotionExample = {
+ id: "gold-price-chart",
+ name: "Gold Price Chart",
+ description: "Animated bar chart with Y-axis labels and staggered spring animations",
+ category: "Charts",
+ durationInFrames: 150,
+ fps: 30,
+ code: goldPriceChartCode,
+};
diff --git a/packages/template-prompt-to-motion-graphics/src/examples/code/index.ts b/packages/template-prompt-to-motion-graphics/src/examples/code/index.ts
index b6b8d7941a..8adc92bea5 100644
--- a/packages/template-prompt-to-motion-graphics/src/examples/code/index.ts
+++ b/packages/template-prompt-to-motion-graphics/src/examples/code/index.ts
@@ -7,6 +7,10 @@ import { animatedShapesExample } from "./animated-shapes";
import { morphingHexagonsExample } from "./morphing-hexagons";
import { lottieAnimationExample } from "./lottie-animation";
import { fallingSpheresExample } from "./falling-spheres";
+import { goldPriceChartExample } from "./gold-price-chart";
+import { typewriterHighlightExample } from "./typewriter-highlight";
+import { wordCarouselExample } from "./word-carousel";
+import { staggeredListExample } from "./staggered-list";
export interface RemotionExample {
id: string;
@@ -28,6 +32,10 @@ export const examples: RemotionExample[] = [
morphingHexagonsExample,
lottieAnimationExample,
fallingSpheresExample,
+ goldPriceChartExample,
+ typewriterHighlightExample,
+ wordCarouselExample,
+ staggeredListExample,
];
export function getExampleById(id: string): RemotionExample | undefined {
diff --git a/packages/template-prompt-to-motion-graphics/src/examples/code/staggered-list.ts b/packages/template-prompt-to-motion-graphics/src/examples/code/staggered-list.ts
new file mode 100644
index 0000000000..300c5e1b33
--- /dev/null
+++ b/packages/template-prompt-to-motion-graphics/src/examples/code/staggered-list.ts
@@ -0,0 +1,123 @@
+import { RemotionExample } from "./index";
+
+export const staggeredListCode = `import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";
+
+export const MyAnimation = () => {
+ /*
+ * Feature list with staggered spring entrances and subtle hover-like highlights.
+ */
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+
+ const COLOR_BG = "#0f0f0f";
+ const COLOR_TEXT = "#ffffff";
+ const COLOR_ACCENT = "#6366f1";
+ const COLOR_MUTED = "#a1a1aa";
+
+ const TITLE = "Why Choose Us";
+ const FEATURES = [
+ { icon: "\u26A1", title: "Lightning Fast", desc: "Built for speed from the ground up" },
+ { icon: "\uD83D\uDD12", title: "Secure by Default", desc: "Enterprise-grade security included" },
+ { icon: "\uD83C\uDFA8", title: "Beautiful Design", desc: "Crafted with attention to detail" },
+ { icon: "\uD83D\uDE80", title: "Scale Infinitely", desc: "Grows with your business needs" },
+ ];
+
+ const TITLE_FONT_SIZE = 48;
+ const ITEM_FONT_SIZE = 28;
+ const DESC_FONT_SIZE = 18;
+ const ICON_SIZE = 48;
+ const ITEM_GAP = 24;
+ const PADDING = 60;
+
+ const TITLE_START = 0;
+ const ITEMS_START = 20;
+ const STAGGER_DELAY = 12;
+ const SLIDE_DISTANCE = 30;
+
+ const titleProgress = spring({
+ frame: frame - TITLE_START,
+ fps,
+ config: { damping: 20, stiffness: 100 }
+ });
+
+ return (
+ <AbsoluteFill style={{
+ backgroundColor: COLOR_BG,
+ padding: PADDING,
+ display: "flex",
+ flexDirection: "column",
+ justifyContent: "center",
+ fontFamily: "Inter, sans-serif"
+ }}>
+ {/* Title */}
+ <div style={{
+ fontSize: TITLE_FONT_SIZE,
+ fontWeight: 700,
+ color: COLOR_TEXT,
+ marginBottom: 40,
+ opacity: titleProgress,
+ transform: \`translateY(\${(1 - titleProgress) * 20}px)\`
+ }}>
+ {TITLE}
+ </div>
+
+ {/* Feature list */}
+ <div style={{ display: "flex", flexDirection: "column", gap: ITEM_GAP }}>
+ {FEATURES.map((feature, i) => {
+ const itemStart = ITEMS_START + i * STAGGER_DELAY;
+ const itemProgress = spring({
+ frame: frame - itemStart,
+ fps,
+ config: { damping: 15, stiffness: 120 }
+ });
+ const opacity = interpolate(itemProgress, [0, 1], [0, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });
+ const translateX = interpolate(itemProgress, [0, 1], [SLIDE_DISTANCE, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });
+
+ return (
+ <div
+ key={i}
+ style={{
+ display: "flex",
+ alignItems: "center",
+ gap: 20,
+ opacity,
+ transform: \`translateX(\${translateX}px)\`
+ }}
+ >
+ <div style={{
+ width: ICON_SIZE,
+ height: ICON_SIZE,
+ borderRadius: 12,
+ backgroundColor: COLOR_ACCENT + "20",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ fontSize: 24
+ }}>
+ {feature.icon}
+ </div>
+ <div>
+ <div style={{ fontSize: ITEM_FONT_SIZE, fontWeight: 600, color: COLOR_TEXT }}>
+ {feature.title}
+ </div>
+ <div style={{ fontSize: DESC_FONT_SIZE, color: COLOR_MUTED, marginTop: 4 }}>
+ {feature.desc}
+ </div>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </AbsoluteFill>
+ );
+};`;
+
+export const staggeredListExample: RemotionExample = {
+ id: "staggered-list",
+ name: "Staggered Feature List",
+ description: "Feature list with staggered spring entrances and slide animations",
+ category: "Other",
+ durationInFrames: 120,
+ fps: 30,
+ code: staggeredListCode,
+};
diff --git a/packages/template-prompt-to-motion-graphics/src/examples/code/typewriter-highlight.ts b/packages/template-prompt-to-motion-graphics/src/examples/code/typewriter-highlight.ts
new file mode 100644
index 0000000000..61bb092992
--- /dev/null
+++ b/packages/template-prompt-to-motion-graphics/src/examples/code/typewriter-highlight.ts
@@ -0,0 +1,191 @@
+import { RemotionExample } from "./index";
+
+export const typewriterHighlightCode = `import {
+ useCurrentFrame,
+ useVideoConfig,
+ AbsoluteFill,
+ interpolate,
+ spring,
+} from "remotion";
+
+export const MyAnimation = () => {
+ /*
+ * Typewriter with blinking cursor, dramatic pause, spring-based highlight, and layer crossfade.
+ */
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+
+ const COLOR_BG = "#ffffff";
+ const COLOR_TEXT = "#000000";
+ const COLOR_HIGHLIGHT = "#A7C7E7";
+
+ const FULL_TEXT = "From prompt to motion graphics. This is Remotion.";
+ const HIGHLIGHT_WORD = "Remotion";
+ const CARET_SYMBOL = "\u258C";
+ const SPLIT_AFTER = " This is Remotion.";
+
+ const FONT_SIZE = 72;
+ const FONT_WEIGHT = 700;
+ const CHAR_FRAMES = 2;
+ const CURSOR_BLINK_FRAMES = 16;
+ const HIGHLIGHT_DELAY = 6;
+ const HIGHLIGHT_WIPE_DURATION = 18;
+ const CROSSFADE_DURATION = 8;
+ const WAIT_AFTER_PRE_SECONDS = 1;
+
+ const WAIT_AFTER_PRE_FRAMES = Math.round(fps * WAIT_AFTER_PRE_SECONDS);
+ const f = frame;
+
+ const splitIndex = FULL_TEXT.indexOf(SPLIT_AFTER);
+ const preLen = splitIndex >= 0 ? splitIndex : FULL_TEXT.length;
+ const postLen = FULL_TEXT.length - preLen;
+
+ let typedChars = 0;
+ if (f < preLen * CHAR_FRAMES) {
+ typedChars = Math.floor(f / CHAR_FRAMES);
+ } else if (f < preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES) {
+ typedChars = preLen;
+ } else {
+ const postPhase = f - preLen * CHAR_FRAMES - WAIT_AFTER_PRE_FRAMES;
+ typedChars = Math.min(
+ FULL_TEXT.length,
+ preLen + Math.floor(postPhase / CHAR_FRAMES),
+ );
+ }
+ const typedText = FULL_TEXT.slice(0, typedChars);
+ const typingDone = typedChars >= FULL_TEXT.length;
+
+ const caretOpacity = !typingDone
+ ? interpolate(
+ f % CURSOR_BLINK_FRAMES,
+ [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES],
+ [1, 0, 1],
+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
+ )
+ : 0;
+
+ const highlightIndex = FULL_TEXT.indexOf(HIGHLIGHT_WORD);
+ const hasHighlight = highlightIndex >= 0;
+ const preText = hasHighlight ? FULL_TEXT.slice(0, highlightIndex) : FULL_TEXT;
+ const postText = hasHighlight
+ ? FULL_TEXT.slice(highlightIndex + HIGHLIGHT_WORD.length)
+ : "";
+
+ const typeEnd =
+ preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES + postLen * CHAR_FRAMES;
+ const highlightStart = typeEnd + HIGHLIGHT_DELAY;
+
+ const typedOpacity = interpolate(
+ f,
+ [highlightStart - CROSSFADE_DURATION, highlightStart + CROSSFADE_DURATION],
+ [1, 0],
+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
+ );
+ const finalOpacity = interpolate(
+ f,
+ [highlightStart, highlightStart + CROSSFADE_DURATION],
+ [0, 1],
+ { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
+ );
+
+ const entrance = spring({
+ fps,
+ frame: f,
+ config: { damping: 200, stiffness: 120 },
+ durationInFrames: 20,
+ });
+ const containerScale = interpolate(entrance, [0, 1], [0.98, 1], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+
+ const highlightProgress = spring({
+ fps,
+ frame: f - highlightStart,
+ config: { damping: 200, stiffness: 180 },
+ durationInFrames: HIGHLIGHT_WIPE_DURATION,
+ });
+ const highlightScaleX = Math.max(0, Math.min(1, highlightProgress));
+
+ return (
+ <AbsoluteFill
+ style={{
+ backgroundColor: COLOR_BG,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ fontFamily: "Inter, sans-serif",
+ }}
+ >
+ <div
+ style={{ position: "relative", transform: \`scale(\${containerScale})\` }}
+ >
+ {/* Typing layer */}
+ <div
+ style={{
+ color: COLOR_TEXT,
+ fontSize: FONT_SIZE,
+ fontWeight: FONT_WEIGHT,
+ lineHeight: 1.15,
+ whiteSpace: "pre-wrap",
+ opacity: typedOpacity,
+ }}
+ >
+ <span>{typedText}</span>
+ <span style={{ opacity: caretOpacity }}>{CARET_SYMBOL}</span>
+ </div>
+ {/* Final layer with highlight */}
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ color: COLOR_TEXT,
+ fontSize: FONT_SIZE,
+ fontWeight: FONT_WEIGHT,
+ lineHeight: 1.15,
+ whiteSpace: "pre-wrap",
+ opacity: finalOpacity,
+ }}
+ >
+ {hasHighlight ? (
+ <>
+ <span>{preText}</span>
+ <span style={{ position: "relative", display: "inline-block" }}>
+ <span
+ style={{
+ position: "absolute",
+ left: 0,
+ right: 0,
+ top: "50%",
+ height: "1.05em",
+ transform: \`translateY(-50%) scaleX(\${highlightScaleX})\`,
+ transformOrigin: "left center",
+ backgroundColor: COLOR_HIGHLIGHT,
+ borderRadius: "0.18em",
+ zIndex: 0,
+ }}
+ />
+ <span style={{ position: "relative", zIndex: 1 }}>
+ {HIGHLIGHT_WORD}
+ </span>
+ </span>
+ <span>{postText}</span>
+ </>
+ ) : (
+ <span>{FULL_TEXT}</span>
+ )}
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};`;
+
+export const typewriterHighlightExample: RemotionExample = {
+ id: "typewriter-highlight",
+ name: "Typewriter with Highlight",
+ description: "Typewriter effect with blinking cursor, pause, and spring-animated word highlight",
+ category: "Text",
+ durationInFrames: 180,
+ fps: 30,
+ code: typewriterHighlightCode,
+};
diff --git a/packages/template-prompt-to-motion-graphics/src/examples/code/word-carousel.ts b/packages/template-prompt-to-motion-graphics/src/examples/code/word-carousel.ts
new file mode 100644
index 0000000000..831dfd6e69
--- /dev/null
+++ b/packages/template-prompt-to-motion-graphics/src/examples/code/word-carousel.ts
@@ -0,0 +1,130 @@
+import { RemotionExample } from "./index";
+
+export const wordCarouselCode = `import { useCurrentFrame, AbsoluteFill, interpolate } from "remotion";
+
+export const MyAnimation = () => {
+ /*
+ * Prefix text with rotating words that crossfade with blur.
+ */
+ const frame = useCurrentFrame();
+
+ const COLOR_TEXT = "#7b92c1";
+ const PREFIX = "Created for";
+ const WORDS = ["Creators", "Marketers", "Developers", "Everyone"];
+
+ const PREFIX_FONT_SIZE = 80;
+ const WORD_FONT_SIZE = 80;
+ const PREFIX_WEIGHT = 300;
+ const WORD_WEIGHT = 700;
+ const WORD_GAP = 20;
+ const HOLD_DURATION = 32;
+ const FLIP_DURATION = 18;
+ const BLUR_AMOUNT = 6;
+
+ const perStep = HOLD_DURATION + FLIP_DURATION;
+ const totalSteps = WORDS.length;
+ const currentStep = Math.floor(frame / perStep) % totalSteps;
+ const nextStep = (currentStep + 1) % totalSteps;
+ const phase = frame % perStep;
+ const isFlipping = phase >= HOLD_DURATION;
+ const flipProgress = isFlipping ? (phase - HOLD_DURATION) / FLIP_DURATION : 0;
+
+ const outOpacity = interpolate(flipProgress, [0, 1], [1, 0], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+ const inOpacity = interpolate(flipProgress, [0, 1], [0, 1], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+ const outBlur = interpolate(flipProgress, [0, 1], [0, BLUR_AMOUNT], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+ const inBlur = interpolate(flipProgress, [0, 1], [BLUR_AMOUNT, 0], {
+ extrapolateLeft: "clamp",
+ extrapolateRight: "clamp",
+ });
+
+ const longestWord = WORDS.reduce(
+ (a, b) => (a.length >= b.length ? a : b),
+ WORDS[0],
+ );
+
+ return (
+ <AbsoluteFill
+ style={{
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ fontFamily: "Inter, sans-serif",
+ }}
+ >
+ <div
+ style={{
+ display: "flex",
+ alignItems: "baseline",
+ gap: WORD_GAP,
+ color: COLOR_TEXT,
+ }}
+ >
+ <div style={{ fontSize: PREFIX_FONT_SIZE, fontWeight: PREFIX_WEIGHT }}>
+ {PREFIX}
+ </div>
+ <div
+ style={{
+ position: "relative",
+ fontSize: WORD_FONT_SIZE,
+ fontWeight: WORD_WEIGHT,
+ }}
+ >
+ {/* Invisible width keeper */}
+ <div style={{ visibility: "hidden" }}>{longestWord}</div>
+ {/* Current word (fades out during flip) */}
+ {!isFlipping && (
+ <div style={{ position: "absolute", left: 0, top: 0 }}>
+ {WORDS[currentStep]}
+ </div>
+ )}
+ {/* Crossfade during flip */}
+ {isFlipping && (
+ <>
+ <div
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ opacity: outOpacity,
+ filter: \`blur(\${outBlur}px)\`,
+ }}
+ >
+ {WORDS[currentStep]}
+ </div>
+ <div
+ style={{
+ position: "absolute",
+ left: 0,
+ top: 0,
+ opacity: inOpacity,
+ filter: \`blur(\${inBlur}px)\`,
+ }}
+ >
+ {WORDS[nextStep]}
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};`;
+
+export const wordCarouselExample: RemotionExample = {
+ id: "word-carousel",
+ name: "Word Carousel",
+ description: "Rotating words with crossfade and blur transitions",
+ category: "Text",
+ durationInFrames: 200,
+ fps: 30,
+ code: wordCarouselCode,
+};
diff --git a/packages/template-prompt-to-motion-graphics/src/markdown.d.ts b/packages/template-prompt-to-motion-graphics/src/markdown.d.ts
new file mode 100644
index 0000000000..c94d67b1a2
--- /dev/null
+++ b/packages/template-prompt-to-motion-graphics/src/markdown.d.ts
@@ -0,0 +1,4 @@
+declare module "*.md" {
+ const content: string;
+ export default content;
+}
diff --git a/packages/template-prompt-to-motion-graphics/src/skills/charts.md b/packages/template-prompt-to-motion-graphics/src/skills/charts.md
index b8dd039ed6..8d8d15388c 100644
--- a/packages/template-prompt-to-motion-graphics/src/skills/charts.md
+++ b/packages/template-prompt-to-motion-graphics/src/skills/charts.md
@@ -101,194 +101,3 @@ const offset = interpolate(progress, [0, 1], [segmentLength, 0]);
/>
```
----
-
-## COMPLETE EXAMPLE: Animated Bar Chart
-
-Prompt: "An animated histogram with the gold price. Focus on simplicity and elegance."
-
-```tsx
-import { useCurrentFrame, useVideoConfig, AbsoluteFill, spring } from "remotion";
-
-export const MyAnimation = () => {
- /*
- * Elegant animated bar chart showing gold prices with Y-axis, staggered spring animations, and full-width layout.
- */
- const frame = useCurrentFrame();
- const { fps, height: videoHeight } = useVideoConfig();
-
- const TITLE = "Gold Price 2024";
- const UNIT = "USD per troy ounce";
- const COLOR_BAR = "#D4AF37";
- const COLOR_TEXT = "#ffffff";
- const COLOR_MUTED = "#888888";
- const COLOR_BG = "#0a0a0a";
- const COLOR_AXIS = "#333333";
-
- const PADDING = 50;
- const HEADER_HEIGHT = 70;
- const LABEL_HEIGHT = 32;
- const BAR_GAP = 8;
- const BAR_RADIUS = 4;
- const TITLE_FONT_SIZE = 24;
- const LABEL_FONT_SIZE = 11;
- const VALUE_FONT_SIZE = 11;
- const AXIS_FONT_SIZE = 12;
- const STAGGER_DELAY = 5;
- const HEADER_START_FRAME = 0;
- const BARS_START_FRAME = 10;
- const SPRING_DAMPING = 18;
- const SPRING_STIFFNESS = 80;
-
- const data = [
- { month: "Jan", price: 2039 },
- { month: "Feb", price: 2024 },
- { month: "Mar", price: 2160 },
- { month: "Apr", price: 2330 },
- { month: "May", price: 2327 },
- { month: "Jun", price: 2339 },
- { month: "Jul", price: 2426 },
- { month: "Aug", price: 2503 },
- { month: "Sep", price: 2634 },
- { month: "Oct", price: 2735 },
- { month: "Nov", price: 2672 },
- { month: "Dec", price: 2650 },
- ];
-
- const minPrice = 1900;
- const maxPrice = 2800;
- const priceRange = maxPrice - minPrice;
- const chartHeight = videoHeight - (PADDING * 2) - HEADER_HEIGHT - LABEL_HEIGHT;
- const yAxisSteps = [1900, 2100, 2300, 2500, 2700];
-
- const headerOpacity = spring({
- frame: frame - HEADER_START_FRAME,
- fps,
- config: { damping: 20, stiffness: 100 },
- });
-
- return (
- <AbsoluteFill
- style={{
- backgroundColor: COLOR_BG,
- padding: PADDING,
- display: "flex",
- flexDirection: "column",
- fontFamily: "Inter, sans-serif",
- }}
- >
- {/* Header */}
- <div style={{ height: HEADER_HEIGHT, opacity: headerOpacity, marginBottom: 10 }}>
- <div style={{ color: COLOR_TEXT, fontSize: TITLE_FONT_SIZE, fontWeight: 600 }}>{TITLE}</div>
- <div style={{ color: COLOR_MUTED, fontSize: 14, marginTop: 4 }}>{UNIT}</div>
- </div>
-
- {/* Chart container */}
- <div style={{ display: "flex", alignItems: "flex-end", width: "100%", flex: 1 }}>
- {/* Y-Axis */}
- <div
- style={{
- display: "flex",
- flexDirection: "column",
- justifyContent: "space-between",
- height: chartHeight,
- paddingRight: 12,
- marginBottom: LABEL_HEIGHT,
- }}
- >
- {yAxisSteps.slice().reverse().map((step) => (
- <div
- key={step}
- style={{
- color: COLOR_MUTED,
- fontSize: AXIS_FONT_SIZE,
- textAlign: "right",
- minWidth: 40,
- }}
- >
- {step.toLocaleString()}
- </div>
- ))}
- </div>
-
- {/* Chart area */}
- <div
- style={{
- display: "flex",
- alignItems: "flex-end",
- gap: BAR_GAP,
- height: chartHeight,
- flex: 1,
- borderLeft: `1px solid ${COLOR_AXIS}`,
- borderBottom: `1px solid ${COLOR_AXIS}`,
- paddingLeft: 8,
- }}
- >
- {data.map((item, i) => {
- const delay = i * STAGGER_DELAY;
- const progress = spring({
- frame: frame - delay - BARS_START_FRAME,
- fps,
- config: { damping: SPRING_DAMPING, stiffness: SPRING_STIFFNESS },
- });
-
- const normalizedHeight = ((item.price - minPrice) / priceRange) * chartHeight;
- const height = normalizedHeight * progress;
-
- return (
- <div
- key={i}
- style={{
- textAlign: "center",
- flex: 1,
- height: "100%",
- display: "flex",
- flexDirection: "column",
- justifyContent: "flex-end",
- }}
- >
- <div
- style={{
- width: "100%",
- height,
- backgroundColor: COLOR_BAR,
- borderRadius: `${BAR_RADIUS}px ${BAR_RADIUS}px 0 0`,
- display: "flex",
- justifyContent: "center",
- alignItems: "flex-start",
- paddingTop: 6,
- minHeight: height > 0 ? 4 : 0,
- }}
- >
- {height > 30 && (
- <span
- style={{
- color: COLOR_BG,
- fontSize: VALUE_FONT_SIZE,
- fontWeight: 600,
- opacity: progress,
- }}
- >
- {item.price.toLocaleString()}
- </span>
- )}
- </div>
- <div
- style={{
- color: COLOR_MUTED,
- fontSize: LABEL_FONT_SIZE,
- marginTop: 8,
- height: LABEL_HEIGHT - 8,
- }}
- >
- {item.month}
- </div>
- </div>
- );
- })}
- </div>
- </div>
- </AbsoluteFill>
- );
-};
-```
diff --git a/packages/template-prompt-to-motion-graphics/src/skills/index.ts b/packages/template-prompt-to-motion-graphics/src/skills/index.ts
index 3a5921ba5d..a44cd4a558 100644
--- a/packages/template-prompt-to-motion-graphics/src/skills/index.ts
+++ b/packages/template-prompt-to-motion-graphics/src/skills/index.ts
@@ -1,7 +1,17 @@
-import fs from "fs";
-import path from "path";
+import { examples } from "@/examples/code";
-export const SKILL_NAMES = [
+// Import markdown files at build time
+import chartsSkill from "./charts.md";
+import typographySkill from "./typography.md";
+import socialMediaSkill from "./social-media.md";
+import messagingSkill from "./messaging.md";
+import threeDSkill from "./3d.md";
+import transitionsSkill from "./transitions.md";
+import sequencingSkill from "./sequencing.md";
+import springPhysicsSkill from "./spring-physics.md";
+
+// Guidance skills (markdown files with patterns/rules)
+const GUIDANCE_SKILLS = [
"charts",
"typography",
"social-media",
@@ -12,17 +22,69 @@ export const SKILL_NAMES = [
"spring-physics",
] as const;
+// Example skills (complete working code references)
+const EXAMPLE_SKILLS = [
+ "example-histogram",
+ "example-progress-bar",
+ "example-counter",
+ "example-text-rotation",
+ "example-chat-messages",
+ "example-falling-spheres",
+ "example-animated-shapes",
+ "example-morphing-hexagons",
+ "example-lottie",
+ "example-gold-price-chart",
+ "example-typewriter-highlight",
+ "example-word-carousel",
+ "example-staggered-list",
+] as const;
+
+export const SKILL_NAMES = [...GUIDANCE_SKILLS, ...EXAMPLE_SKILLS] as const;
+
export type SkillName = (typeof SKILL_NAMES)[number];
-const skillsDir = path.join(process.cwd(), "src/skills");
+// Map guidance skill names to imported content
+const guidanceSkillContent: Record<(typeof GUIDANCE_SKILLS)[number], string> = {
+ charts: chartsSkill,
+ typography: typographySkill,
+ "social-media": socialMediaSkill,
+ messaging: messagingSkill,
+ "3d": threeDSkill,
+ transitions: transitionsSkill,
+ sequencing: sequencingSkill,
+ "spring-physics": springPhysicsSkill,
+};
+
+// Map example skill names to example IDs
+const exampleIdMap: Record<(typeof EXAMPLE_SKILLS)[number], string> = {
+ "example-histogram": "histogram",
+ "example-progress-bar": "progress-bar",
+ "example-counter": "counter-animation",
+ "example-text-rotation": "text-rotation",
+ "example-chat-messages": "chat-messages",
+ "example-falling-spheres": "falling-spheres",
+ "example-animated-shapes": "animated-shapes",
+ "example-morphing-hexagons": "morphing-hexagons",
+ "example-lottie": "lottie-animation",
+ "example-gold-price-chart": "gold-price-chart",
+ "example-typewriter-highlight": "typewriter-highlight",
+ "example-word-carousel": "word-carousel",
+ "example-staggered-list": "staggered-list",
+};
export function getSkillContent(skillName: SkillName): string {
- const filePath = path.join(skillsDir, `${skillName}.md`);
- try {
- return fs.readFileSync(filePath, "utf-8");
- } catch {
+ // Handle example skills - return the code directly
+ if (skillName.startsWith("example-")) {
+ const exampleId = exampleIdMap[skillName as (typeof EXAMPLE_SKILLS)[number]];
+ const example = examples.find((e) => e.id === exampleId);
+ if (example) {
+ return `## Example: ${example.name}\n${example.description}\n\n\`\`\`tsx\n${example.code}\n\`\`\``;
+ }
return "";
}
+
+ // Handle guidance skills - return imported markdown content
+ return guidanceSkillContent[skillName as (typeof GUIDANCE_SKILLS)[number]] || "";
}
export function getCombinedSkillContent(skills: SkillName[]): string {
@@ -40,7 +102,7 @@ export function getCombinedSkillContent(skills: SkillName[]): string {
export const SKILL_DETECTION_PROMPT = `Classify this motion graphics prompt into ALL applicable categories.
A prompt can match multiple categories. Only include categories that are clearly relevant.
-Categories:
+Guidance categories (patterns and rules):
- charts: data visualizations, graphs, histograms, bar charts, pie charts, progress bars, statistics, metrics
- typography: kinetic text, typewriter effects, text animations, word carousels, animated titles, text-heavy content
- social-media: Instagram stories, TikTok content, YouTube shorts, social media posts, reels, vertical video
@@ -50,4 +112,19 @@ Categories:
- sequencing: multiple elements appearing at different times, staggered animations, choreographed entrances
- spring-physics: bouncy animations, organic motion, elastic effects, overshoot animations
+Code examples (complete working references):
+- example-histogram: animated bar chart with spring animations and @remotion/shapes
+- example-progress-bar: loading bar animation from 0 to 100%
+- example-counter: animated number counters with multiple metrics
+- example-text-rotation: rotating words with fade/blur transitions
+- example-chat-messages: WhatsApp-style chat bubbles with staggered entrance
+- example-falling-spheres: 3D bouncing spheres with ThreeJS and physics simulation
+- example-animated-shapes: bouncing/rotating SVG shapes (circle, triangle, rect, star)
+- example-morphing-hexagons: pulsing hexagon grid with color-shifting effects
+- example-lottie: loading and displaying Lottie animations from URL
+- example-gold-price-chart: bar chart with Y-axis labels, monthly data, staggered animations
+- example-typewriter-highlight: typewriter effect with cursor blink, pause, and word highlight
+- example-word-carousel: rotating words with crossfade and blur transitions
+- example-staggered-list: feature list with staggered spring entrances
+
Return an array of matching category names. Return an empty array if none apply.`;
diff --git a/packages/template-prompt-to-motion-graphics/src/skills/messaging.md b/packages/template-prompt-to-motion-graphics/src/skills/messaging.md
index ef6f027624..c1831d763d 100644
--- a/packages/template-prompt-to-motion-graphics/src/skills/messaging.md
+++ b/packages/template-prompt-to-motion-graphics/src/skills/messaging.md
@@ -112,91 +112,3 @@ const COLOR_TEXT_SENT = "#ffffff";
const COLOR_TEXT_RECEIVED = "#000000";
```
----
-
-## COMPLETE EXAMPLE: WhatsApp-Style Chat
-
-Prompt: "WhatsApp-style chat with messages appearing one by one"
-
-```tsx
-import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";
-
-export const MyAnimation = () => {
- /*
- * Chat conversation with bubbles sliding in with spring animation.
- */
- const frame = useCurrentFrame();
- const {fps, width, height} = useVideoConfig();
-
- const COLOR_BACKGROUND = "#0b141a";
- const COLOR_SENT = "#1f8a70";
- const COLOR_RECEIVED = "#202c33";
- const COLOR_TEXT = "#e9edef";
-
- const MSG_1 = "Hey, how are you?";
- const MSG_2 = "Great, thanks!";
- const MSG_3 = "Want to grab coffee?";
-
- const FONT_SIZE = 44;
- const FADE_DURATION = 18;
- const STAGGER_DELAY = 38;
- const SLIDE_DISTANCE = 40;
- const BOUNCE_DAMPING = 12;
- const BOUNCE_STIFFNESS = 170;
- const BUBBLE_RADIUS = 18;
- const BUBBLE_PADDING_X = 24;
- const BUBBLE_PADDING_Y = 18;
- const ROW_GAP = 22;
- const MAX_WIDTH_PERCENT = 72;
-
- const MSG1_START = 0;
- const MSG2_START = MSG1_START + FADE_DURATION + STAGGER_DELAY;
- const MSG3_START = MSG2_START + FADE_DURATION + STAGGER_DELAY;
-
- const MessageRow = ({text, align, start}: {text: string, align: string, start: number}) => {
- const local = frame - start;
- const opacity = interpolate(local, [0, FADE_DURATION], [0, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});
- const bounce = spring({frame: Math.max(0, local), fps, config: {damping: BOUNCE_DAMPING, stiffness: BOUNCE_STIFFNESS}});
- const scaleValue = interpolate(bounce, [0, 1], [0.98, 1], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});
- const xFrom = align === "right" ? SLIDE_DISTANCE : -SLIDE_DISTANCE;
- const tx = interpolate(opacity, [0, 1], [xFrom, 0], {extrapolateLeft: "clamp", extrapolateRight: "clamp"});
- const bubbleBg = align === "right" ? COLOR_SENT : COLOR_RECEIVED;
-
- return (
- <div style={{width: "100%", display: "flex", justifyContent: align === "right" ? "flex-end" : "flex-start", marginTop: ROW_GAP}}>
- <div style={{
- maxWidth: `${MAX_WIDTH_PERCENT}%`,
- backgroundColor: bubbleBg,
- color: COLOR_TEXT,
- padding: `${BUBBLE_PADDING_Y}px ${BUBBLE_PADDING_X}px`,
- borderRadius: BUBBLE_RADIUS,
- fontSize: FONT_SIZE,
- fontFamily: "Inter, sans-serif",
- opacity,
- transform: `translateX(${tx}px) scale(${scaleValue})`,
- transformOrigin: align === "right" ? "100% 100%" : "0% 100%"
- }}>
- {text}
- </div>
- </div>
- );
- };
-
- return (
- <AbsoluteFill style={{
- backgroundColor: COLOR_BACKGROUND,
- display: "flex",
- flexDirection: "column",
- justifyContent: "flex-end",
- padding: Math.max(36, Math.round(width * 0.04)),
- fontFamily: "Inter, sans-serif"
- }}>
- <div style={{flex: 1}} />
- <MessageRow text={MSG_1} align="left" start={MSG1_START} />
- <MessageRow text={MSG_2} align="right" start={MSG2_START} />
- <MessageRow text={MSG_3} align="left" start={MSG3_START} />
- <div style={{height: Math.max(20, Math.round(height * 0.02))}} />
- </AbsoluteFill>
- );
-};
-```
diff --git a/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md b/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md
index 61ed94ddd9..4b047980d6 100644
--- a/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md
+++ b/packages/template-prompt-to-motion-graphics/src/skills/sequencing.md
@@ -122,122 +122,3 @@ Inside a Sequence, useCurrentFrame() returns the local frame (starting from 0):
</Sequence>
```
----
-
-## COMPLETE EXAMPLE: Staggered List Animation
-
-Prompt: "A list of features that animate in one by one with a slide and fade effect"
-
-```tsx
-import { useCurrentFrame, useVideoConfig, AbsoluteFill, interpolate, spring } from "remotion";
-
-export const MyAnimation = () => {
- /*
- * Feature list with staggered spring entrances and subtle hover-like highlights.
- */
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
-
- const COLOR_BG = "#0f0f0f";
- const COLOR_TEXT = "#ffffff";
- const COLOR_ACCENT = "#6366f1";
- const COLOR_MUTED = "#a1a1aa";
-
- const TITLE = "Why Choose Us";
- const FEATURES = [
- { icon: "⚑", title: "Lightning Fast", desc: "Built for speed from the ground up" },
- { icon: "πŸ”’", title: "Secure by Default", desc: "Enterprise-grade security included" },
- { icon: "🎨", title: "Beautiful Design", desc: "Crafted with attention to detail" },
- { icon: "πŸš€", title: "Scale Infinitely", desc: "Grows with your business needs" },
- ];
-
- const TITLE_FONT_SIZE = 48;
- const ITEM_FONT_SIZE = 28;
- const DESC_FONT_SIZE = 18;
- const ICON_SIZE = 48;
- const ITEM_GAP = 24;
- const PADDING = 60;
-
- const TITLE_START = 0;
- const ITEMS_START = 20;
- const STAGGER_DELAY = 12;
- const SLIDE_DISTANCE = 30;
-
- const titleProgress = spring({
- frame: frame - TITLE_START,
- fps,
- config: { damping: 20, stiffness: 100 }
- });
-
- return (
- <AbsoluteFill style={{
- backgroundColor: COLOR_BG,
- padding: PADDING,
- display: "flex",
- flexDirection: "column",
- justifyContent: "center",
- fontFamily: "Inter, sans-serif"
- }}>
- {/* Title */}
- <div style={{
- fontSize: TITLE_FONT_SIZE,
- fontWeight: 700,
- color: COLOR_TEXT,
- marginBottom: 40,
- opacity: titleProgress,
- transform: `translateY(${(1 - titleProgress) * 20}px)`
- }}>
- {TITLE}
- </div>
-
- {/* Feature list */}
- <div style={{ display: "flex", flexDirection: "column", gap: ITEM_GAP }}>
- {FEATURES.map((feature, i) => {
- const itemStart = ITEMS_START + i * STAGGER_DELAY;
- const itemProgress = spring({
- frame: frame - itemStart,
- fps,
- config: { damping: 15, stiffness: 120 }
- });
- const opacity = interpolate(itemProgress, [0, 1], [0, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });
- const translateX = interpolate(itemProgress, [0, 1], [SLIDE_DISTANCE, 0], { extrapolateLeft: "clamp", extrapolateRight: "clamp" });
-
- return (
- <div
- key={i}
- style={{
- display: "flex",
- alignItems: "center",
- gap: 20,
- opacity,
- transform: `translateX(${translateX}px)`
- }}
- >
- <div style={{
- width: ICON_SIZE,
- height: ICON_SIZE,
- borderRadius: 12,
- backgroundColor: COLOR_ACCENT + "20",
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- fontSize: 24
- }}>
- {feature.icon}
- </div>
- <div>
- <div style={{ fontSize: ITEM_FONT_SIZE, fontWeight: 600, color: COLOR_TEXT }}>
- {feature.title}
- </div>
- <div style={{ fontSize: DESC_FONT_SIZE, color: COLOR_MUTED, marginTop: 4 }}>
- {feature.desc}
- </div>
- </div>
- </div>
- );
- })}
- </div>
- </AbsoluteFill>
- );
-};
-```
diff --git a/packages/template-prompt-to-motion-graphics/src/skills/typography.md b/packages/template-prompt-to-motion-graphics/src/skills/typography.md
index 149a58ab34..4e04d645d1 100644
--- a/packages/template-prompt-to-motion-graphics/src/skills/typography.md
+++ b/packages/template-prompt-to-motion-graphics/src/skills/typography.md
@@ -117,315 +117,3 @@ const finalOpacity = interpolate(
</div>;
```
----
-
-## COMPLETE EXAMPLE: Typewriter with Highlight
-
-Prompt: "Text with typewriter effect, pause mid-sentence, then highlight a word"
-
-```tsx
-import {
- useCurrentFrame,
- useVideoConfig,
- AbsoluteFill,
- interpolate,
- spring,
-} from "remotion";
-
-export const MyAnimation = () => {
- /*
- * Typewriter with blinking cursor, dramatic pause, spring-based highlight, and layer crossfade.
- */
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
-
- const COLOR_TEXT = "#000000";
- const COLOR_HIGHLIGHT = "#A7C7E7";
-
- const FULL_TEXT = "From prompt to motion graphics. This is Remotion.";
- const HIGHLIGHT_WORD = "Remotion";
- const CARET_SYMBOL = "β–Œ";
- const SPLIT_AFTER = " This is Remotion.";
-
- const FONT_SIZE = 72;
- const FONT_WEIGHT = 700;
- const CHAR_FRAMES = 2;
- const CURSOR_BLINK_FRAMES = 16;
- const HIGHLIGHT_DELAY = 6;
- const HIGHLIGHT_WIPE_DURATION = 18;
- const CROSSFADE_DURATION = 8;
- const WAIT_AFTER_PRE_SECONDS = 1;
-
- const WAIT_AFTER_PRE_FRAMES = Math.round(fps * WAIT_AFTER_PRE_SECONDS);
- const f = frame;
-
- const splitIndex = FULL_TEXT.indexOf(SPLIT_AFTER);
- const preLen = splitIndex >= 0 ? splitIndex : FULL_TEXT.length;
- const postLen = FULL_TEXT.length - preLen;
-
- let typedChars = 0;
- if (f < preLen * CHAR_FRAMES) {
- typedChars = Math.floor(f / CHAR_FRAMES);
- } else if (f < preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES) {
- typedChars = preLen;
- } else {
- const postPhase = f - preLen * CHAR_FRAMES - WAIT_AFTER_PRE_FRAMES;
- typedChars = Math.min(
- FULL_TEXT.length,
- preLen + Math.floor(postPhase / CHAR_FRAMES),
- );
- }
- const typedText = FULL_TEXT.slice(0, typedChars);
- const typingDone = typedChars >= FULL_TEXT.length;
-
- const caretOpacity = !typingDone
- ? interpolate(
- f % CURSOR_BLINK_FRAMES,
- [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES],
- [1, 0, 1],
- { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
- )
- : 0;
-
- const highlightIndex = FULL_TEXT.indexOf(HIGHLIGHT_WORD);
- const hasHighlight = highlightIndex >= 0;
- const preText = hasHighlight ? FULL_TEXT.slice(0, highlightIndex) : FULL_TEXT;
- const postText = hasHighlight
- ? FULL_TEXT.slice(highlightIndex + HIGHLIGHT_WORD.length)
- : "";
-
- const typeEnd =
- preLen * CHAR_FRAMES + WAIT_AFTER_PRE_FRAMES + postLen * CHAR_FRAMES;
- const highlightStart = typeEnd + HIGHLIGHT_DELAY;
-
- const typedOpacity = interpolate(
- f,
- [highlightStart - CROSSFADE_DURATION, highlightStart + CROSSFADE_DURATION],
- [1, 0],
- { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
- );
- const finalOpacity = interpolate(
- f,
- [highlightStart, highlightStart + CROSSFADE_DURATION],
- [0, 1],
- { extrapolateLeft: "clamp", extrapolateRight: "clamp" },
- );
-
- const entrance = spring({
- fps,
- frame: f,
- config: { damping: 200, stiffness: 120 },
- durationInFrames: 20,
- });
- const containerScale = interpolate(entrance, [0, 1], [0.98, 1], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- });
-
- const highlightProgress = spring({
- fps,
- frame: f - highlightStart,
- config: { damping: 200, stiffness: 180 },
- durationInFrames: HIGHLIGHT_WIPE_DURATION,
- });
- const highlightScaleX = Math.max(0, Math.min(1, highlightProgress));
-
- return (
- <AbsoluteFill
- style={{
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- fontFamily: "Inter, sans-serif",
- }}
- >
- <div
- style={{ position: "relative", transform: `scale(${containerScale})` }}
- >
- {/* Typing layer */}
- <div
- style={{
- color: COLOR_TEXT,
- fontSize: FONT_SIZE,
- fontWeight: FONT_WEIGHT,
- lineHeight: 1.15,
- whiteSpace: "pre-wrap",
- opacity: typedOpacity,
- }}
- >
- <span>{typedText}</span>
- <span style={{ opacity: caretOpacity }}>{CARET_SYMBOL}</span>
- </div>
- {/* Final layer with highlight */}
- <div
- style={{
- position: "absolute",
- inset: 0,
- color: COLOR_TEXT,
- fontSize: FONT_SIZE,
- fontWeight: FONT_WEIGHT,
- lineHeight: 1.15,
- whiteSpace: "pre-wrap",
- opacity: finalOpacity,
- }}
- >
- {hasHighlight ? (
- <>
- <span>{preText}</span>
- <span style={{ position: "relative", display: "inline-block" }}>
- <span
- style={{
- position: "absolute",
- left: 0,
- right: 0,
- top: "50%",
- height: "1.05em",
- transform: `translateY(-50%) scaleX(${highlightScaleX})`,
- transformOrigin: "left center",
- backgroundColor: COLOR_HIGHLIGHT,
- borderRadius: "0.18em",
- zIndex: 0,
- }}
- />
- <span style={{ position: "relative", zIndex: 1 }}>
- {HIGHLIGHT_WORD}
- </span>
- </span>
- <span>{postText}</span>
- </>
- ) : (
- <span>{FULL_TEXT}</span>
- )}
- </div>
- </div>
- </AbsoluteFill>
- );
-};
-```
-
----
-
-## COMPLETE EXAMPLE: Rotating Word Carousel
-
-Prompt: "Text that dissolves between different words"
-
-```tsx
-import { useCurrentFrame, AbsoluteFill, interpolate } from "remotion";
-
-export const MyAnimation = () => {
- /*
- * Prefix text with rotating words that crossfade with blur.
- */
- const frame = useCurrentFrame();
-
- const COLOR_TEXT = "#7b92c1";
- const PREFIX = "Created for";
- const WORDS = ["Creators", "Marketers", "Developers", "Everyone"];
-
- const PREFIX_FONT_SIZE = 80;
- const WORD_FONT_SIZE = 80;
- const PREFIX_WEIGHT = 300;
- const WORD_WEIGHT = 700;
- const WORD_GAP = 20;
- const HOLD_DURATION = 32;
- const FLIP_DURATION = 18;
- const BLUR_AMOUNT = 6;
-
- const perStep = HOLD_DURATION + FLIP_DURATION;
- const totalSteps = WORDS.length;
- const currentStep = Math.floor(frame / perStep) % totalSteps;
- const nextStep = (currentStep + 1) % totalSteps;
- const phase = frame % perStep;
- const isFlipping = phase >= HOLD_DURATION;
- const flipProgress = isFlipping ? (phase - HOLD_DURATION) / FLIP_DURATION : 0;
-
- const outOpacity = interpolate(flipProgress, [0, 1], [1, 0], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- });
- const inOpacity = interpolate(flipProgress, [0, 1], [0, 1], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- });
- const outBlur = interpolate(flipProgress, [0, 1], [0, BLUR_AMOUNT], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- });
- const inBlur = interpolate(flipProgress, [0, 1], [BLUR_AMOUNT, 0], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- });
-
- const longestWord = WORDS.reduce(
- (a, b) => (a.length >= b.length ? a : b),
- WORDS[0],
- );
-
- return (
- <AbsoluteFill
- style={{
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- fontFamily: "Inter, sans-serif",
- }}
- >
- <div
- style={{
- display: "flex",
- alignItems: "baseline",
- gap: WORD_GAP,
- color: COLOR_TEXT,
- }}
- >
- <div style={{ fontSize: PREFIX_FONT_SIZE, fontWeight: PREFIX_WEIGHT }}>
- {PREFIX}
- </div>
- <div
- style={{
- position: "relative",
- fontSize: WORD_FONT_SIZE,
- fontWeight: WORD_WEIGHT,
- }}
- >
- {/* Invisible width keeper */}
- <div style={{ visibility: "hidden" }}>{longestWord}</div>
- {/* Current word (fades out during flip) */}
- {!isFlipping && (
- <div style={{ position: "absolute", left: 0, top: 0 }}>
- {WORDS[currentStep]}
- </div>
- )}
- {/* Crossfade during flip */}
- {isFlipping && (
- <>
- <div
- style={{
- position: "absolute",
- left: 0,
- top: 0,
- opacity: outOpacity,
- filter: `blur(${outBlur}px)`,
- }}
- >
- {WORDS[currentStep]}
- </div>
- <div
- style={{
- position: "absolute",
- left: 0,
- top: 0,
- opacity: inOpacity,
- filter: `blur(${inBlur}px)`,
- }}
- >
- {WORDS[nextStep]}
- </div>
- </>
- )}
- </div>
- </div>
- </AbsoluteFill>
- );
-};
-```