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": "Inline Pill Takeover",
"initialProps": null,
"slug": "inline-pill-takeover",
"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 InlinePillTakeoverProps {\n before: string;\n insert: string;\n after: string;\n fontSize?: number;\n color?: string;\n fontWeight?: number;\n pillWidth?: number;\n pillColor?: string;\n pillTextColor?: string;\n expandFrames?: number;\n pillRevealHeightScale?: number;\n pillGrowAt?: number;\n pillGrowFrames?: number;\n pillGrowWidthScale?: number;\n pillGrowHeightScale?: number;\n outerExitFrames?: number;\n takeoverAt?: number;\n takeoverScale?: number;\n blur?: number;\n speed?: number;\n className?: string;\n}\n\nconst PRE_CUT_FRAMES = 12;\nconst TAKEOVER_SETTLE_FRAMES = 6;\nconst PRE_CUT_CAMERA_SCALE = 1.25;\nconst CAMERA_CUT_ENTRY_PROGRESS = 0.86;\nconst expandEasing = Easing.out(Easing.quad);\nconst pillGrowEasing = Easing.inOut(Easing.quad);\nconst fadeEasing = Easing.in(Easing.cubic);\nconst preCutEasing = Easing.out(Easing.quad);\nconst takeoverSettleEasing = Easing.out(Easing.cubic);\n\nfunction InlinePillTakeoverBase({\n before,\n insert,\n after,\n fontSize = 52,\n color = \"#fff3df\",\n fontWeight = 400,\n pillWidth = 260,\n pillColor = \"#fffaf0\",\n pillTextColor = \"#1c1210\",\n expandFrames = 12,\n pillRevealHeightScale = 0.35,\n pillGrowAt = 12,\n pillGrowFrames = 24,\n pillGrowWidthScale = 1.08,\n pillGrowHeightScale = 1.16,\n outerExitFrames = 18,\n takeoverAt = 12,\n takeoverScale = 2.15,\n blur = 12,\n speed = 1,\n className,\n}: InlinePillTakeoverProps) {\n const frame = useCurrentFrame() * speed;\n const safeExpandFrames = Math.max(expandFrames, 0.001);\n const pillGrowEnd = pillGrowAt + Math.max(pillGrowFrames, 0.001);\n const outerExitEnd = Math.max(outerExitFrames, 2.001);\n const dashWidth = fontSize * 0.72;\n const pillHeight = fontSize * 1.22;\n const cutAt = takeoverAt + PRE_CUT_FRAMES;\n const cutEntryScale = takeoverScale * CAMERA_CUT_ENTRY_PROGRESS;\n\n const expand = interpolate(frame, [0, safeExpandFrames], [0, 1], {\n easing: expandEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const pillGrowProgress = interpolate(\n frame,\n [pillGrowAt, pillGrowEnd],\n [0, 1],\n {\n easing: pillGrowEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const outerExit = interpolate(frame, [2, outerExitEnd], [0, 1], {\n easing: fadeEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const pillTextOpacity = frame >= 3 ? 1 : 0;\n const preCutCameraScale = interpolate(\n frame,\n [takeoverAt, cutAt - 1],\n [1, PRE_CUT_CAMERA_SCALE],\n {\n easing: preCutEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const postCutCameraScale = interpolate(\n frame,\n [cutAt, cutAt + TAKEOVER_SETTLE_FRAMES],\n [cutEntryScale, takeoverScale],\n {\n easing: takeoverSettleEasing,\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n },\n );\n const cameraScale = frame < cutAt ? preCutCameraScale : postCutCameraScale;\n const revealedPillWidth = dashWidth + (pillWidth - dashWidth) * expand;\n const revealedPillHeight =\n pillHeight * (pillRevealHeightScale + (1 - pillRevealHeightScale) * expand);\n const pillWidthGrow = 1 + (pillGrowWidthScale - 1) * pillGrowProgress;\n const pillHeightGrow = 1 + (pillGrowHeightScale - 1) * pillGrowProgress;\n const animatedPillWidth = revealedPillWidth * pillWidthGrow;\n const animatedPillHeight = revealedPillHeight * pillHeightGrow;\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 background: \"transparent\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n transform: `scale(${cameraScale})`,\n transformOrigin: \"center\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: \"100%\",\n gap: `${fontSize * 0.16}px`,\n whiteSpace: \"nowrap\",\n fontFamily:\n \"var(--font-geist-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif)\",\n fontSize,\n fontWeight,\n letterSpacing: \"-0.02em\",\n lineHeight: 1,\n }}\n >\n <span\n style={{\n flex: 1,\n textAlign: \"right\",\n color,\n opacity: 1 - outerExit,\n filter: outerExit > 0 ? `blur(${blur * outerExit}px)` : undefined,\n }}\n >\n {before}\n </span>\n\n <span\n style={{\n position: \"relative\",\n display: \"inline-block\",\n flexShrink: 0,\n width: animatedPillWidth,\n height: animatedPillHeight,\n overflow: \"hidden\",\n borderRadius: animatedPillHeight / 2,\n background: pillColor,\n color: pillTextColor,\n }}\n >\n <span\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n translate: \"-50% -50%\",\n fontSize: fontSize * 0.84,\n opacity: pillTextOpacity,\n whiteSpace: \"nowrap\",\n }}\n >\n {insert}\n </span>\n </span>\n\n <span\n style={{\n flex: 1,\n textAlign: \"left\",\n color,\n opacity: 1 - outerExit,\n filter: outerExit > 0 ? `blur(${blur * outerExit}px)` : undefined,\n }}\n >\n {after}\n </span>\n </div>\n </div>\n </div>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n before: {\n type: \"text-content\",\n default: \"powering 20%\",\n description: \"Text before pill\",\n },\n insert: {\n type: \"text-content\",\n default: \"Start building\",\n description: \"Pill text\",\n },\n after: {\n type: \"text-content\",\n default: \"of the Internet.\",\n description: \"Text after pill\",\n },\n fontSize: {\n type: \"number\",\n min: 24,\n max: 120,\n step: 1,\n default: 52,\n description: \"Font size\",\n hiddenFromList: false,\n },\n pillWidth: {\n type: \"number\",\n min: 100,\n max: 600,\n step: 5,\n default: 260,\n description: \"Expanded pill width\",\n hiddenFromList: false,\n },\n expandFrames: {\n type: \"number\",\n min: 6,\n max: 45,\n step: 1,\n default: 12,\n description: \"Width reveal frames\",\n hiddenFromList: false,\n },\n pillRevealHeightScale: {\n type: \"number\",\n min: 0.05,\n max: 1,\n step: 0.05,\n default: 0.35,\n description: \"Initial reveal height scale\",\n hiddenFromList: false,\n },\n pillGrowAt: {\n type: \"number\",\n min: 6,\n max: 30,\n step: 1,\n default: 12,\n description: \"Pill growth start frame\",\n hiddenFromList: false,\n },\n pillGrowFrames: {\n type: \"number\",\n min: 6,\n max: 36,\n step: 1,\n default: 24,\n description: \"Pill growth frames\",\n hiddenFromList: false,\n },\n pillGrowWidthScale: {\n type: \"number\",\n min: 1,\n max: 1.3,\n step: 0.01,\n default: 1.08,\n description: \"Final pill width scale\",\n hiddenFromList: false,\n },\n pillGrowHeightScale: {\n type: \"number\",\n min: 1,\n max: 1.5,\n step: 0.01,\n default: 1.16,\n description: \"Final pill height scale\",\n hiddenFromList: false,\n },\n outerExitFrames: {\n type: \"number\",\n min: 6,\n max: 30,\n step: 1,\n default: 18,\n description: \"Outer text exit frames\",\n hiddenFromList: false,\n },\n takeoverAt: {\n type: \"number\",\n min: 12,\n max: 40,\n step: 1,\n default: 12,\n description: \"Camera move start frame\",\n hiddenFromList: false,\n },\n takeoverScale: {\n type: \"number\",\n min: 1,\n max: 4,\n step: 0.05,\n default: 2.15,\n description: \"Final takeover scale\",\n hiddenFromList: false,\n },\n blur: {\n type: \"number\",\n min: 0,\n max: 30,\n step: 1,\n default: 12,\n description: \"Outer text blur\",\n hiddenFromList: false,\n },\n color: {\n type: \"color\",\n default: \"#fff3df\",\n description: \"Outer text color\",\n },\n pillColor: {\n type: \"color\",\n default: \"#fffaf0\",\n description: \"Pill color\",\n },\n pillTextColor: {\n type: \"color\",\n default: \"#1c1210\",\n description: \"Pill 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([\"before\",\"insert\",\"after\",\"fontSize\",\"pillWidth\",\"expandFrames\",\"pillRevealHeightScale\",\"pillGrowAt\",\"pillGrowFrames\",\"pillGrowWidthScale\",\"pillGrowHeightScale\",\"outerExitFrames\",\"takeoverAt\",\"takeoverScale\",\"blur\",\"color\",\"pillColor\",\"pillTextColor\",\"fontWeight\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n before: \"powering 20%\",\n insert: \"Start building\",\n after: \"of the Internet.\",\n fontSize: 52,\n pillWidth: 260,\n expandFrames: 12,\n pillRevealHeightScale: 0.35,\n pillGrowAt: 12,\n pillGrowFrames: 24,\n pillGrowWidthScale: 1.08,\n pillGrowHeightScale: 1.16,\n outerExitFrames: 18,\n takeoverAt: 12,\n takeoverScale: 2.15,\n blur: 12,\n color: \"#fff3df\",\n pillColor: \"#fffaf0\",\n pillTextColor: \"#1c1210\",\n fontWeight: \"400\",\n speed: 1,\n};\n\ntype InlinePillTakeoverElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof InlinePillTakeoverBase>;\n\nconst InlinePillTakeoverInner = forwardRef<\n HTMLDivElement,\n InlinePillTakeoverElementProps & { 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 ?? \"<InlinePillTakeover>\"}\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 <InlinePillTakeoverBase\n {...(componentProps as unknown as ComponentProps<typeof InlinePillTakeoverBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const InlinePillTakeover = Interactive.withSchema({\n Component: InlinePillTakeoverInner,\n componentName: \"<InlinePillTakeover>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 30,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 30
}