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": "Typed Split Wipe",
"initialProps": null,
"slug": "typed-split-wipe",
"sourceCode": "import { forwardRef, useImperativeHandle, useRef, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\ninterface TypedSplitWipeProps {\n prefix: string;\n anchor: string;\n suffix: string;\n typeFrames?: number;\n exitAt?: number;\n exitFrames?: number;\n wordStagger?: number;\n anchorShift?: number;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n speed?: number;\n className?: string;\n}\n\nconst clamp = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\nconst wipeEasing = Easing.inOut(Easing.quad);\n\nfunction getTypedSplitWipeText(\n text: string,\n frame: number,\n typeFrames: number,\n) {\n const characters = Array.from(text);\n const typedLength = interpolate(\n frame,\n [0, Math.max(typeFrames, 0.001)],\n [0, characters.length],\n clamp,\n );\n const visibleLength = Math.min(\n characters.length,\n Math.max(frame >= 0 ? 1 : 0, Math.floor(typedLength) + 1),\n );\n return characters.slice(0, visibleLength).join(\"\");\n}\n\nfunction TypedSplitWipeBase({\n prefix,\n anchor,\n suffix,\n typeFrames = 30,\n exitAt = 50,\n exitFrames = 20,\n wordStagger = 4,\n anchorShift = -72,\n fontSize = 42,\n color = \"#e8e8e8\",\n fontWeight = 400,\n speed = 1,\n className,\n}: TypedSplitWipeProps) {\n const frame = useCurrentFrame() * speed;\n const fullText = [prefix, anchor, suffix].filter(Boolean).join(\" \");\n const safeExitFrames = Math.max(exitFrames, 0.001);\n const typedText = getTypedSplitWipeText(fullText, frame, typeFrames);\n const suffixWords = suffix.trim().split(/\\s+/).filter(Boolean);\n\n const textStyle: CSSProperties = {\n color,\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.03em\",\n lineHeight: 1,\n whiteSpace: \"pre\",\n };\n\n const prefixExit = interpolate(\n frame,\n [exitAt, exitAt + safeExitFrames],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\n const anchorExitStart = exitAt + Math.max(exitFrames - 6, 0);\n const anchorExit = interpolate(\n frame,\n [anchorExitStart, anchorExitStart + 6],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\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 {frame < exitAt ? (\n <span className={className} style={textStyle}>\n {typedText}\n </span>\n ) : (\n <span\n className={className}\n style={{\n ...textStyle,\n display: \"inline-flex\",\n alignItems: \"baseline\",\n gap: \"0.25em\",\n }}\n >\n {prefix && (\n <span\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 ${prefixExit * 100}% 0 0)`,\n }}\n >\n {prefix}\n </span>\n )}\n\n {anchor && (\n <span\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 ${anchorExit * 50}% 0 ${anchorExit * 50}%)`,\n transform: `translateX(${anchorShift * prefixExit}px)`,\n }}\n >\n {anchor}\n </span>\n )}\n\n {suffixWords.map((word, index) => {\n const wordExitStart = exitAt + 2 + index * wordStagger;\n const wordExit = interpolate(\n frame,\n [wordExitStart, wordExitStart + safeExitFrames * 0.65],\n [0, 1],\n { ...clamp, easing: wipeEasing },\n );\n\n return (\n <span\n key={`${word}-${index}`}\n style={{\n display: \"inline-block\",\n clipPath: `inset(0 0 0 ${wordExit * 100}%)`,\n }}\n >\n {word}\n </span>\n );\n })}\n </span>\n )}\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n prefix: {\n type: \"text-content\",\n default: \"Introducing\",\n description: \"Leading text\",\n },\n anchor: {\n type: \"text-content\",\n default: \"X\",\n description: \"Persistent anchor\",\n },\n suffix: {\n type: \"text-content\",\n default: \"Ads MCP\",\n description: \"Staggered trailing words\",\n },\n typeFrames: {\n type: \"number\",\n min: 6,\n max: 60,\n step: 1,\n default: 30,\n description: \"Typing frames\",\n hiddenFromList: false,\n },\n exitAt: {\n type: \"number\",\n min: 20,\n max: 90,\n step: 1,\n default: 50,\n description: \"Exit start frame\",\n hiddenFromList: false,\n },\n exitFrames: {\n type: \"number\",\n min: 6,\n max: 40,\n step: 1,\n default: 20,\n description: \"Exit duration\",\n hiddenFromList: false,\n },\n wordStagger: {\n type: \"number\",\n min: 0,\n max: 12,\n step: 1,\n default: 4,\n description: \"Suffix word stagger\",\n hiddenFromList: false,\n },\n anchorShift: {\n type: \"number\",\n min: -200,\n max: 0,\n step: 2,\n default: -72,\n description: \"Anchor exit shift\",\n hiddenFromList: false,\n },\n fontSize: {\n type: \"number\",\n min: 18,\n max: 120,\n step: 1,\n default: 42,\n description: \"Font size\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#e8e8e8\",\n description: \"Text 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([\"prefix\",\"anchor\",\"suffix\",\"typeFrames\",\"exitAt\",\"exitFrames\",\"wordStagger\",\"anchorShift\",\"fontSize\",\"color\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n prefix: \"Introducing\",\n anchor: \"X\",\n suffix: \"Ads MCP\",\n typeFrames: 30,\n exitAt: 50,\n exitFrames: 20,\n wordStagger: 4,\n anchorShift: -72,\n fontSize: 42,\n color: \"#e8e8e8\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype TypedSplitWipeElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof TypedSplitWipeBase>;\n\nconst TypedSplitWipeInner = forwardRef<\n HTMLDivElement,\n TypedSplitWipeElementProps & { 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 ?? \"<TypedSplitWipe>\"}\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 <TypedSplitWipeBase\n {...(componentProps as unknown as ComponentProps<typeof TypedSplitWipeBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const TypedSplitWipe = Interactive.withSchema({\n Component: TypedSplitWipeInner,\n componentName: \"<TypedSplitWipe>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 75,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 75
}