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": "Shadow Sweep Text",
"initialProps": null,
"slug": "shadow-sweep-text",
"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 ShadowSweepTextProps {\n text: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n backgroundColor?: string;\n shadowColor?: string;\n shadowSoftness?: number;\n rise?: number;\n driftLeft?: number;\n speed?: number;\n className?: string;\n}\n\nconst shadowSweepTextLength = 37;\n\nconst ENTER_END = 23;\nconst EXIT_START = 26;\nconst EXIT_END = shadowSweepTextLength - 1;\nconst REST_X = -20;\nconst REST_Y = 9;\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nfunction ShadowSweepTextBase({\n text,\n fontSize = 96,\n color = \"#aaa6b5\",\n fontWeight = 700,\n backgroundColor = \"#030012\",\n shadowColor = backgroundColor,\n shadowSoftness = 130,\n rise = 96,\n driftLeft = 16,\n speed = 1,\n className,\n}: ShadowSweepTextProps) {\n const frame = useCurrentFrame() * speed;\n const safeSoftness = Math.max(shadowSoftness, 0);\n const travelProgress = interpolate(\n frame,\n [0, shadowSweepTextLength - 1],\n [0, 1],\n {\n ...clamp,\n easing: Easing.out(Easing.cubic),\n },\n );\n const enterProgress = interpolate(frame, [-3, ENTER_END], [0, 1], clamp);\n const exitProgress = interpolate(\n frame,\n [EXIT_START, EXIT_END],\n [0, 1],\n clamp,\n );\n const x = REST_X + driftLeft * (1 - travelProgress);\n const y = REST_Y + rise * (1 - travelProgress);\n const isEntering = frame < ENTER_END;\n const isExiting = frame >= EXIT_START;\n const sweepProgress = isEntering\n ? enterProgress\n : isExiting\n ? exitProgress\n : null;\n const edgeOffset =\n sweepProgress === null ? 0 : (sweepProgress * 2 - 1) * (safeSoftness / 2);\n const edgePosition =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset}px)`;\n const maskStart =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset - safeSoftness / 2}px)`;\n const maskEnd =\n sweepProgress === null\n ? \"50%\"\n : `calc(${sweepProgress * 100}% + ${edgeOffset + safeSoftness / 2}px)`;\n const textMask = isEntering\n ? `linear-gradient(90deg, #000 0, #000 ${maskStart}, transparent ${maskEnd}, transparent 100%)`\n : isExiting\n ? `linear-gradient(90deg, transparent 0, transparent ${maskStart}, #000 ${maskEnd}, #000 100%)`\n : undefined;\n const fieldOpacity =\n sweepProgress === null\n ? 0\n : interpolate(sweepProgress, [0, 0.08, 0.82, 1], [0, 1, 1, 0], clamp);\n const fieldWidth = Math.max(safeSoftness * 3, 1);\n const fieldHeight = Math.max(fontSize * 2.6, safeSoftness * 1.8, 1);\n\n if (text.length === 0) {\n return (\n <div\n className={className}\n style={{ position: \"absolute\", inset: 0, backgroundColor }}\n />\n );\n }\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 backgroundColor,\n }}\n >\n <div\n style={{\n position: \"relative\",\n display: \"inline-block\",\n transform: `translate3d(${x}px, ${y}px, 0)`,\n }}\n >\n <span\n style={{\n color,\n display: \"inline-block\",\n fontFamily: \"Arial, Helvetica, sans-serif\",\n fontSize,\n fontWeight,\n letterSpacing: 0,\n lineHeight: 1,\n maskImage: textMask,\n maskRepeat: \"no-repeat\",\n opacity: 1,\n WebkitMaskImage: textMask,\n WebkitMaskRepeat: \"no-repeat\",\n whiteSpace: \"nowrap\",\n }}\n >\n {text}\n </span>\n\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: edgePosition,\n width: fieldWidth,\n height: fieldHeight,\n background: `radial-gradient(ellipse at center, ${shadowColor} 0%, ${shadowColor} 14%, transparent 72%)`,\n filter: `blur(${safeSoftness * 0.08}px)`,\n opacity: fieldOpacity,\n pointerEvents: \"none\",\n transform: \"translate3d(-50%, -50%, 0)\",\n }}\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n text: {\n type: \"text-content\",\n default: \"are abandoned\",\n description: \"Text\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 180,\n step: 1,\n default: 96,\n description: \"Font size\",\n hiddenFromList: false,\n },\n rise: {\n type: \"number\",\n min: 0,\n max: 300,\n step: 1,\n default: 96,\n description: \"Vertical travel\",\n hiddenFromList: false,\n },\n driftLeft: {\n type: \"number\",\n min: 0,\n max: 120,\n step: 1,\n default: 16,\n description: \"Leftward travel\",\n hiddenFromList: false,\n },\n shadowSoftness: {\n type: \"number\",\n min: 0,\n max: 280,\n step: 2,\n default: 130,\n description: \"Shadow softness\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#aaa6b5\",\n description: \"Text color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Background color\",\n },\n shadowColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Shadow 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 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\",\"rise\",\"driftLeft\",\"shadowSoftness\",\"color\",\"backgroundColor\",\"shadowColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n text: \"are abandoned\",\n fontSize: 96,\n rise: 96,\n driftLeft: 16,\n shadowSoftness: 130,\n color: \"#aaa6b5\",\n backgroundColor: \"#030012\",\n shadowColor: \"#030012\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype ShadowSweepTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ShadowSweepTextBase>;\n\nconst ShadowSweepTextInner = forwardRef<\n HTMLDivElement,\n ShadowSweepTextElementProps & { 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 ?? \"<ShadowSweepText>\"}\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 <ShadowSweepTextBase\n {...(componentProps as unknown as ComponentProps<typeof ShadowSweepTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ShadowSweepText = Interactive.withSchema({\n Component: ShadowSweepTextInner,\n componentName: \"<ShadowSweepText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 37,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 37
}