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": "Outline Fill Track Text",
"initialProps": null,
"slug": "outline-fill-track-text",
"sourceCode": "import { forwardRef, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface OutlineFillTrackTextProps {\n leadText?: string;\n valueText?: string;\n fontSize?: number;\n fontWeight?: number;\n color?: string;\n outlineColor?: string;\n outlineWidth?: number;\n backgroundColor?: string;\n glowColor?: string;\n enterOffset?: number;\n anchorOffsetX?: number;\n trackDistance?: number;\n wordGap?: number;\n endPadding?: number;\n fillDuration?: number;\n speed?: number;\n className?: string;\n}\n\nconst outlineFillTrackTextLength = 80;\n\nconst ENTER_END = 16;\nconst TRACK_START = 16;\nconst TRACK_END = 72;\nconst FILL_START = 34;\nconst FILL_PREFILL = 10;\nconst FONT_FAMILY = \"Arial, Helvetica, sans-serif\";\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\nfunction estimateTextWidth(\n text: string,\n fontSize: number,\n fontWeight: number,\n): number {\n if (typeof document === \"undefined\") {\n return text.length * fontSize * 0.56;\n }\n\n const context = document.createElement(\"canvas\").getContext(\"2d\");\n if (!context) return text.length * fontSize * 0.56;\n context.font = `${fontWeight} ${fontSize}px Arial`;\n return context.measureText(text).width;\n}\n\nfunction OutlineFillTrackTextBase({\n leadText = \"Keep\",\n valueText = \"1000000000%\",\n fontSize = 368,\n fontWeight = 700,\n color = \"#f4f3f6\",\n outlineColor = \"#e6e2ed\",\n outlineWidth = 3,\n backgroundColor = \"#030012\",\n glowColor = \"#64109a\",\n enterOffset = 240,\n anchorOffsetX = -84,\n trackDistance = 0,\n wordGap = 220,\n endPadding = 96,\n fillDuration = 38,\n speed = 1,\n className,\n}: OutlineFillTrackTextProps) {\n const frame = useCurrentFrame() * Math.max(speed, 0);\n const { width: compositionWidth } = useVideoConfig();\n const safeFontSize = Math.max(fontSize, 1);\n const safeFontWeight = Math.max(fontWeight, 1);\n const safeOutlineWidth = Math.max(outlineWidth, 0);\n const safeGap = Math.max(wordGap, 0);\n const safeEndPadding = Math.max(endPadding, 0);\n const safeFillDuration = Math.max(fillDuration, 1);\n\n const measurements = useMemo(() => {\n const leadWidth = estimateTextWidth(leadText, safeFontSize, safeFontWeight);\n const valueWidth = estimateTextWidth(\n valueText,\n safeFontSize,\n safeFontWeight,\n );\n return {\n valueWidth,\n distance: leadWidth / 2 + safeGap + valueWidth / 2,\n };\n }, [leadText, safeFontSize, safeFontWeight, safeGap, valueText]);\n\n const valueOffset = trackDistance > 0 ? trackDistance : measurements.distance;\n const anchorX = compositionWidth / 2 + anchorOffsetX;\n const trailingOverflow = Math.max(\n 0,\n anchorX + measurements.valueWidth / 2 - (compositionWidth - safeEndPadding),\n );\n const travelDistance = valueOffset + trailingOverflow;\n const enterProgress = interpolate(frame, [0, ENTER_END], [0, 1], {\n ...clamp,\n easing: Easing.bezier(0.16, 0.84, 0.24, 1),\n });\n const trackProgress = interpolate(frame, [TRACK_START, TRACK_END], [0, 1], {\n ...clamp,\n easing: Easing.bezier(0.42, 0, 0.58, 1),\n });\n const fillProgress = interpolate(\n frame,\n [FILL_START - FILL_PREFILL, FILL_START + safeFillDuration],\n [0, 1],\n clamp,\n );\n const leadY = enterOffset * (1 - enterProgress);\n const revealEdge = enterProgress * 112 - 8;\n const revealSolid = Math.max(0, Math.min(100, revealEdge - 10));\n const revealFade = Math.max(0, Math.min(100, revealEdge + 10));\n const leadMask = `linear-gradient(180deg, #000 0%, #000 ${revealSolid}%, transparent ${revealFade}%, transparent 100%)`;\n const glowOpacity = interpolate(\n enterProgress,\n [0, 0.18, 0.72, 1],\n [0.92, 1, 0.52, 0],\n clamp,\n );\n const fieldY = interpolate(enterProgress, [0, 1], [-42, -210], clamp);\n const textStyle = {\n display: \"block\",\n fontFamily: FONT_FAMILY,\n fontSize: safeFontSize,\n fontWeight: safeFontWeight,\n letterSpacing: 0,\n lineHeight: 0.86,\n whiteSpace: \"nowrap\" as const,\n };\n\n return (\n <div\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n backgroundColor,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `radial-gradient(ellipse 118% 66% at 50% -12%, ${glowColor} 0%, ${glowColor} 14%, transparent 76%)`,\n filter: `blur(${safeFontSize * 0.15}px)`,\n opacity: glowOpacity,\n pointerEvents: \"none\",\n transform: \"translateZ(0)\",\n }}\n />\n\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: `calc(50% + ${anchorOffsetX}px)`,\n transform: `translate3d(${-travelDistance * trackProgress}px, -50%, 0)`,\n }}\n >\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n color,\n maskImage: leadMask,\n maskRepeat: \"no-repeat\",\n opacity: 1,\n transform: `translate3d(-50%, calc(-50% + ${leadY}px), 0)`,\n WebkitMaskImage: leadMask,\n WebkitMaskRepeat: \"no-repeat\",\n ...textStyle,\n }}\n >\n {leadText}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: valueOffset,\n transform: \"translate3d(-50%, -50%, 0)\",\n visibility: frame < FILL_START ? \"hidden\" : \"visible\",\n }}\n >\n <span\n style={{\n ...textStyle,\n color: \"transparent\",\n paintOrder: \"stroke fill\",\n WebkitTextStroke: `${safeOutlineWidth}px ${outlineColor}`,\n }}\n >\n {valueText}\n </span>\n <span\n style={{\n ...textStyle,\n position: \"absolute\",\n inset: 0,\n clipPath: `inset(0 ${100 - fillProgress * 100}% 0 0)`,\n color,\n opacity: 1,\n }}\n >\n {valueText}\n </span>\n </div>\n\n <div\n style={{\n position: \"absolute\",\n top: fieldY,\n left: 0,\n width: safeFontSize * 2.8,\n height: safeFontSize * 0.72,\n background: `radial-gradient(ellipse at center, ${backgroundColor} 0%, ${backgroundColor} 18%, transparent 74%)`,\n filter: `blur(${safeFontSize * 0.07}px)`,\n opacity: glowOpacity,\n pointerEvents: \"none\",\n transform: \"translate3d(-50%, -50%, 0)\",\n }}\n />\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n leadText: {\n type: \"text-content\",\n default: \"Keep\",\n description: \"Lead text\",\n },\n valueText: {\n type: \"text-content\",\n default: \"1000000000%\",\n description: \"Outlined value\",\n },\n fontSize: {\n type: \"number\",\n min: 120,\n max: 520,\n step: 4,\n default: 368,\n description: \"Font size\",\n hiddenFromList: false,\n },\n enterOffset: {\n type: \"number\",\n min: 0,\n max: 420,\n step: 4,\n default: 240,\n description: \"Vertical entrance offset\",\n hiddenFromList: false,\n },\n anchorOffsetX: {\n type: \"number\",\n min: -400,\n max: 400,\n step: 4,\n default: -84,\n description: \"Shared horizontal anchor offset\",\n hiddenFromList: false,\n },\n trackDistance: {\n type: \"number\",\n min: 0,\n max: 1800,\n step: 10,\n default: 0,\n description: \"Lead-to-value distance override; zero measures the text\",\n hiddenFromList: false,\n },\n wordGap: {\n type: \"number\",\n min: 0,\n max: 500,\n step: 4,\n default: 220,\n description: \"Gap between the lead and value\",\n hiddenFromList: false,\n },\n endPadding: {\n type: \"number\",\n min: 0,\n max: 320,\n step: 4,\n default: 96,\n description: \"Trailing edge padding for long values\",\n hiddenFromList: false,\n },\n fillDuration: {\n type: \"number\",\n min: 8,\n max: 45,\n step: 1,\n default: 38,\n description: \"Fill duration in frames\",\n hiddenFromList: false,\n },\n outlineWidth: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 0.5,\n default: 3,\n description: \"Outline width\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#f4f3f6\",\n description: \"Fill color\",\n },\n outlineColor: {\n type: \"color\",\n default: \"#e6e2ed\",\n description: \"Outline color\",\n },\n backgroundColor: {\n type: \"color\",\n default: \"#030012\",\n description: \"Background color\",\n },\n glowColor: {\n type: \"color\",\n default: \"#64109a\",\n description: \"Entrance glow 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([\"leadText\",\"valueText\",\"fontSize\",\"enterOffset\",\"anchorOffsetX\",\"trackDistance\",\"wordGap\",\"endPadding\",\"fillDuration\",\"outlineWidth\",\"color\",\"outlineColor\",\"backgroundColor\",\"glowColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n leadText: \"Keep\",\n valueText: \"1000000000%\",\n fontSize: 368,\n enterOffset: 240,\n anchorOffsetX: -84,\n trackDistance: 0,\n wordGap: 220,\n endPadding: 96,\n fillDuration: 38,\n outlineWidth: 3,\n color: \"#f4f3f6\",\n outlineColor: \"#e6e2ed\",\n backgroundColor: \"#030012\",\n glowColor: \"#64109a\",\n fontWeight: \"700\",\n speed: 1,\n};\n\ntype OutlineFillTrackTextElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof OutlineFillTrackTextBase>;\n\nconst OutlineFillTrackTextInner = forwardRef<\n HTMLDivElement,\n OutlineFillTrackTextElementProps & { 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 ?? \"<OutlineFillTrackText>\"}\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 <OutlineFillTrackTextBase\n {...(componentProps as unknown as ComponentProps<typeof OutlineFillTrackTextBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const OutlineFillTrackText = Interactive.withSchema({\n Component: OutlineFillTrackTextInner,\n componentName: \"<OutlineFillTrackText>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 80,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 80
}