Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: palaroid

kapishdima8f1b3012d26a
diff --git a/components/docs/examples/polaroid-example.tsx b/components/docs/examples/polaroid-example.tsx
new file mode 100644
index 00000000..ebb7fe30
--- /dev/null
+++ b/components/docs/examples/polaroid-example.tsx
@@ -0,0 +1,85 @@
+"use client";
+
+import { AbsoluteFill, interpolate, useCurrentFrame } from "remotion";
+import { Polaroid } from "@/registry/remocn/polaroid";
+
+function LiveMedia() {
+ const frame = useCurrentFrame();
+ const drift = interpolate(frame, [0, 120], [0, 40]);
+ const scale = interpolate(frame, [0, 120], [1, 1.08]);
+
+ return (
+ <AbsoluteFill
+ style={{
+ background: "#100f14",
+ alignItems: "center",
+ justifyContent: "center",
+ overflow: "hidden",
+ }}
+ >
+ <AbsoluteFill
+ style={{
+ background:
+ "linear-gradient(115deg, #2b3a67 0%, #6f7f35 45%, #b8642a 100%)",
+ transform: `translateX(${-drift}px) scale(${scale})`,
+ }}
+ />
+ </AbsoluteFill>
+ );
+}
+
+export function PolaroidExampleScene({
+ caption = "first light",
+ captionAt,
+ width,
+ captionSize,
+ step,
+}: {
+ caption?: string;
+ captionAt?: number;
+ width?: number;
+ captionSize?: number;
+ step?: number;
+}) {
+ return (
+ <AbsoluteFill style={{ alignItems: "center", justifyContent: "center" }}>
+ <Polaroid
+ caption={caption}
+ captionAt={captionAt}
+ width={width}
+ captionSize={captionSize}
+ step={step}
+ >
+ <LiveMedia />
+ </Polaroid>
+ </AbsoluteFill>
+ );
+}
+
+export const polaroidExampleCode = (
+ values: Record<string, unknown>,
+): string => {
+ const caption = (values.caption as string) ?? "first light";
+ const captionAt = (values.captionAt as number) ?? 0;
+ const width = (values.width as number) ?? 652;
+ const captionSize = (values.captionSize as number) ?? 36;
+ const step = (values.step as number) ?? 3;
+ return `import { OffthreadVideo, staticFile } from "remotion";
+import { Polaroid } from "@/components/remocn/polaroid";
+
+export const MyScene = () => (
+ <Polaroid
+ caption="${caption}"
+ captionAt={${captionAt}}
+ width={${width}}
+ captionSize={${captionSize}}
+ step={${step}}
+ >
+ <OffthreadVideo
+ src={staticFile("clip.mp4")}
+ muted
+ style={{ width: "100%", height: "100%", objectFit: "cover" }}
+ />
+ </Polaroid>
+);`;
+};
diff --git a/content/docs/components.mdx b/content/docs/components.mdx
index 01e0d961..dadfc655 100644
--- a/content/docs/components.mdx
+++ b/content/docs/components.mdx
@@ -354,6 +354,12 @@ Pre-assembled interface elements: code editors, layouts, charts, and workflow vi
status: "stable",
href: "/docs/ui-blocks/paper-sticker",
},
+ {
+ name: "Polaroid",
+ description: "An instant-photo frame with a handwritten caption for video, images, or live compositions",
+ status: "stable",
+ href: "/docs/ui-blocks/polaroid",
+ },
]}
/>
diff --git a/content/docs/ui-blocks/meta.json b/content/docs/ui-blocks/meta.json
index c8a42bd3..5defdd5b 100644
--- a/content/docs/ui-blocks/meta.json
+++ b/content/docs/ui-blocks/meta.json
@@ -9,6 +9,7 @@
"terminal-cursor-zoom",
"animated-line-chart",
"animated-bar-chart",
- "paper-sticker"
+ "paper-sticker",
+ "polaroid"
]
}
diff --git a/content/docs/ui-blocks/paper-sticker.mdx b/content/docs/ui-blocks/paper-sticker.mdx
index 23faa95e..16f45a82 100644
--- a/content/docs/ui-blocks/paper-sticker.mdx
+++ b/content/docs/ui-blocks/paper-sticker.mdx
@@ -64,8 +64,10 @@ const labels = ["remotion", "shadcn", "bun", "biome"];
```
The tilt is fixed per seed and the per-pose wobble is already built in, so do
-not wrap this in `paper-wobble` — that would shake it twice. `maxTilt={0}` sits
-the chip square if you want a deliberately tidy row.
+not wrap this in `paper-wobble` — that would shake it twice. `maxTilt={0}`
+removes the fixed tilt for a deliberately tidy row; the chip still carries the
+per-pose wobble of roughly a fifth of a degree, because it is still a piece of
+paper on a desk.
## Props
@@ -111,7 +113,7 @@ the chip square if you want a deliberately tidy row.
name: "maxTilt",
type: "number",
default: "2.6",
- description: "Largest hand-placed tilt in degrees; 0 sits square",
+ description: "Largest fixed hand-placed tilt in degrees; 0 removes it, leaving only the per-pose wobble",
},
{
name: "step",
diff --git a/content/docs/ui-blocks/polaroid.mdx b/content/docs/ui-blocks/polaroid.mdx
new file mode 100644
index 00000000..8da8f4af
--- /dev/null
+++ b/content/docs/ui-blocks/polaroid.mdx
@@ -0,0 +1,142 @@
+---
+title: Polaroid
+description: An instant-photo frame with a handwritten caption for video, images, or live compositions
+---
+
+<ComponentPreview name="polaroid" />
+
+## Installation
+
+<InstallBlock name="polaroid" />
+
+## Usage
+
+The media is `children`, so anything can play inside the window. Give your
+media `width: 100%` and `height: 100%` — the frame sizes the window, the
+`objectFit` is yours.
+
+```tsx
+// src/Root.tsx
+import { AbsoluteFill, Composition, OffthreadVideo, staticFile } from "remotion";
+import { Polaroid } from "@/components/remocn/polaroid";
+
+const PolaroidScene = () => (
+ <AbsoluteFill
+ style={{
+ background: "#f1eee7",
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <Polaroid caption="first light">
+ <OffthreadVideo
+ src={staticFile("clip.mp4")}
+ muted
+ style={{ width: "100%", height: "100%", objectFit: "cover" }}
+ />
+ </Polaroid>
+ </AbsoluteFill>
+);
+
+export const RemotionRoot = () => (
+ <Composition
+ id="Polaroid"
+ component={PolaroidScene}
+ durationInFrames={150}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+);
+```
+
+### A living photograph
+
+The window takes a whole composition, not just a file. The scene inside keeps
+running on the real 30fps clock while the frame around it moves in stop-motion
+poses — a photograph that never stopped playing, with no pre-rendered video.
+
+```tsx
+<Polaroid caption="the demo">
+ <YourProductScene />
+</Polaroid>
+```
+
+### Stopping the photo
+
+Wrap the media in Remotion's `<Freeze>` to make the photograph stop playing —
+the usual reason is that the card is being flipped aside and should read as a
+still print again.
+
+```tsx
+import { Freeze } from "remotion";
+
+const FREEZE_AT = 90;
+
+<Polaroid caption="the demo">
+ <Freeze frame={FREEZE_AT} active={frame >= FREEZE_AT}>
+ <YourProductScene />
+ </Freeze>
+</Polaroid>;
+```
+
+The card has no jitter or positioning of its own. Wrap it in `paper-wobble` to
+put it on the desk, and position it yourself.
+
+Every measurement derives from `width`, so the card keeps the proportions of
+the original 652px print at any size. `captionSize` defaults to the same scale;
+pass it explicitly only when you want the caption off that ratio.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "children",
+ type: "React.ReactNode",
+ required: true,
+ description: "The media inside the window; give it width and height of 100%",
+ },
+ {
+ name: "caption",
+ type: "string",
+ description: "Handwritten caption; omit it and the band stays empty",
+ },
+ {
+ name: "captionAt",
+ type: "number",
+ default: "0",
+ description: "Local frame the caption starts writing",
+ },
+ {
+ name: "width",
+ type: "number",
+ default: "652",
+ description: "Card width; every other measurement scales from it",
+ },
+ {
+ name: "frameColor",
+ type: "string",
+ default: "\"#fdfcf8\"",
+ description: "Card stock colour",
+ },
+ {
+ name: "captionColor",
+ type: "string",
+ default: "\"#26242c\"",
+ description: "Ink colour of the caption",
+ },
+ {
+ name: "captionSize",
+ type: "number",
+ default: "scales from width",
+ description: "Caption font size; defaults to 36 at the default width",
+ },
+ {
+ name: "step",
+ type: "number",
+ default: "3",
+ description: "Frames per stop-motion pose, forwarded to the caption",
+ },
+ ]}
+/>
diff --git a/registry-artifacts/polaroid.json b/registry-artifacts/polaroid.json
new file mode 100644
index 00000000..a9471228
--- /dev/null
+++ b/registry-artifacts/polaroid.json
@@ -0,0 +1,17 @@
+{
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
+ "name": "polaroid",
+ "title": "Polaroid",
+ "description": "An instant-photo frame with a handwritten caption for video, images, or live compositions.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion", "@remocn/handwrite"],
+ "files": [
+ {
+ "path": "registry/remocn/polaroid/index.tsx",
+ "content": "\"use client\";\n\nimport type React from \"react\";\nimport { Handwrite } from \"@/components/remocn/handwrite\";\nimport { DEFAULT_STEP } from \"@/lib/remocn/stop-motion\";\n\nconst BASE_WIDTH = 652;\nconst BASE_PAD = 16;\nconst BASE_MEDIA_WIDTH = 620;\nconst BASE_MEDIA_HEIGHT = 349;\nconst BASE_CAPTION_HEIGHT = 62;\nconst BASE_CAPTION_SIZE = 36;\n\nexport type PolaroidGeometry = {\n pad: number;\n mediaWidth: number;\n mediaHeight: number;\n captionHeight: number;\n height: number;\n};\n\nexport function polaroidGeometry(width: number): PolaroidGeometry {\n const scale = width / BASE_WIDTH;\n const pad = BASE_PAD * scale;\n const mediaWidth = BASE_MEDIA_WIDTH * scale;\n const mediaHeight = BASE_MEDIA_HEIGHT * scale;\n const captionHeight = BASE_CAPTION_HEIGHT * scale;\n return {\n pad,\n mediaWidth,\n mediaHeight,\n captionHeight,\n height: pad + mediaHeight + captionHeight,\n };\n}\n\nexport interface PolaroidProps {\n children: React.ReactNode;\n caption?: string;\n captionAt?: number;\n width?: number;\n frameColor?: string;\n captionColor?: string;\n captionSize?: number;\n step?: number;\n}\n\nexport function Polaroid({\n children,\n caption,\n captionAt = 0,\n width = BASE_WIDTH,\n frameColor = \"#fdfcf8\",\n captionColor = \"#26242c\",\n captionSize,\n step = DEFAULT_STEP,\n}: PolaroidProps) {\n const { pad, mediaWidth, mediaHeight, captionHeight, height } =\n polaroidGeometry(width);\n const resolvedCaptionSize =\n captionSize ?? BASE_CAPTION_SIZE * (width / BASE_WIDTH);\n\n return (\n <div\n style={{\n width,\n height,\n boxSizing: \"border-box\",\n background: frameColor,\n borderRadius: 4,\n boxShadow:\n \"0 8px 20px rgba(38,36,44,0.18), 0 2px 5px rgba(38,36,44,0.12)\",\n paddingTop: pad,\n }}\n >\n <div\n style={{\n position: \"relative\",\n width: mediaWidth,\n height: mediaHeight,\n margin: \"0 auto\",\n background: \"#100f14\",\n overflow: \"hidden\",\n }}\n >\n {children}\n </div>\n <div style={{ position: \"relative\", height: captionHeight }}>\n {caption ? (\n <Handwrite\n text={caption}\n fontSize={resolvedCaptionSize}\n color={captionColor}\n delay={captionAt}\n perStep={1.4}\n weight={600}\n step={step}\n />\n ) : null}\n </div>\n </div>\n );\n}\n",
+ "type": "registry:component",
+ "target": "components/remocn/polaroid.tsx"
+ }
+ ],
+ "type": "registry:component"
+}
diff --git a/registry-artifacts/registry.json b/registry-artifacts/registry.json
index d2f098f0..a1f6582a 100644
--- a/registry-artifacts/registry.json
+++ b/registry-artifacts/registry.json
@@ -1358,6 +1358,21 @@
],
"type": "registry:component"
},
+ {
+ "name": "polaroid",
+ "title": "Polaroid",
+ "description": "An instant-photo frame with a handwritten caption for video, images, or live compositions.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion", "@remocn/handwrite"],
+ "files": [
+ {
+ "path": "registry/remocn/polaroid/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/polaroid.tsx"
+ }
+ ],
+ "type": "registry:component"
+ },
{
"name": "stop-motion",
"title": "Stop Motion Clock",
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 8d30c6c3..f9e96e27 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -45,6 +45,7 @@ import { perCharacterRiseConfig } from "@/registry/remocn/per-character-rise/con
import { perWordCrossfadeConfig } from "@/registry/remocn/per-word-crossfade/config";
import { perlinDissolveConfig } from "@/registry/remocn/perlin-dissolve/config";
import { perspectiveMarqueeConfig } from "@/registry/remocn/perspective-marquee/config";
+import { polaroidConfig } from "@/registry/remocn/polaroid/config";
import { progressStepsConfig } from "@/registry/remocn/progress-steps/config";
import { pushThroughConfig } from "@/registry/remocn/push-through/config";
import { rgbGlitchTextConfig } from "@/registry/remocn/rgb-glitch-text/config";
@@ -1548,6 +1549,13 @@ const registry: Record<string, RegistryEntry> = {
})),
config: paperStickerConfig,
},
+ polaroid: {
+ load: () =>
+ import("@/components/docs/examples/polaroid-example").then((m) => ({
+ default: m.PolaroidExampleScene,
+ })),
+ config: polaroidConfig,
+ },
"ink-arrow": {
load: () =>
import("@/components/docs/examples/ink-arrow-example").then((m) => ({
diff --git a/registry/remocn/polaroid/__tests__/polaroid.test.ts b/registry/remocn/polaroid/__tests__/polaroid.test.ts
new file mode 100644
index 00000000..9021c890
--- /dev/null
+++ b/registry/remocn/polaroid/__tests__/polaroid.test.ts
@@ -0,0 +1,52 @@
+import { describe, expect, it } from "bun:test";
+
+import { polaroidGeometry } from "../index";
+
+const ASPECT = 620 / 349;
+
+describe("polaroidGeometry", () => {
+ it("reproduces the demo card at the default width", () => {
+ const g = polaroidGeometry(652);
+ expect(g.pad).toBe(16);
+ expect(g.mediaWidth).toBe(620);
+ expect(g.mediaHeight).toBe(349);
+ expect(g.captionHeight).toBe(62);
+ expect(g.height).toBe(427);
+ });
+
+ it("leaves the media window inset by pad on both sides", () => {
+ for (const width of [320, 500, 652, 900]) {
+ const g = polaroidGeometry(width);
+ expect(g.mediaWidth + 2 * g.pad).toBeCloseTo(width, 6);
+ }
+ });
+
+ it("keeps the media aspect at every width", () => {
+ for (const width of [320, 500, 652, 900]) {
+ const g = polaroidGeometry(width);
+ expect(g.mediaWidth / g.mediaHeight).toBeCloseTo(ASPECT, 6);
+ }
+ });
+
+ it("scales every metric linearly with width", () => {
+ const base = polaroidGeometry(652);
+ const half = polaroidGeometry(326);
+ expect(half.pad).toBeCloseTo(base.pad / 2, 6);
+ expect(half.mediaWidth).toBeCloseTo(base.mediaWidth / 2, 6);
+ expect(half.mediaHeight).toBeCloseTo(base.mediaHeight / 2, 6);
+ expect(half.captionHeight).toBeCloseTo(base.captionHeight / 2, 6);
+ expect(half.height).toBeCloseTo(base.height / 2, 6);
+ });
+
+ it("stacks pad, media and caption into the card height", () => {
+ for (const width of [320, 652, 900]) {
+ const g = polaroidGeometry(width);
+ expect(g.height).toBeCloseTo(g.pad + g.mediaHeight + g.captionHeight, 6);
+ }
+ });
+
+ it("keeps the card taller than it is wide only below the demo ratio", () => {
+ const g = polaroidGeometry(652);
+ expect(g.height / 652).toBeCloseTo(427 / 652, 6);
+ });
+});
diff --git a/registry/remocn/polaroid/config.ts b/registry/remocn/polaroid/config.ts
new file mode 100644
index 00000000..5dfc2ecc
--- /dev/null
+++ b/registry/remocn/polaroid/config.ts
@@ -0,0 +1,48 @@
+import { polaroidExampleCode } from "@/components/docs/examples/polaroid-example";
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const polaroidConfig: ComponentConfig = {
+ componentName: "Polaroid",
+ importPath: "@/components/remocn/polaroid",
+ controls: {
+ caption: { type: "text", default: "first light", label: "Caption" },
+ captionAt: {
+ type: "number",
+ default: 0,
+ min: 0,
+ max: 60,
+ step: 1,
+ label: "Caption starts",
+ },
+ width: {
+ type: "number",
+ default: 652,
+ min: 320,
+ max: 900,
+ step: 4,
+ label: "Card width",
+ },
+ captionSize: {
+ type: "number",
+ default: 36,
+ min: 20,
+ max: 56,
+ step: 1,
+ label: "Caption size",
+ },
+ step: {
+ type: "number",
+ default: 3,
+ min: 1,
+ max: 6,
+ step: 1,
+ label: "Frames / pose",
+ },
+ },
+ snippet: polaroidExampleCode,
+ durationInFrames: 150,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+ previewBackdrop: { type: "color", value: "#f1eee7" },
+};
diff --git a/registry/remocn/polaroid/index.tsx b/registry/remocn/polaroid/index.tsx
new file mode 100644
index 00000000..ac91fdfa
--- /dev/null
+++ b/registry/remocn/polaroid/index.tsx
@@ -0,0 +1,103 @@
+"use client";
+
+import type React from "react";
+import { Handwrite } from "@/components/remocn/handwrite";
+import { DEFAULT_STEP } from "@/lib/remocn/stop-motion";
+
+const BASE_WIDTH = 652;
+const BASE_PAD = 16;
+const BASE_MEDIA_WIDTH = 620;
+const BASE_MEDIA_HEIGHT = 349;
+const BASE_CAPTION_HEIGHT = 62;
+const BASE_CAPTION_SIZE = 36;
+
+export type PolaroidGeometry = {
+ pad: number;
+ mediaWidth: number;
+ mediaHeight: number;
+ captionHeight: number;
+ height: number;
+};
+
+export function polaroidGeometry(width: number): PolaroidGeometry {
+ const scale = width / BASE_WIDTH;
+ const pad = BASE_PAD * scale;
+ const mediaWidth = BASE_MEDIA_WIDTH * scale;
+ const mediaHeight = BASE_MEDIA_HEIGHT * scale;
+ const captionHeight = BASE_CAPTION_HEIGHT * scale;
+ return {
+ pad,
+ mediaWidth,
+ mediaHeight,
+ captionHeight,
+ height: pad + mediaHeight + captionHeight,
+ };
+}
+
+export interface PolaroidProps {
+ children: React.ReactNode;
+ caption?: string;
+ captionAt?: number;
+ width?: number;
+ frameColor?: string;
+ captionColor?: string;
+ captionSize?: number;
+ step?: number;
+}
+
+export function Polaroid({
+ children,
+ caption,
+ captionAt = 0,
+ width = BASE_WIDTH,
+ frameColor = "#fdfcf8",
+ captionColor = "#26242c",
+ captionSize,
+ step = DEFAULT_STEP,
+}: PolaroidProps) {
+ const { pad, mediaWidth, mediaHeight, captionHeight, height } =
+ polaroidGeometry(width);
+ const resolvedCaptionSize =
+ captionSize ?? BASE_CAPTION_SIZE * (width / BASE_WIDTH);
+
+ return (
+ <div
+ style={{
+ width,
+ height,
+ boxSizing: "border-box",
+ background: frameColor,
+ borderRadius: 4,
+ boxShadow:
+ "0 8px 20px rgba(38,36,44,0.18), 0 2px 5px rgba(38,36,44,0.12)",
+ paddingTop: pad,
+ }}
+ >
+ <div
+ style={{
+ position: "relative",
+ width: mediaWidth,
+ height: mediaHeight,
+ margin: "0 auto",
+ background: "#100f14",
+ overflow: "hidden",
+ }}
+ >
+ {children}
+ </div>
+ <div style={{ position: "relative", height: captionHeight }}>
+ {caption ? (
+ <Handwrite
+ text={caption}
+ fontSize={resolvedCaptionSize}
+ color={captionColor}
+ delay={captionAt}
+ perStep={1.4}
+ weight={600}
+ step={step}
+ />
+ ) : null}
+ </div>
+ </div>
+ );
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index 6207fe8a..eb738b53 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -1358,6 +1358,21 @@
}
]
},
+ {
+ "name": "polaroid",
+ "type": "registry:component",
+ "title": "Polaroid",
+ "description": "An instant-photo frame with a handwritten caption for video, images, or live compositions.",
+ "dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/stop-motion", "@remocn/handwrite"],
+ "files": [
+ {
+ "path": "polaroid/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/polaroid.tsx"
+ }
+ ]
+ },
{
"name": "stop-motion",
"type": "registry:lib",
diff --git a/tsconfig.json b/tsconfig.json
index 00af7434..4e7497fd 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -24,6 +24,9 @@
"@/lib/remocn-ui": ["./registry/remocn-ui/core/index.ts"],
"@/lib/remocn-ui/*": ["./registry/remocn-ui/core/*"],
"@/lib/remocn/stop-motion": ["./registry/remocn/stop-motion/index.ts"],
+ "@/components/remocn/handwrite": [
+ "./registry/remocn/handwrite/index.tsx"
+ ],
"@/components/remocn/use-cursor-path": [
"./registry/remocn-ui/cursor/use-cursor-path.ts"
],