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": [
{
"name": "@remotion/google-fonts",
"version": null
}
],
"dimensions": null,
"displayName": "Absorb Stack",
"initialProps": null,
"slug": "absorb-stack",
"sourceCode": "import { loadVariableFont } from \"@remotion/google-fonts/Jost\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, spring, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { forwardRef, useImperativeHandle, useRef, type ComponentProps } from \"react\";\n\nconst jost = loadVariableFont(\"normal\", { subsets: [\"latin\"] });\n\ninterface AbsorbStackProps {\n lines?: string[];\n accentLine?: number;\n accent?: string;\n background?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst THEMES = {\n dark: { bg: \"#2A1C17\", ink: \"#E8C9B0\", accent: \"#C8102E\" },\n light: { bg: \"#EAD3C3\", ink: \"#2A1C17\", accent: \"#C8102E\" },\n} as const;\n\nconst LEADING = 1.02;\nconst WEIGHT = 400;\nconst ENTER_LEN = 12;\nconst SETTLE_AT = 14;\nconst RING_GAP = 5;\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\n\nfunction AbsorbStackBase({\n lines = [\"made to\", \"sink into\", \"your cut,\", \"not sit\", \"on top.\"],\n accentLine,\n accent,\n background,\n speed = 1,\n theme = \"dark\",\n}: AbsorbStackProps) {\n const frame = useCurrentFrame() * speed;\n const { width, height, fps } = useVideoConfig();\n const c = THEMES[theme];\n const hot = accent ?? c.accent;\n const bg = background ?? c.bg;\n const n = Math.max(1, lines.length);\n const hotIndex = accentLine ?? n - 1;\n\n const fs = Math.min(height * 0.125, width * 0.1);\n const pitch = fs * LEADING;\n const mid = (n - 1) / 2;\n const centreY = height * 0.5;\n const spreadPitch = n > 1 ? (height * 0.84) / (n - 1) : 0;\n\n return (\n <AbsoluteFill style={{ background: bg, overflow: \"hidden\" }}>\n {lines.map((line, i) => {\n const offset = i - mid;\n const ring = Math.abs(offset);\n const enter = interpolate(\n frame,\n [ring * 3, ring * 3 + ENTER_LEN],\n [0, 1],\n {\n ...CLAMP,\n easing: EASE_OUT,\n },\n );\n const settle = spring({\n frame: frame - SETTLE_AT - ring * RING_GAP,\n fps,\n config: { damping: 20, stiffness: 70, mass: 1 },\n });\n const from = centreY + offset * spreadPitch;\n const to = centreY + offset * pitch;\n const y = from + (to - from) * settle;\n const drift = interpolate(\n enter,\n [0, 1],\n [offset >= 0 ? 0.25 : -0.25, 0],\n );\n const sat = interpolate(settle, [0, 1], [72, 100], CLAMP);\n const ink = i === hotIndex ? hot : c.ink;\n return (\n <div\n key={`${i}-${line}`}\n style={{\n position: \"absolute\",\n left: 0,\n right: 0,\n top: y - pitch / 2,\n height: pitch,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontFamily: jost.fontFamily,\n fontWeight: WEIGHT,\n fontSize: fs,\n lineHeight: 1,\n letterSpacing: \"-0.025em\",\n textTransform: \"lowercase\",\n whiteSpace: \"pre\",\n color: `color-mix(in oklab, ${ink} ${sat.toFixed(1)}%, ${bg})`,\n opacity: enter,\n transform: `translateY(${(drift * fs).toFixed(2)}px)`,\n }}\n >\n {line}\n </div>\n );\n })}\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"dark\",\n variants: {\n dark: {},\n light: {},\n },\n description: \"Theme\",\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([\"theme\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n speed: 1,\n};\n\ntype AbsorbStackElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof AbsorbStackBase>;\n\nconst AbsorbStackInner = forwardRef<\n HTMLDivElement,\n AbsorbStackElementProps & { 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 ?? \"<AbsorbStack>\"}\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 <AbsorbStackBase\n {...(componentProps as unknown as ComponentProps<typeof AbsorbStackBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const AbsorbStack = Interactive.withSchema({\n Component: AbsorbStackInner,\n componentName: \"<AbsorbStack>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 60,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 60
}