Skip to content

πŸŽ₯ Make videos programmatically with React

Add LandingPage

ASchwadb7e3d8968fa7
diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsx
index a2b08bb227..ba771e6369 100644
--- a/packages/template-code-generation/src/app/page.tsx
+++ b/packages/template-code-generation/src/app/page.tsx
@@ -17,6 +17,8 @@ const Home: NextPage = () => {
const [fps, setFps] = useState(examples[0]?.fps || 30);
const [isStreaming, setIsStreaming] = useState(false);
const [streamPhase, setStreamPhase] = useState<StreamPhase>("idle");
+ const [hasStartedGeneration, setHasStartedGeneration] = useState(false);
+ const [prompt, setPrompt] = useState("");
const { code, Component, error, isCompiling, setCode, compileCode } =
useAnimationState(examples[0]?.code || "");
@@ -72,6 +74,39 @@ const Home: NextPage = () => {
};
}, []);
+ const handleStreamingChange = useCallback(
+ (streaming: boolean) => {
+ setIsStreaming(streaming);
+ if (streaming && !hasStartedGeneration) {
+ setHasStartedGeneration(true);
+ }
+ },
+ [hasStartedGeneration],
+ );
+
+ if (!hasStartedGeneration) {
+ return (
+ <div className="h-screen w-screen bg-[#0a0a0a] flex flex-col">
+ <div className="flex items-center py-6 px-12">
+ <div className="flex items-center gap-3">
+ <Image src="/logo.png" alt="Remotion" width={32} height={32} />
+ <span className="text-xl font-bold text-white font-sans">
+ Remotion Code Generation
+ </span>
+ </div>
+ </div>
+ <PromptInput
+ variant="landing"
+ onCodeGenerated={handleCodeChange}
+ onStreamingChange={handleStreamingChange}
+ onStreamPhaseChange={setStreamPhase}
+ prompt={prompt}
+ onPromptChange={setPrompt}
+ />
+ </div>
+ );
+ }
+
return (
<div className="flex h-screen w-screen overflow-hidden bg-[#0a0a0a]">
<div className="flex-1 flex flex-col min-w-0 py-8 px-12 rounded-md gap-8">
@@ -108,8 +143,10 @@ const Home: NextPage = () => {
<PromptInput
onCodeGenerated={handleCodeChange}
- onStreamingChange={setIsStreaming}
+ onStreamingChange={handleStreamingChange}
onStreamPhaseChange={setStreamPhase}
+ prompt={prompt}
+ onPromptChange={setPrompt}
/>
</div>
</div>
diff --git a/packages/template-code-generation/src/components/PromptInput.tsx b/packages/template-code-generation/src/components/PromptInput.tsx
index 57835932ac..edc31575b0 100644
--- a/packages/template-code-generation/src/components/PromptInput.tsx
+++ b/packages/template-code-generation/src/components/PromptInput.tsx
@@ -1,6 +1,15 @@
"use client";
import { useState } from "react";
+import {
+ ArrowUp,
+ Type,
+ MessageCircle,
+ Hash,
+ BarChart3,
+ Disc,
+ type LucideIcon,
+} from "lucide-react";
import {
Select,
SelectContent,
@@ -17,7 +26,15 @@ import {
import { useApiKeyContext } from "@/context/ApiKeyContext";
import { examplePrompts } from "@/data/examplePrompts";
-const MODELS = [
+const iconMap: Record<string, LucideIcon> = {
+ Type,
+ MessageCircle,
+ Hash,
+ BarChart3,
+ Disc,
+};
+
+export const MODELS = [
{ id: "gpt-5-mini", name: "GPT-5 Mini" },
{ id: "gpt-5.1-codex", name: "GPT-5.1 Codex" },
{ id: "gpt-5.1:none", name: "GPT-5.1 (No Reasoning)" },
@@ -26,7 +43,7 @@ const MODELS = [
{ id: "gpt-5.1:high", name: "GPT-5.1 (High Reasoning)" },
] as const;
-type ModelId = (typeof MODELS)[number]["id"];
+export type ModelId = (typeof MODELS)[number]["id"];
export type StreamPhase = "idle" | "reasoning" | "generating";
@@ -34,16 +51,27 @@ interface PromptInputProps {
onCodeGenerated: (code: string) => void;
onStreamingChange?: (isStreaming: boolean) => void;
onStreamPhaseChange?: (phase: StreamPhase) => void;
+ variant?: "landing" | "editor";
+ prompt?: string;
+ onPromptChange?: (prompt: string) => void;
}
export function PromptInput({
onCodeGenerated,
onStreamingChange,
onStreamPhaseChange,
+ variant = "editor",
+ prompt: controlledPrompt,
+ onPromptChange,
}: PromptInputProps) {
const { apiKey, hasApiKey, isLoaded } = useApiKeyContext();
- const [prompt, setPrompt] = useState("");
+ const [uncontrolledPrompt, setUncontrolledPrompt] = useState("");
const [model, setModel] = useState<ModelId>("gpt-5.1:low");
+
+ // Support both controlled and uncontrolled modes
+ const prompt =
+ controlledPrompt !== undefined ? controlledPrompt : uncontrolledPrompt;
+ const setPrompt = onPromptChange || setUncontrolledPrompt;
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
@@ -129,30 +157,48 @@ export function PromptInput({
}
};
+ const isLanding = variant === "landing";
+
return (
- <div className="flex flex-col gap-2">
- <h2 className="text-sm font-medium text-[#888]">Prompt</h2>
+ <div
+ className={
+ isLanding
+ ? "flex flex-col items-center justify-center flex-1 px-4"
+ : "flex flex-col gap-2"
+ }
+ >
+ {isLanding && (
+ <h1 className="text-5xl font-bold text-white mb-10 text-center">
+ What do you want to create?
+ </h1>
+ )}
+
<form
onSubmit={handleSubmit}
- className="flex flex-col gap-3 p-4 bg-[#1a1a1a] rounded-md"
+ className={isLanding ? "w-full max-w-3xl" : ""}
>
- <div className="flex gap-2">
+ <div className="bg-[#1a1a1a] rounded-xl border border-[#333] p-4">
<textarea
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
onKeyDown={handleKeyDown}
- placeholder="Describe your animation... (e.g., 'A bouncing ball')"
- className="flex-1 px-4 py-2 rounded-lg border border-[#333] bg-[#0f0f0f] text-white text-sm font-sans placeholder:text-[#666] focus:outline-none focus:border-[#555] resize-none min-h-[4.5rem] max-h-[200px] overflow-y-auto"
+ placeholder="Describe your animation..."
+ className={`w-full bg-transparent text-white placeholder:text-[#666] focus:outline-none resize-none overflow-y-auto ${
+ isLanding
+ ? "text-base min-h-[60px] max-h-[200px]"
+ : "text-sm min-h-[40px] max-h-[150px]"
+ }`}
style={{ fieldSizing: "content" } as React.CSSProperties}
disabled={isLoading}
/>
- <div className="flex flex-col gap-2">
+
+ <div className="flex justify-between items-center mt-3 pt-3 border-t border-[#333]">
<Select
value={model}
onValueChange={(value) => setModel(value as ModelId)}
disabled={isLoading}
>
- <SelectTrigger className="w-[160px] bg-[#0f0f0f] border-[#333] text-white">
+ <SelectTrigger className="w-auto bg-transparent border-none text-[#888] hover:text-white transition-colors">
<SelectValue />
</SelectTrigger>
<SelectContent className="bg-[#1a1a1a] border-[#333]">
@@ -167,33 +213,17 @@ export function PromptInput({
))}
</SelectContent>
</Select>
+
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
- <div className="w-full">
- <button
- type="submit"
- disabled={isLoading || !prompt.trim() || !hasApiKey}
- className="w-full px-4 py-2 rounded border-none bg-indigo-500 text-white text-sm font-medium cursor-pointer font-sans transition-colors hover:bg-indigo-600 disabled:opacity-50 disabled:cursor-not-allowed flex flex-col items-center gap-1"
- >
- {isLoading ? (
- "Generating..."
- ) : (
- <>
- <span>Generate</span>
- <span className="flex items-center gap-0.5 text-[10px] text-indigo-200/70">
- <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">
- ⌘
- </kbd>
- <span>+</span>
- <kbd className="px-0.5 bg-indigo-600/40 rounded font-mono">
- Enter
- </kbd>
- </span>
- </>
- )}
- </button>
- </div>
+ <button
+ type="submit"
+ disabled={isLoading || !prompt.trim() || !hasApiKey}
+ className="p-2 rounded-lg bg-white text-black hover:bg-gray-200 disabled:opacity-30 disabled:cursor-not-allowed transition-all"
+ >
+ <ArrowUp className="w-5 h-5" />
+ </button>
</TooltipTrigger>
{!hasApiKey && isLoaded && (
<TooltipContent>
@@ -206,22 +236,31 @@ export function PromptInput({
</TooltipProvider>
</div>
</div>
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-xs text-[#666]">Try these:</span>
- {examplePrompts.map((example) => (
- <button
- key={example.id}
- type="button"
- onClick={() => setPrompt(example.prompt)}
- style={{
- borderColor: `${example.color}40`,
- color: example.color,
- }}
- className="px-2 py-1 text-xs rounded-full bg-[#252525] border hover:brightness-125 transition-all"
- >
- {example.headline}
- </button>
- ))}
+
+ <div
+ className={`flex flex-wrap items-center gap-1.5 mt-3 ${
+ isLanding ? "justify-center mt-6 gap-2" : ""
+ }`}
+ >
+ <span className="text-[#666] text-xs mr-1">Try</span>
+ {examplePrompts.map((example) => {
+ const Icon = iconMap[example.icon];
+ return (
+ <button
+ key={example.id}
+ type="button"
+ onClick={() => setPrompt(example.prompt)}
+ style={{
+ borderColor: `${example.color}40`,
+ color: example.color,
+ }}
+ className={`rounded-full bg-[#1a1a1a] border hover:brightness-125 transition-all flex items-center gap-1 px-1.5 py-0.5 text-[11px]`}
+ >
+ {Icon && <Icon className={isLanding ? "w-3 h-3" : "w-3 h-3"} />}
+ {example.headline}
+ </button>
+ );
+ })}
</div>
</form>
</div>
diff --git a/packages/template-code-generation/src/data/examplePrompts.ts b/packages/template-code-generation/src/data/examplePrompts.ts
index 9a39de53cb..6a5c387b3e 100644
--- a/packages/template-code-generation/src/data/examplePrompts.ts
+++ b/packages/template-code-generation/src/data/examplePrompts.ts
@@ -2,6 +2,7 @@ export const examplePrompts = [
{
id: "text-typewriter",
headline: "Typewriter text",
+ icon: "Type",
prompt: `Generate the text "Hello world" with world in yellow highlighting. Do not render any background. That words should be shown next to each other and rendered in black
Animation: Let the words fade in from left to right and then highlight "world" yellow. Mimic a typewriter effect for the text appearance with a blinking cursor at the end of the text.`,
@@ -10,6 +11,7 @@ Animation: Let the words fade in from left to right and then highlight "world" y
{
id: "chat-bubbles",
headline: "Chat messages",
+ icon: "MessageCircle",
prompt: `WhatsApp-style chat bubbles that appear one by one with a bouncy spring animation, alternating between sent and received messages.
Use green for sent messages and gray for received messages. Position them on left and right sides respectively.`,
color: "#86efac",
@@ -17,7 +19,8 @@ Use green for sent messages and gray for received messages. Position them on lef
{
id: "counter",
headline: "Metric counters",
- prompt: `Three animated number counters showing Users (10,000), Revenue ($50,000), and Growth (127%) that count up from zero with staggered timing.
+ icon: "Hash",
+ prompt: `Three animated number counters showing Users (10,000), Revenue ($50,000), and Growth (127%) that count up from zero with staggered timing.
Show all metrics at the same time, use this color #fde047. Focus on no overlaps and no flickering. Show the metrics in the center.`,
color: "#fde047",
@@ -25,6 +28,7 @@ Show all metrics at the same time, use this color #fde047. Focus on no overlaps
{
id: "bar-chart",
headline: "Bar chart",
+ icon: "BarChart3",
prompt: `An animated histogram with the gold price for the following data:
{
"title": "Gold Price 2024",
@@ -49,6 +53,7 @@ Show all metrics at the same time, use this color #fde047. Focus on no overlaps
{
id: "doge-dvd",
headline: "Doge screensaver",
+ icon: "Disc",
prompt: `Create a DVD-Rom Style animation of this image https://i.pinimg.com/600x/ac/82/57/ac8257e1cfc4e63f5c63f3d4869eb7c4.jpg
The graphic moves smoothly across the screen in a straight line, bouncing off the edges of the screen whenever it hits a border. Each time it hits a corner or side, it changes direction, creating a continuous floating, ricocheting motion. The speed is steady, the movement is linear, and the object keeps rotating around the screen endlessly, just like the classic DVD logo screensaver.