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": "Perspective Marquee",
"initialProps": null,
"slug": "perspective-marquee",
"sourceCode": "import { Interactive, Sequence, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\ninterface PerspectiveMarqueeProps {\n items?: string[];\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n pixelsPerFrame?: number;\n rotateY?: number;\n rotateX?: number;\n perspective?: number;\n fadeColor?: string;\n speed?: number;\n className?: string;\n}\n\nconst FONT_FAMILY =\n \"var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif\";\n\nconst DEFAULT_ITEMS = [\n \"Vercel\",\n \"Linear\",\n \"Stripe\",\n \"Figma\",\n \"Notion\",\n \"Raycast\",\n \"Arc\",\n \"Cursor\",\n];\n\nfunction PerspectiveMarqueeBase({\n items = DEFAULT_ITEMS,\n fontSize = 84,\n color = \"#fafafa\",\n fontWeight = 700,\n pixelsPerFrame = 2,\n rotateY = -28,\n rotateX = 8,\n perspective = 1200,\n fadeColor = \"#050505\",\n speed = 1,\n className,\n}: PerspectiveMarqueeProps) {\n const frame = useCurrentFrame() * speed;\n\n // Approximate width of one full item set so the modulo wraps cleanly.\n const itemPadding = fontSize * 0.9;\n const approxItemWidth = items.reduce(\n (acc, item) => acc + item.length * fontSize * 0.6 + itemPadding,\n 0,\n );\n\n const offset = -((frame * pixelsPerFrame) % approxItemWidth);\n\n // Render the row 3x so the loop is seamless even when rotated in 3D.\n const rendered = [...items, ...items, ...items];\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n overflow: \"hidden\",\n perspective: `${perspective}px`,\n }}\n >\n <div\n style={{\n width: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"flex-start\",\n transform: `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`,\n transformStyle: \"preserve-3d\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n whiteSpace: \"nowrap\",\n translate: `${offset}px`,\n }}\n >\n {rendered.map((item, i) => {\n // Approximate this item's center X (relative to the marquee row,\n // including the rolling offset). Used to dial in depth-of-field blur\n // and opacity by horizontal position on screen.\n const itemCenter =\n i * (approxItemWidth / items.length) +\n approxItemWidth / items.length / 2 +\n offset;\n // Normalize roughly to [-1, 1] across a 1280px viewport.\n const norm = (itemCenter - 640) / 640;\n const distance = Math.min(1, Math.abs(norm));\n const blurPx = distance * 6;\n const opacity = 1 - distance * 0.4;\n\n return (\n <span\n key={i}\n style={{\n display: \"inline-block\",\n fontFamily: FONT_FAMILY,\n fontSize,\n fontWeight,\n color,\n letterSpacing: \"-0.03em\",\n paddingRight: itemPadding,\n filter: `blur(${blurPx}px)`,\n opacity,\n }}\n >\n {item}\n </span>\n );\n })}\n </div>\n </div>\n\n {/* Vignette to fade marquee edges into background */}\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n background: `linear-gradient(90deg, ${fadeColor} 0%, transparent 18%, transparent 82%, ${fadeColor} 100%)`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n pointerEvents: \"none\",\n background: `linear-gradient(180deg, ${fadeColor} 0%, transparent 25%, transparent 75%, ${fadeColor} 100%)`,\n }}\n />\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fontSize: {\n type: \"number\",\n min: 24,\n max: 200,\n step: 2,\n default: 84,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fafafa\",\n description: \"Color\",\n },\n fontWeight: {\n type: \"enum\",\n default: \"700\",\n variants: {\n \"400\": {},\n \"500\": {},\n \"600\": {},\n \"700\": {},\n },\n description: \"Font weight\",\n },\n pixelsPerFrame: {\n type: \"number\",\n min: 0.25,\n max: 10,\n step: 0.25,\n default: 2,\n description: \"Pixels / frame\",\n hiddenFromList: false,\n },\n rotateY: {\n type: \"number\",\n min: -60,\n max: 60,\n step: 1,\n default: -28,\n description: \"Rotate Y (deg)\",\n hiddenFromList: false,\n },\n rotateX: {\n type: \"number\",\n min: -30,\n max: 30,\n step: 1,\n default: 8,\n description: \"Rotate X (deg)\",\n hiddenFromList: false,\n },\n perspective: {\n type: \"number\",\n min: 400,\n max: 3000,\n step: 50,\n default: 1200,\n description: \"Perspective\",\n hiddenFromList: false,\n },\n fadeColor: {\n type: \"color\",\n default: \"#050505\",\n description: \"Fade color\",\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([\"fontSize\",\"color\",\"fontWeight\",\"pixelsPerFrame\",\"rotateY\",\"rotateX\",\"perspective\",\"fadeColor\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fontSize: 84,\n color: \"#fafafa\",\n fontWeight: \"700\",\n pixelsPerFrame: 2,\n rotateY: -28,\n rotateX: 8,\n perspective: 1200,\n fadeColor: \"#050505\",\n speed: 1,\n};\n\ntype PerspectiveMarqueeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PerspectiveMarqueeBase>;\n\nconst PerspectiveMarqueeInner = forwardRef<\n HTMLDivElement,\n PerspectiveMarqueeElementProps & { 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 ?? \"<PerspectiveMarquee>\"}\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 <PerspectiveMarqueeBase\n {...(componentProps as unknown as ComponentProps<typeof PerspectiveMarqueeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PerspectiveMarquee = Interactive.withSchema({\n Component: PerspectiveMarqueeInner,\n componentName: \"<PerspectiveMarquee>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 240,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 240
}