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": "Centered Word Build",
"initialProps": null,
"slug": "centered-word-build",
"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 CenteredWordBuildProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n wordGap?: number;\n accel?: number;\n rise?: number;\n zoomStep?: number;\n settleFrames?: number;\n exitAt?: number;\n exitFrames?: number;\n speed?: number;\n className?: string;\n}\n\nfunction revealFrame(index: number, wordGap: number, accel: number): number {\n let frame = 0;\n\n for (let step = 1; step <= index; step++) {\n // Establish two even beats before tightening the cadence.\n frame += wordGap * accel ** Math.max(step - 2, 0);\n }\n\n return Math.round(frame);\n}\n\nfunction centeredWordBuildLength(\n text: string,\n wordGap = 11,\n accel = 0.75,\n settleFrames = 9,\n exitAt = 51,\n exitFrames = 12,\n): number {\n const words = text.trim().split(/\\s+/).filter(Boolean);\n if (words.length === 0) return 0;\n\n const lastReveal = revealFrame(words.length - 1, wordGap, accel);\n return Math.max(lastReveal + settleFrames, exitAt + exitFrames);\n}\n\nconst settleEasing = Easing.bezier(0.16, 1, 0.3, 1);\n\nfunction CenteredWordBuildBase({\n text,\n fontSize = 52,\n color = \"#fff3df\",\n fontWeight = 400,\n wordGap = 11,\n accel = 0.75,\n rise = 0.18,\n zoomStep = 0.035,\n settleFrames = 9,\n exitAt = 51,\n exitFrames = 12,\n speed = 1,\n className,\n}: CenteredWordBuildProps) {\n const frame = useCurrentFrame() * speed;\n const words = text.trim().split(/\\s+/).filter(Boolean);\n\n if (words.length === 0) return null;\n\n const visibleCount = words.filter(\n (_, index) => frame >= revealFrame(index, wordGap, accel),\n ).length;\n let cameraScale = 1;\n for (let index = 1; index < visibleCount; index++) {\n const revealAt = revealFrame(index, wordGap, accel);\n cameraScale +=\n zoomStep *\n interpolate(\n frame,\n [revealAt, revealAt + Math.max(settleFrames, 0.001)],\n [0, 1],\n {\n easing: settleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n }\n const exitProgress = interpolate(\n frame,\n [exitAt, exitAt + Math.max(exitFrames, 0.001)],\n [0, 1],\n {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const fadeStart = -35 + exitProgress * 135;\n const fadeEnd = fadeStart + 35;\n const exitMask = `linear-gradient(90deg, transparent ${fadeStart}%, black ${fadeEnd}%)`;\n\n return (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n background: \"transparent\",\n }}\n >\n <span\n className={className}\n style={{\n color,\n display: \"inline-block\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.02em\",\n lineHeight: 1.1,\n whiteSpace: \"nowrap\",\n scale: `${cameraScale}`,\n opacity: exitProgress >= 1 ? 0 : 1,\n maskImage: exitProgress > 0 ? exitMask : undefined,\n WebkitMaskImage: exitProgress > 0 ? exitMask : undefined,\n maskRepeat: \"no-repeat\",\n WebkitMaskRepeat: \"no-repeat\",\n }}\n >\n {words.slice(0, visibleCount).map((word, index) => {\n const revealAt = revealFrame(index, wordGap, accel);\n const y = interpolate(\n frame,\n [revealAt, revealAt + Math.max(settleFrames, 0.001)],\n [rise * fontSize, 0],\n {\n easing: settleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n\n return (\n <span\n key={index}\n style={{\n display: \"inline-block\",\n marginLeft: index > 0 ? \"0.25em\" : undefined,\n translate: `0 ${y}px`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"everything we learn from\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 160,\n step: 1,\n default: 52,\n description: \"Font size\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 4,\n max: 24,\n step: 1,\n default: 11,\n description: \"First word gaps\",\n hiddenFromList: false,\n },\n accel: {\n type: \"number\",\n min: 0.4,\n max: 1,\n step: 0.05,\n default: 0.75,\n description: \"Later gap multiplier\",\n hiddenFromList: false,\n },\n rise: {\n type: \"number\",\n min: 0,\n max: 0.5,\n step: 0.01,\n default: 0.18,\n description: \"Word rise (em)\",\n hiddenFromList: false,\n },\n zoomStep: {\n type: \"number\",\n min: 0,\n max: 0.1,\n step: 0.005,\n default: 0.035,\n description: \"Zoom / word\",\n hiddenFromList: false,\n },\n settleFrames: {\n type: \"number\",\n min: 2,\n max: 20,\n step: 1,\n default: 9,\n description: \"Rise and zoom frames\",\n hiddenFromList: false,\n },\n exitAt: {\n type: \"number\",\n min: 20,\n max: 100,\n step: 1,\n default: 51,\n description: \"Exit start frame\",\n hiddenFromList: false,\n },\n exitFrames: {\n type: \"number\",\n min: 4,\n max: 30,\n step: 1,\n default: 12,\n description: \"Exit duration\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fff3df\",\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\",\"accel\",\"rise\",\"zoomStep\",\"settleFrames\",\"exitAt\",\"exitFrames\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"everything we learn from\",\n fontSize: 52,\n wordGap: 11,\n accel: 0.75,\n rise: 0.18,\n zoomStep: 0.035,\n settleFrames: 9,\n exitAt: 51,\n exitFrames: 12,\n color: \"#fff3df\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype CenteredWordBuildElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof CenteredWordBuildBase>;\n\nconst CenteredWordBuildInner = forwardRef<\n HTMLDivElement,\n CenteredWordBuildElementProps & { 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 ?? \"<CenteredWordBuild>\"}\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 <CenteredWordBuildBase\n {...(componentProps as unknown as ComponentProps<typeof CenteredWordBuildBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const CenteredWordBuild = Interactive.withSchema({\n Component: CenteredWordBuildInner,\n componentName: \"<CenteredWordBuild>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 63,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 63
}