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": "Thin Slab",
"initialProps": null,
"slug": "thin-slab",
"sourceCode": "import { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadInterTight } from \"@remotion/google-fonts/InterTight\";\nimport React, { forwardRef, useId, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\nconst display = loadInterTight(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\nconst mono = loadMono(\"normal\", {\n weights: [\"400\", \"500\"],\n subsets: [\"latin\"],\n});\n\ninterface ThinSlabSide {\n value: number;\n label: string;\n unit?: string;\n}\n\ninterface ThinSlabProps {\n title?: string;\n before?: ThinSlabSide;\n after?: ThinSlabSide;\n callout?: string;\n accent?: string;\n background?: string;\n speed?: number;\n theme?: \"dark\" | \"light\";\n}\n\nconst BEAM = [\"#f4f7ff\", \"#8fb4ff\", \"#3d5bff\", \"#1a1660\"] as const;\n\nconst THEMES = {\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F4F3F0\",\n muted: \"#8E8D94\",\n slab: \"#26262C\",\n slabEdge: \"#34343B\",\n ghost: \"#6A6970\",\n deep: BEAM[3],\n tip: BEAM[0],\n haze: \"rgba(61,91,255,0.10)\",\n },\n light: {\n bg: \"#F5F4F0\",\n fg: \"#111113\",\n muted: \"#6E6C67\",\n slab: \"#DDDAD2\",\n slabEdge: \"#CFCBC2\",\n ghost: \"#8F8C85\",\n deep: \"#1a1660\",\n tip: BEAM[1],\n haze: \"rgba(61,91,255,0.06)\",\n },\n} as const;\n\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_SQUEEZE = Easing.bezier(0.7, 0, 0.18, 1.06);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nconst INTER_TIGHT_500 = [\n 223, 271, 452, 595, 601, 786, 608, 269, 324, 324, 479, 624, 274, 420, 260,\n 325, 604, 370, 571, 602, 611, 575, 589, 527, 588, 589, 260, 271, 624, 624,\n 624, 483, 926, 657, 612, 693, 679, 561, 544, 707, 699, 227, 509, 623, 522,\n 858, 706, 726, 597, 727, 603, 601, 608, 695, 657, 940, 624, 643, 597, 324,\n 325, 324, 433, 418, 402, 529, 574, 528, 574, 543, 327, 575, 561, 207, 207,\n 514, 207, 843, 557, 560, 574, 574, 342, 493, 330, 553, 524, 783, 509, 524,\n 509, 396, 301, 396, 624,\n];\nconst TNUM = 0.6;\n\nfunction textEm(text: string) {\n let w = 0;\n for (const ch of text) {\n if (ch >= \"0\" && ch <= \"9\") {\n w += TNUM;\n continue;\n }\n const c = ch.charCodeAt(0);\n w += (c >= 32 && c <= 126 ? INTER_TIGHT_500[c - 32] : 600) / 1000;\n }\n return w;\n}\n\nfunction decimalsOf(n: number) {\n const s = String(n);\n const i = s.indexOf(\".\");\n return i < 0 ? 0 : Math.min(3, s.length - i - 1);\n}\n\nfunction formatNumber(n: number, decimals: number) {\n const fixed = Math.abs(n).toFixed(decimals);\n const [int, frac] = fixed.split(\".\");\n const grouped = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n return `${n < 0 ? \"−\" : \"\"}${grouped}${frac ? `.${frac}` : \"\"}`;\n}\n\nfunction autoCallout(before: number, after: number) {\n if (before <= 0 || after <= 0 || before === after) return \"\";\n const big = Math.max(before, after);\n const small = Math.min(before, after);\n const ratio = big / small;\n const word = after < before ? \"less\" : \"more\";\n if (ratio >= 2) {\n const r = ratio >= 10 ? Math.round(ratio) : Math.round(ratio * 10) / 10;\n return `${r}× ${word}`;\n }\n const pct = Math.round((Math.abs(after - before) / before) * 100);\n return `${after < before ? \"−\" : \"+\"}${pct}%`;\n}\n\nfunction Roll({\n text,\n progressIn,\n progressOut = 0,\n style,\n}: {\n text: string;\n progressIn: number;\n progressOut?: number;\n style: React.CSSProperties;\n}) {\n return (\n <div\n style={{\n fontSize: style.fontSize,\n overflow: \"hidden\",\n padding: \"0.12em 0.2em 0.26em 0.12em\",\n margin: \"-0.12em -0.2em -0.26em -0.12em\",\n }}\n >\n <div\n style={{\n ...style,\n transform: `translateY(${(1 - progressIn) * 150 - progressOut * 150}%)`,\n whiteSpace: \"nowrap\",\n }}\n >\n {text}\n </div>\n </div>\n );\n}\n\nconst DEFAULT_BEFORE: ThinSlabSide = {\n value: 14,\n label: \"By hand\",\n unit: \"days\",\n};\nconst DEFAULT_AFTER: ThinSlabSide = {\n value: 1,\n label: \"With remocn\",\n unit: \"day\",\n};\n\nfunction ThinSlabBase({\n title = \"Time to your first launch video\",\n before = DEFAULT_BEFORE,\n after = DEFAULT_AFTER,\n callout,\n accent = \"#3B5BFD\",\n background,\n speed = 1,\n theme = \"dark\",\n}: ThinSlabProps) {\n const frame = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const t = THEMES[theme];\n const gid = `ts${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n const defaultSides = before === DEFAULT_BEFORE && after === DEFAULT_AFTER;\n const portrait = height > width * 1.1;\n const s = portrait\n ? (width / 1280) * 1.5\n : Math.min(width / 1280, height / 720);\n\n const wipe = interpolate(frame, [-5, 20], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const titleIn = interpolate(frame, [-4, 14], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const numIn = interpolate(frame, [3, 22], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const ghostIn = interpolate(frame, [40, 52], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const labelSwap = interpolate(frame, [42, 56], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const squeeze = interpolate(frame, [46, 82], [0, 1], {\n ...CLAMP,\n easing: EASE_SQUEEZE,\n });\n const count = Math.min(1, Math.max(0, squeeze));\n const calloutIn = interpolate(frame, [70, 88], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const sheen = interpolate(frame, [84, 108], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n\n const left = width * (portrait ? 0.08 : 0.1);\n const slabW = width * (portrait ? 0.78 : 0.7);\n const titleFs = (portrait ? 26 : 22) * s;\n const labelFs = (portrait ? 22 : 18) * s;\n const tMax = height * (portrait ? 0.2 : 0.28);\n const tMin = Math.max(5 * s, tMax * 0.035);\n\n const maxV = Math.max(Math.abs(before.value), Math.abs(after.value), 1e-6);\n const thickOf = (v: number) => Math.max(tMin, (Math.abs(v) / maxV) * tMax);\n const tBefore = thickOf(before.value);\n const tAfter = thickOf(after.value);\n const thick = Math.max(tMin * 0.8, tBefore + (tAfter - tBefore) * squeeze);\n\n const decimals = Math.max(decimalsOf(before.value), decimalsOf(after.value));\n const value = before.value + (after.value - before.value) * count;\n const shown = formatNumber(count >= 0.999 ? after.value : value, decimals);\n const unit =\n shown === formatNumber(after.value, decimals)\n ? (after.unit ?? \"\")\n : (before.unit ?? \"\");\n const numText = `${shown}${unit ? ` ${unit}` : \"\"}`;\n const grows = tAfter > tBefore;\n const widest = Math.max(\n textEm(\n `${formatNumber(before.value, decimals)}${before.unit ? ` ${before.unit}` : \"\"}`,\n ),\n textEm(\n `${formatNumber(after.value, decimals)}${after.unit ? ` ${after.unit}` : \"\"}`,\n ),\n );\n const numFs = Math.min(\n (portrait ? 190 : 168) * s,\n (width - left * 2) / (widest * 0.97),\n );\n\n const gap = height * (portrait ? 0.05 : 0.065);\n const groupH = titleFs * 2.6 + labelFs * 1.5 + numFs * 1.02 + gap + tMax;\n const titleY = Math.max(height * 0.06, (height - groupH) / 2);\n const labelY = titleY + titleFs * 2.6;\n const numY = labelY + labelFs * 1.5;\n const slabCy = numY + numFs * 1.02 + gap + tMax / 2;\n\n const radius = (h: number) => Math.min(14 * s, h / 2);\n const slabTop = slabCy - thick / 2;\n const ghostTop = slabCy - tBefore / 2;\n const callText =\n callout ??\n (defaultSides ? \"14× faster\" : autoCallout(before.value, after.value));\n\n const transparent = background === \"transparent\";\n const showStage = !transparent && background === undefined;\n\n const dimX = left + slabW + 26 * s;\n const tick = 9 * s;\n\n const ghost = (\n <>\n <rect\n x={left}\n y={ghostTop}\n width={slabW}\n height={tBefore}\n rx={radius(tBefore)}\n fill=\"none\"\n stroke={grows ? t.fg : t.ghost}\n strokeWidth={1.4 * s}\n strokeDasharray={`${6 * s} ${6 * s}`}\n opacity={ghostIn * 0.9}\n />\n <text\n x={left + 18 * s}\n y={ghostTop + 18 * s + labelFs * 0.8}\n fill={grows ? t.fg : t.muted}\n fontFamily={mono.fontFamily}\n fontSize={labelFs * 0.9}\n letterSpacing={labelFs * 0.9 * 0.08}\n opacity={interpolate(squeeze, [0.35, 0.8], [0, 1], CLAMP)}\n >\n {`${before.label} · ${formatNumber(before.value, decimalsOf(before.value))}${before.unit ? ` ${before.unit}` : \"\"}`.toUpperCase()}\n </text>\n </>\n );\n\n return (\n <AbsoluteFill\n style={{\n background: transparent ? \"transparent\" : (background ?? t.bg),\n overflow: \"hidden\",\n }}\n >\n {showStage ? (\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n opacity: squeeze > 0 ? Math.min(1, squeeze) : 0,\n background: `radial-gradient(${slabW * 0.75}px ${tMax * 1.1}px at ${left + slabW * 0.6}px ${slabCy}px, ${t.haze} 0%, transparent 100%)`,\n }}\n />\n ) : null}\n\n <div\n style={{\n position: \"absolute\",\n left,\n top: titleY,\n maxWidth: width - left * 2,\n fontFamily: display.fontFamily,\n fontWeight: 400,\n fontSize: titleFs,\n lineHeight: 1.2,\n letterSpacing: \"-0.01em\",\n color: t.muted,\n opacity: titleIn,\n transform: `translateY(${(1 - titleIn) * 10 * s}px)`,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n }}\n >\n {title}\n </div>\n\n <div\n style={{\n position: \"absolute\",\n left,\n top: labelY,\n height: labelFs * 1.3,\n }}\n >\n <div style={{ position: \"absolute\", left: 0, top: 0 }}>\n <Roll\n text={before.label.toUpperCase()}\n progressIn={numIn}\n progressOut={labelSwap}\n style={{\n fontFamily: mono.fontFamily,\n fontWeight: 400,\n fontSize: labelFs,\n letterSpacing: \"0.08em\",\n color: t.muted,\n }}\n />\n </div>\n <div style={{ position: \"absolute\", left: 0, top: 0 }}>\n <Roll\n text={after.label.toUpperCase()}\n progressIn={labelSwap}\n style={{\n fontFamily: mono.fontFamily,\n fontWeight: 500,\n fontSize: labelFs,\n letterSpacing: \"0.08em\",\n color: theme === \"dark\" ? BEAM[1] : accent,\n }}\n />\n </div>\n </div>\n\n <div style={{ position: \"absolute\", left, top: numY }}>\n <Roll\n text={numText}\n progressIn={numIn}\n style={{\n fontFamily: display.fontFamily,\n fontWeight: 500,\n fontSize: numFs,\n lineHeight: 1,\n letterSpacing: \"-0.035em\",\n fontVariantNumeric: \"tabular-nums\",\n color: t.fg,\n }}\n />\n </div>\n\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n style={{ position: \"absolute\", inset: 0, overflow: \"visible\" }}\n aria-hidden\n >\n <defs>\n <linearGradient id={`${gid}f`} x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\">\n <stop offset=\"0\" stopColor={t.deep} />\n <stop offset=\"0.5\" stopColor={accent} />\n <stop offset=\"0.86\" stopColor={BEAM[1]} />\n <stop offset=\"1\" stopColor={t.tip} />\n </linearGradient>\n <linearGradient\n id={`${gid}s`}\n gradientUnits=\"userSpaceOnUse\"\n x1={left - slabW * 0.3 + sheen * slabW * 1.6}\n x2={left + slabW * 0.0 + sheen * slabW * 1.6}\n y1=\"0\"\n y2=\"0\"\n >\n <stop offset=\"0\" stopColor=\"#fff\" stopOpacity={0} />\n <stop offset=\"0.5\" stopColor=\"#fff\" stopOpacity={0.85} />\n <stop offset=\"1\" stopColor=\"#fff\" stopOpacity={0} />\n </linearGradient>\n <clipPath id={`${gid}c`}>\n <rect x={left} y={0} width={slabW * wipe} height={height} />\n </clipPath>\n </defs>\n\n {grows ? null : ghost}\n <g clipPath={`url(#${gid}c)`}>\n <rect\n x={left}\n y={slabTop}\n width={slabW}\n height={thick}\n rx={radius(thick)}\n fill={t.slab}\n stroke={t.slabEdge}\n strokeWidth={1 * s}\n />\n <rect\n x={left}\n y={slabTop}\n width={slabW}\n height={thick}\n rx={radius(thick)}\n fill={`url(#${gid}f)`}\n opacity={Math.min(1, Math.max(0, squeeze * 1.15))}\n />\n {sheen > 0 && sheen < 1 ? (\n <rect\n x={left}\n y={slabTop}\n width={slabW}\n height={thick}\n rx={radius(thick)}\n fill={`url(#${gid}s)`}\n opacity={0.9}\n />\n ) : null}\n </g>\n\n {grows ? ghost : null}\n\n <g opacity={interpolate(wipe, [0.7, 1], [0, 1], CLAMP)}>\n <line\n x1={dimX - tick}\n x2={dimX + tick}\n y1={slabTop}\n y2={slabTop}\n stroke={t.muted}\n strokeWidth={1.4 * s}\n />\n <line\n x1={dimX - tick}\n x2={dimX + tick}\n y1={slabTop + thick}\n y2={slabTop + thick}\n stroke={t.muted}\n strokeWidth={1.4 * s}\n />\n <line\n x1={dimX}\n x2={dimX}\n y1={slabTop}\n y2={slabTop + thick}\n stroke={t.muted}\n strokeWidth={1.4 * s}\n />\n </g>\n </svg>\n\n {callText ? (\n <div\n style={{\n position: \"absolute\",\n left: portrait ? undefined : dimX + 18 * s,\n right: portrait ? width - (left + slabW) : undefined,\n top: portrait ? slabCy + tMax / 2 + 26 * s : slabCy,\n transform: portrait\n ? `translateY(${(1 - calloutIn) * 12 * s}px)`\n : `translate(${(1 - calloutIn) * -10 * s}px, -50%)`,\n opacity: calloutIn,\n fontFamily: display.fontFamily,\n fontWeight: 500,\n fontSize: (portrait ? 44 : 30) * s,\n letterSpacing: \"-0.02em\",\n color: t.fg,\n whiteSpace: \"nowrap\",\n }}\n >\n {callText}\n </div>\n ) : null}\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 accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n title: {\n type: \"text-content\",\n default: \"Time to your first launch video\",\n description: \"Title\",\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\",\"accent\",\"title\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"dark\",\n accent: \"#3B5BFD\",\n title: \"Time to your first launch video\",\n speed: 1,\n};\n\ntype ThinSlabElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof ThinSlabBase>;\n\nconst ThinSlabInner = forwardRef<\n HTMLDivElement,\n ThinSlabElementProps & { 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 ?? \"<ThinSlab>\"}\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 <ThinSlabBase\n {...(componentProps as unknown as ComponentProps<typeof ThinSlabBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const ThinSlab = Interactive.withSchema({\n Component: ThinSlabInner,\n componentName: \"<ThinSlab>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 108,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 108
}