Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "caption-outline",
"title": "Caption Outline",
"description": "Heavy-stroked captions that stay readable over any footage, with the spoken word switching to a contrast colour and nothing else moving.",
"dependencies": ["remotion", "@remotion/captions"],
"registryDependencies": ["@remocn/caption-core"],
"files": [
{
"path": "registry/remocn/caption-outline/index.tsx",
"content": "\"use client\";\n\nimport { Fragment } from \"react\";\nimport { Easing, interpolate, interpolateColors } from \"remotion\";\nimport {\n type CaptionBaseProps,\n captionWordText,\n DEFAULT_HOLD_MS,\n getExitWindowMs,\n groupCaptionWords,\n useCaptions,\n} from \"@/lib/remocn/caption-core\";\n\nexport interface CaptionOutlineProps extends CaptionBaseProps {\n activeColor?: string;\n strokeColor?: string;\n strokeWidth?: number;\n}\n\nconst ENTER_MS = 160;\nconst EXIT_MS = 220;\nconst RISE_EM = 0.14;\nconst SWITCH_MS = 70;\n\nconst enterEasing = Easing.bezier(0.2, 0.8, 0.2, 1);\n\nconst clamp = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\nexport function CaptionOutline({\n captions,\n combineTokensWithinMilliseconds = 1200,\n holdMs = DEFAULT_HOLD_MS,\n fontSize = 64,\n fontWeight = 800,\n color = \"#ffffff\",\n activeColor = \"#facc15\",\n strokeColor = \"#000000\",\n strokeWidth = 0.12,\n className,\n}: CaptionOutlineProps) {\n const state = useCaptions({\n captions,\n combineTokensWithinMilliseconds,\n holdMs,\n });\n if (!state) return null;\n\n const enter = interpolate(\n state.previous ? ENTER_MS : state.sinceStartMs,\n [0, ENTER_MS],\n [0, 1],\n {\n ...clamp,\n easing: enterEasing,\n },\n );\n const exit = state.endsInSilence\n ? interpolate(\n state.untilEndMs,\n [0, getExitWindowMs(state, EXIT_MS)],\n [0, 1],\n clamp,\n )\n : 1;\n\n const words = groupCaptionWords(state.tokens);\n const activeWord = words.findIndex((word) =>\n word.some(({ index }) => index === state.activeIndex),\n );\n const activeSince =\n activeWord >= 0 ? state.timeMs - words[activeWord][0].token.fromMs : 0;\n const highlight = (w: number): number => {\n if (w === activeWord) {\n return interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n if (w === activeWord - 1) {\n return 1 - interpolate(activeSince, [0, SWITCH_MS], [0, 1], clamp);\n }\n return 0;\n };\n\n return (\n <div\n className={className}\n style={{\n fontSize,\n fontWeight,\n color,\n lineHeight: 1.2,\n textAlign: \"center\",\n WebkitTextStroke: `${strokeWidth * 2}em ${strokeColor}`,\n paintOrder: \"stroke fill\",\n opacity: Math.min(enter, exit),\n transform: `translateY(${(1 - enter) * RISE_EM}em)`,\n }}\n >\n {words.map((word, w) => (\n <Fragment key={`${state.pageIndex}-${word[0].index}`}>\n {w > 0 && \" \"}\n <span\n style={{\n display: \"inline-block\",\n whiteSpace: \"nowrap\",\n color: interpolateColors(\n highlight(w),\n [0, 1],\n [color, activeColor],\n ),\n }}\n >\n {captionWordText(word)}\n </span>\n </Fragment>\n ))}\n </div>\n );\n}\n",
"type": "registry:component",
"target": "components/remocn/caption-outline.tsx"
}
],
"type": "registry:component"
}