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": "Backdrop",
"initialProps": null,
"slug": "backdrop",
"sourceCode": "import { forwardRef, isValidElement, useImperativeHandle, useRef, type ComponentProps, type ReactNode } from \"react\";\nimport { AbsoluteFill, Img, Interactive, Sequence, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ntype BackdropFill =\n | { type: \"color\"; value: string }\n | { type: \"gradient\"; value: string }\n | { type: \"image\"; src: string; fit?: \"cover\" | \"contain\" };\n\ninterface BackdropProps {\n fill?: BackdropFill | ReactNode;\n padding?: number;\n radius?: number;\n shadow?: string;\n children?: ReactNode;\n className?: string;\n}\n\nconst DEFAULT_FILL: BackdropFill = { type: \"color\", value: \"#0a0a0a\" };\n\nfunction FillLayer({ fill }: { fill: BackdropFill }) {\n if (fill.type === \"image\") {\n return (\n <AbsoluteFill>\n <Img\n src={fill.src}\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: fill.fit ?? \"cover\",\n }}\n />\n </AbsoluteFill>\n );\n }\n\n return <AbsoluteFill style={{ background: fill.value }} />;\n}\n\nfunction BackdropBase({\n fill,\n padding = 4,\n radius = 1,\n shadow = \"0 20px 60px rgba(0,0,0,0.4)\",\n children,\n className,\n}: BackdropProps) {\n const { width } = useVideoConfig();\n\n const paddingPx = (padding / 100) * width;\n const radiusPx = (radius / 100) * width;\n\n const fillLayer = isValidElement(fill) ? (\n <AbsoluteFill>{fill}</AbsoluteFill>\n ) : (\n <FillLayer fill={(fill as BackdropFill | undefined) ?? DEFAULT_FILL} />\n );\n\n return (\n <AbsoluteFill className={className}>\n {fillLayer}\n {children != null && (\n <div\n style={{\n position: \"absolute\",\n inset: paddingPx,\n overflow: \"hidden\",\n borderRadius: radiusPx,\n display: \"flex\",\n ...(shadow === \"\" ? {} : { boxShadow: shadow }),\n }}\n >\n <div style={{ width: \"100%\", height: \"100%\" }}>{children}</div>\n </div>\n )}\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n fillType: {\n type: \"enum\",\n default: \"gradient\",\n variants: {\n color: {},\n gradient: {},\n image: {},\n },\n description: \"Fill type\",\n },\n color: {\n type: \"color\",\n default: \"#6366f1\",\n description: \"Color\",\n },\n gradient: {\n type: \"text-content\",\n default: \"linear-gradient(135deg, #6366f1 0%, #a855f7 100%)\",\n description: \"Gradient (CSS)\",\n },\n image: {\n type: \"text-content\",\n default: \"/hero.png\",\n description: \"Image URL\",\n },\n padding: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 0.5,\n default: 4,\n description: \"Padding\",\n hiddenFromList: false,\n },\n radius: {\n type: \"number\",\n min: 0,\n max: 4,\n step: 0.25,\n default: 1,\n description: \"Radius\",\n hiddenFromList: false,\n },\n shadow: {\n type: \"text-content\",\n default: \"0 20px 60px rgba(0,0,0,0.4)\",\n description: \"Shadow\",\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"fillType\",\"color\",\"gradient\",\"image\",\"padding\",\"radius\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n fillType: \"gradient\",\n color: \"#6366f1\",\n gradient: \"linear-gradient(135deg, #6366f1 0%, #a855f7 100%)\",\n image: \"/hero.png\",\n padding: 4,\n radius: 1,\n shadow: \"0 20px 60px rgba(0,0,0,0.4)\",\n};\n\ntype BackdropElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof BackdropBase>;\n\nconst BackdropInner = forwardRef<\n HTMLDivElement,\n BackdropElementProps & { 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 ?? \"<Backdrop>\"}\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 <BackdropBase\n {...(componentProps as unknown as ComponentProps<typeof BackdropBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const Backdrop = Interactive.withSchema({\n Component: BackdropInner,\n componentName: \"<Backdrop>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 150,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 150
}