Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [],
"dimensions": null,
"displayName": "Zoom Words",
"initialProps": null,
"slug": "zoom-words",
"sourceCode": "import { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface ZoomWordsProps {\n text: string;\n fontSize?: number;\n zoom?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n anchor?: number;\n blur?: number;\n blurFrames?: number;\n speed?: number;\n className?: string;\n}\n\nconst CHAR_WIDTH_EM = 0.52;\nconst SPACE_WIDTH_EM = 0.3;\nconst WORD_BLUR_EM = 0.05;\nconst phraseEasing = Easing.bezier(0.5, 0, 0.7, 0.7);\nconst FADE_EARLY = 0.5;\nconst FADE_SLOTS = 2;\n\nfunction smoothstep(t: number): number {\n const x = Math.min(Math.max(t, 0), 1);\n return x * x * (3 - 2 * x);\n}\nconst WORD_SHIFT_X_EM = 0.16;\nconst WORD_SHIFT_Y_EM = 0.12;\n\nfunction wordWidthEm(word: string): number {\n return Array.from(word).length * CHAR_WIDTH_EM + SPACE_WIDTH_EM;\n}\n\nfunction zoomWordsLength(text: string, wordGap = 12): number {\n const words = text.trim().split(/\\s+/).filter(Boolean);\n return words.length * wordGap;\n}\n\nfunction ZoomWordsBase({\n text,\n fontSize = 64,\n zoom = 2.2,\n color = \"#cfc2ff\",\n fontWeight = 400,\n wordGap = 12,\n anchor = 0.5,\n blur = 0.04,\n blurFrames = 60,\n speed = 1,\n className,\n}: ZoomWordsProps) {\n const frame = useCurrentFrame() * speed;\n\n const words = text.trim().split(/\\s+/).filter(Boolean);\n\n const phraseFrames = words.length * wordGap;\n const wordProgress =\n words.length *\n interpolate(frame, [0, phraseFrames], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n easing: phraseEasing,\n });\n\n const totalEm = words.reduce((sum, w) => sum + wordWidthEm(w), 0);\n const firstHalfEm = words.length > 0 ? wordWidthEm(words[0]) / 2 : 0;\n const lastHalfEm =\n words.length > 0 ? wordWidthEm(words[words.length - 1]) / 2 : 0;\n let revealedEm = 0;\n for (let i = 0; i < words.length; i++) {\n revealedEm +=\n wordWidthEm(words[i]) *\n smoothstep((wordProgress - i + FADE_EARLY) / FADE_SLOTS);\n }\n const travelMax = Math.max(totalEm - lastHalfEm - firstHalfEm, 0.001);\n const raw = Math.min(Math.max(revealedEm, 0), travelMax);\n const cameraEm = firstHalfEm + travelMax * smoothstep(raw / travelMax);\n const cameraPct = totalEm > 0 ? (cameraEm / totalEm) * 100 : 0;\n\n const blurNow =\n blur *\n fontSize *\n zoom *\n interpolate(frame, [0, blurFrames], [1, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n scale: `${zoom}`,\n filter: blurNow > 0.05 ? `blur(${blurNow}px)` : undefined,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: `${anchor * 100}%`,\n transform: \"translateY(-50%)\",\n whiteSpace: \"pre\",\n }}\n >\n <span\n className={className}\n style={{\n display: \"inline-flex\",\n alignItems: \"baseline\",\n transform: `translateX(-${cameraPct.toFixed(3)}%)`,\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.15,\n whiteSpace: \"pre\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n }}\n >\n {words.map((word, i) => {\n const p = smoothstep(\n (wordProgress - i + FADE_EARLY) / FADE_SLOTS,\n );\n const opacity = smoothstep(p * 1.2);\n const wordBlur = WORD_BLUR_EM * fontSize * (1 - p);\n const arrive = 1 - smoothstep(p * 1.6);\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n whiteSpace: \"pre\",\n opacity,\n filter: wordBlur > 0.05 ? `blur(${wordBlur}px)` : undefined,\n translate: `${(WORD_SHIFT_X_EM * fontSize * arrive).toFixed(1)}px ${(WORD_SHIFT_Y_EM * fontSize * arrive).toFixed(1)}px`,\n }}\n >\n {word}\n {i < words.length - 1 && \" \"}\n </span>\n );\n })}\n </span>\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"Still piecing together tools\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 160,\n step: 1,\n default: 64,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 12,\n description: \"Frames / word\",\n hiddenFromList: false,\n },\n zoom: {\n type: \"number\",\n min: 1,\n max: 4,\n step: 0.1,\n default: 2.2,\n description: \"Camera zoom\",\n hiddenFromList: false,\n },\n anchor: {\n type: \"number\",\n min: 0.2,\n max: 0.9,\n step: 0.05,\n default: 0.5,\n description: \"Camera anchor\",\n hiddenFromList: false,\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 0.3,\n step: 0.01,\n default: 0.04,\n description: \"Start blur (em)\",\n hiddenFromList: false,\n },\n blurFrames: {\n type: \"number\",\n min: 10,\n max: 120,\n step: 5,\n default: 60,\n description: \"Focus frames\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#cfc2ff\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"400\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"text\",\"fontSize\",\"wordGap\",\"zoom\",\"anchor\",\"blur\",\"blurFrames\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"Still piecing together tools\",\n fontSize: 64,\n wordGap: 12,\n zoom: 2.2,\n anchor: 0.5,\n blur: 0.04,\n blurFrames: 60,\n color: \"#cfc2ff\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype ZoomWordsElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ZoomWordsBase>;\n\nconst ZoomWordsInner = forwardRef<\n HTMLDivElement,\n ZoomWordsElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<ZoomWords>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <ZoomWordsBase\n {...(componentProps as unknown as ComponentProps<typeof ZoomWordsBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ZoomWords = Interactive.withSchema({\n Component: ZoomWordsInner,\n componentName: \"<ZoomWords>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 63,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 63
}