Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: create claude chat

dev_wandry5496638c159e
diff --git a/content/docs/ui-blocks/claude-chat.mdx b/content/docs/ui-blocks/claude-chat.mdx
new file mode 100644
index 00000000..cd3c964b
--- /dev/null
+++ b/content/docs/ui-blocks/claude-chat.mdx
@@ -0,0 +1,119 @@
+---
+title: Claude Chat
+description: Animated Claude chat input that types a prompt and morphs the waveform button into a send button
+---
+
+<ComponentPreview name="claude-chat" />
+
+## Installation
+
+<InstallBlock name="claude-chat" />
+
+<Note>
+ Installing `claude-chat` pulls the `Inter` and `Fraunces` fonts via `@remotion/google-fonts` automatically. No additional install needed.
+</Note>
+
+## Usage
+
+Standalone in a Remotion `<Composition>` — renders immediately after install:
+
+```tsx
+// src/Root.tsx
+import { Composition } from "remotion";
+import { ClaudeChat } from "@/components/remocn/claude-chat";
+
+const ClaudeChatScene = () => (
+ <ClaudeChat
+ greeting="Back at it, Dima"
+ placeholder="Try: draft an email · summarize a doc · plan your week"
+ prompt="Draft a launch tweet for our new release"
+ modelName="Opus 4.8"
+ modelTier="Max"
+ accentColor="#D97757"
+ theme="light"
+ background="surface"
+ speed={1}
+ />
+);
+
+export const RemotionRoot = () => (
+ <Composition
+ id="ClaudeChat"
+ component={ClaudeChatScene}
+ durationInFrames={150}
+ fps={30}
+ width={1280}
+ height={720}
+ />
+);
+```
+
+Timeline: card + greeting ease in (0–16), default state with blinking caret holds (16–42), the prompt types in from frame 42, and the waveform button morphs into the terracotta send button the instant text appears, then holds to the end.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "greeting",
+ type: "string",
+ default: "\"Back at it, Dima\"",
+ description: "Serif greeting headline shown above the input",
+ },
+ {
+ name: "placeholder",
+ type: "string",
+ default: "\"Try: draft an email · summarize a doc · plan your week\"",
+ description: "Muted placeholder shown before typing begins",
+ },
+ {
+ name: "prompt",
+ type: "string",
+ default: "\"Draft a launch tweet for our new release\"",
+ description: "The text that types in character-by-character",
+ },
+ {
+ name: "modelName",
+ type: "string",
+ default: "\"Opus 4.8\"",
+ description: "Model label in the toolbar",
+ },
+ {
+ name: "modelTier",
+ type: "string",
+ default: "\"Max\"",
+ description: "Tier label shown next to the model name",
+ },
+ {
+ name: "accentColor",
+ type: "string",
+ default: "\"#D97757\"",
+ description: "Terracotta accent used for the sunburst and send button",
+ },
+ {
+ name: "theme",
+ type: "\"light\" | \"dark\"",
+ default: "\"light\"",
+ description: "Warm light or dark color theme",
+ },
+ {
+ name: "background",
+ type: "\"surface\" | \"transparent\"",
+ default: "\"surface\"",
+ description: "Page background fill or transparent",
+ },
+ {
+ name: "speed",
+ type: "number",
+ default: "1",
+ description: "Animation speed multiplier (minimum 1 so the prompt finishes typing)",
+ },
+ ]}
+/>
+
+## Notes
+
+- **Button morph:** The waveform-to-send morph is gated purely on text presence — the moment the prompt has any characters, the terracotta send button appears.
+- **Static mic:** The microphone button stays static throughout the animation.
+- **Offline-friendly:** No network requests or images are used, so the preview works offline and MP4 export requires no CORS setup.
+- **Serif greeting:** The greeting headline uses the `Fraunces` serif typeface.
diff --git a/content/docs/ui-blocks/meta.json b/content/docs/ui-blocks/meta.json
index 88e5641d..46248e85 100644
--- a/content/docs/ui-blocks/meta.json
+++ b/content/docs/ui-blocks/meta.json
@@ -8,6 +8,7 @@
"code-accordion",
"code-diff-wipe",
"tool-menu-slide-in",
+ "claude-chat",
"animated-line-chart",
"animated-bar-chart",
"drag-and-drop-flow"
diff --git a/content/docs/ui/components/caret.mdx b/content/docs/ui/components/caret.mdx
new file mode 100644
index 00000000..d2f2602b
--- /dev/null
+++ b/content/docs/ui/components/caret.mdx
@@ -0,0 +1,113 @@
+---
+title: Caret
+description: A blinking text caret — a pure motion atom or a fully controlled bar
+---
+
+<ComponentPreview name="caret" />
+
+A **text caret**: a thin vertical bar you can drive two ways. Pass a controlled `opacity` and it renders exactly that (let the surrounding component decide when the caret shows), or set `blink` and it blinks deterministically from `useCurrentFrame()`. Safe in Remotion's headless per-frame renderer (no `Date`, `Math.random`, or `requestAnimationFrame`).
+
+It is the shared caret behind the `input` primitive and the `claude-chat` composition.
+
+## Installation
+
+<InstallBlock name="caret" />
+
+## Usage
+
+Controlled — the consumer decides visibility (e.g. a typing state machine):
+
+```tsx
+import { Caret } from "@/components/remocn/caret";
+
+export const Scene = () => (
+ <Caret color="#1F1E1D" height={24} opacity={typing ? 1 : 0} />
+);
+```
+
+Standalone blink — a self-animating caret:
+
+```tsx
+import { Caret } from "@/components/remocn/caret";
+
+export const Scene = () => <Caret blink blinkPerSecond={1} height={28} />;
+```
+
+## How blink works
+
+```
+visible = floor(frame × speed / halfPeriod) is even
+halfPeriod = fps / blinkPerSecond / 2
+```
+
+When `opacity` is provided it always wins; otherwise `blink` drives the bar, and with neither the caret stays solid.
+
+## Props
+
+<PropsTable
+ rows={[
+ {
+ name: "color",
+ type: "string",
+ default: "\"currentColor\"",
+ description: "Bar fill color. Defaults to currentColor so it inherits the surrounding text color.",
+ },
+ {
+ name: "width",
+ type: "number",
+ default: "2",
+ description: "Bar width in px.",
+ },
+ {
+ name: "height",
+ type: "number",
+ default: "18",
+ description: "Bar height in px.",
+ },
+ {
+ name: "radius",
+ type: "number",
+ default: "1",
+ description: "Corner radius in px.",
+ },
+ {
+ name: "opacity",
+ type: "number",
+ description: "Controlled opacity. When set, it overrides blink and renders exactly this value.",
+ },
+ {
+ name: "blink",
+ type: "boolean",
+ default: "false",
+ description: "When true and opacity is unset, the caret blinks on the timeline.",
+ },
+ {
+ name: "blinkPerSecond",
+ type: "number",
+ default: "1",
+ description: "Full on/off blink cycles per second.",
+ },
+ {
+ name: "speed",
+ type: "number",
+ default: "1",
+ description: "Scales the playhead used for blinking. speed=2 blinks twice as fast.",
+ },
+ {
+ name: "marginLeft",
+ type: "number",
+ default: "0",
+ description: "Left gap in px, useful to space the caret after revealed text.",
+ },
+ {
+ name: "className",
+ type: "string",
+ description: "Optional className passed to the span.",
+ },
+ {
+ name: "style",
+ type: "CSSProperties",
+ description: "Optional style overrides merged last (e.g. vertical alignment offsets).",
+ },
+ ]}
+/>
diff --git a/content/docs/ui/components/meta.json b/content/docs/ui/components/meta.json
index ddae1dfd..1713166e 100644
--- a/content/docs/ui/components/meta.json
+++ b/content/docs/ui/components/meta.json
@@ -1,5 +1,5 @@
{
"title": "Components",
"collapsible": false,
- "pages": ["accordion", "alert-dialog", "blur-in", "button", "checkbox", "combobox", "command-menu", "context-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "popover", "progress", "radio", "resizable", "select", "skeleton", "slider", "spinner", "stepper", "switch", "tabs", "toast", "toggle-group", "tooltip"]
+ "pages": ["accordion", "alert-dialog", "blur-in", "button", "caret", "checkbox", "combobox", "command-menu", "context-menu", "cursor", "dialog", "drawer", "sheet", "dropdown-menu", "input", "popover", "progress", "radio", "resizable", "select", "skeleton", "slider", "spinner", "stepper", "switch", "tabs", "toast", "toggle-group", "tooltip"]
}
diff --git a/content/docs/ui/concepts.mdx b/content/docs/ui/concepts.mdx
index 6febd735..309057f2 100644
--- a/content/docs/ui/concepts.mdx
+++ b/content/docs/ui/concepts.mdx
@@ -63,6 +63,27 @@ interface Step<S extends string = string> {
}
```
+### `useTypewriter` — typed text reveal
+
+`useTypewriter` is the shared typewriter driver. It reads the frame and reveals a string character-by-character at a fixed rate, returning the revealed slice plus status flags. It composes `revealCount` (count math) and `revealedText` (the pure slice), so every surface that types text uses one source of truth.
+
+```ts
+function useTypewriter(
+ full: string,
+ options?: { cps?: number; speed?: number; startFrame?: number },
+): { text: string; count: number; done: boolean; typing: boolean }
+```
+
+- `cps` — characters per second (default `20`). `speed` scales the playhead; `startFrame` delays the start.
+- `typing` is `true` only while characters are still appearing; pair it with the `caret` primitive so the cursor stays solid mid-type and blinks otherwise:
+
+```tsx
+const tw = useTypewriter(text, { cps: 22, speed, startFrame: 42 });
+<span>{tw.text}<Caret blink={!tw.typing} speed={speed} /></span>
+```
+
+Components that already receive a controlled count (`combobox`, `command-menu`) or reveal by state-transition progress (`input`) call `revealedText(full, count)` directly instead of the hook, so they share the same slice without taking on a frame timer.
+
`duration` is consumed by `useStateTransition` (and transition hooks). `useCurrentState` ignores it — snap resolution has no concept of transition length.
## States snap by default
@@ -152,7 +173,7 @@ Installing any component in this tier also installs `lib/remocn-ui/` with these
| Module | Key exports |
|---|---|
-| `timeline.ts` | `useCurrentState`, `useStateTransition`, `framesFor`, `revealCount` |
+| `timeline.ts` | `useCurrentState`, `useStateTransition`, `useTypewriter`, `framesFor`, `revealCount`, `revealedText` |
| `theme.ts` | `RemocnUIProvider`, `useRemocnTheme`, `defaultLightTheme`, `defaultDarkTheme` |
| `color.ts` | `mixOklch`, `parseColor`, `oklchToRgb`, `rgbToOklch`, `toCss` |
| `motion.ts` | `easings`, `springs` |
diff --git a/registry/__index__.tsx b/registry/__index__.tsx
index 39008208..ea1ea81e 100644
--- a/registry/__index__.tsx
+++ b/registry/__index__.tsx
@@ -101,6 +101,8 @@ import { XFollowersOverview } from "@/registry/remocn/x-followers-overview";
import { xFollowersOverviewConfig } from "@/registry/remocn/x-followers-overview/config";
import { Confetti } from "@/registry/remocn/confetti";
import { confettiConfig } from "@/registry/remocn/confetti/config";
+import { ClaudeChat } from "@/registry/remocn/claude-chat";
+import { claudeChatConfig } from "@/registry/remocn/claude-chat/config";
import { Accordion } from "@/registry/remocn-ui/accordion";
import { accordionConfig } from "@/registry/remocn-ui/accordion/config";
import { AlertDialog } from "@/registry/remocn-ui/alert-dialog";
@@ -123,6 +125,8 @@ import { Radio } from "@/registry/remocn-ui/radio";
import { radioConfig } from "@/registry/remocn-ui/radio/config";
import { Spinner } from "@/registry/remocn-ui/spinner";
import { spinnerConfig } from "@/registry/remocn-ui/spinner/config";
+import { CaretPreview } from "@/registry/remocn-ui/caret/preview";
+import { caretConfig } from "@/registry/remocn-ui/caret/config";
import { Switch } from "@/registry/remocn-ui/switch";
import { switchConfig } from "@/registry/remocn-ui/switch/config";
import { Select } from "@/registry/remocn-ui/select";
@@ -327,6 +331,7 @@ const registry: Record<string, RegistryEntry> = {
config: xFollowersOverviewConfig,
},
"confetti": { Component: Confetti, config: confettiConfig },
+ "claude-chat": { Component: ClaudeChat, config: claudeChatConfig },
"button": { Component: Button, config: buttonConfig },
"accordion": { Component: Accordion, config: accordionConfig },
"alert-dialog": { Component: AlertDialog, config: alertDialogConfig },
@@ -400,6 +405,7 @@ const registry: Record<string, RegistryEntry> = {
// an opaque inset:0 stage that centers the fixed-size bordered box, like tabs.
"resizable": { Component: Resizable, config: resizableConfig },
"spinner": { Component: Spinner, config: spinnerConfig },
+ "caret": { Component: CaretPreview, config: caretConfig },
};
// Append the shared controls (e.g. `speed`) to every component config so
@@ -451,4 +457,16 @@ if (xFollowersOverview) {
};
}
+const claudeChat = registry["claude-chat"];
+if (claudeChat) {
+ claudeChat.config.controls.speed = {
+ type: "number",
+ default: 1,
+ min: 1,
+ max: 4,
+ step: 0.25,
+ label: "Speed",
+ };
+}
+
export default registry;
diff --git a/registry/remocn-ui/caret/__tests__/caret.test.ts b/registry/remocn-ui/caret/__tests__/caret.test.ts
new file mode 100644
index 00000000..2231d3dd
--- /dev/null
+++ b/registry/remocn-ui/caret/__tests__/caret.test.ts
@@ -0,0 +1,66 @@
+import { describe, expect, it } from "vitest";
+
+import { caretBlinkOpacity } from "../index";
+
+const FPS = 30;
+
+describe("caretBlinkOpacity", () => {
+ it("returns only 0 or 1 across a full range of frames", () => {
+ for (let f = 0; f <= 300; f++) {
+ const v = caretBlinkOpacity(f, { fps: FPS, blinkPerSecond: 1, speed: 1 });
+ expect(v === 0 || v === 1).toBe(true);
+ }
+ });
+
+ it("starts visible at frame 0", () => {
+ expect(caretBlinkOpacity(0, { fps: FPS, blinkPerSecond: 1, speed: 1 })).toBe(1);
+ });
+
+ it("toggles after one half-period for blinkPerSecond=1", () => {
+ const halfPeriod = FPS / 1 / 2;
+ const on = caretBlinkOpacity(0, { fps: FPS, blinkPerSecond: 1, speed: 1 });
+ const off = caretBlinkOpacity(halfPeriod, {
+ fps: FPS,
+ blinkPerSecond: 1,
+ speed: 1,
+ });
+ expect(on).toBe(1);
+ expect(off).toBe(0);
+ });
+
+ it("is deterministic for identical inputs", () => {
+ const a = caretBlinkOpacity(37, { fps: FPS, blinkPerSecond: 2, speed: 1 });
+ const b = caretBlinkOpacity(37, { fps: FPS, blinkPerSecond: 2, speed: 1 });
+ expect(a).toBe(b);
+ });
+
+ it("blinks twice as fast when blinkPerSecond doubles", () => {
+ const slowToggle = FPS / 1 / 2;
+ const fastToggle = FPS / 2 / 2;
+ expect(
+ caretBlinkOpacity(fastToggle, { fps: FPS, blinkPerSecond: 2, speed: 1 }),
+ ).toBe(0);
+ expect(
+ caretBlinkOpacity(fastToggle, { fps: FPS, blinkPerSecond: 1, speed: 1 }),
+ ).toBe(1);
+ expect(
+ caretBlinkOpacity(slowToggle, { fps: FPS, blinkPerSecond: 1, speed: 1 }),
+ ).toBe(0);
+ });
+
+ it("speed=2 at frame f matches speed=1 at frame 2f", () => {
+ for (let f = 0; f <= 120; f++) {
+ const fast = caretBlinkOpacity(f, { fps: FPS, blinkPerSecond: 1, speed: 2 });
+ const normal = caretBlinkOpacity(2 * f, {
+ fps: FPS,
+ blinkPerSecond: 1,
+ speed: 1,
+ });
+ expect(fast).toBe(normal);
+ }
+ });
+
+ it("stays visible when blinkPerSecond is 0 or negative", () => {
+ expect(caretBlinkOpacity(13, { fps: FPS, blinkPerSecond: 0, speed: 1 })).toBe(1);
+ });
+});
diff --git a/registry/remocn-ui/caret/config.ts b/registry/remocn-ui/caret/config.ts
new file mode 100644
index 00000000..1c31dab6
--- /dev/null
+++ b/registry/remocn-ui/caret/config.ts
@@ -0,0 +1,25 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const caretConfig: ComponentConfig = {
+ componentName: "Caret",
+ importPath: "@/components/remocn/caret",
+ controls: {
+ height: { type: "number", default: 28, min: 8, max: 80, step: 2, label: "Height" },
+ width: { type: "number", default: 3, min: 1, max: 8, step: 1, label: "Width" },
+ radius: { type: "number", default: 1, min: 0, max: 8, step: 1, label: "Radius" },
+ blink: { type: "boolean", default: true, label: "Blink" },
+ blinkPerSecond: {
+ type: "number",
+ default: 1,
+ min: 0.25,
+ max: 4,
+ step: 0.25,
+ label: "Blink/sec",
+ },
+ color: { type: "color", default: "#1F1E1D", label: "Color" },
+ },
+ durationInFrames: 120,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+};
diff --git a/registry/remocn-ui/caret/index.tsx b/registry/remocn-ui/caret/index.tsx
new file mode 100644
index 00000000..6afadde0
--- /dev/null
+++ b/registry/remocn-ui/caret/index.tsx
@@ -0,0 +1,69 @@
+"use client";
+
+import type { CSSProperties } from "react";
+import { useCurrentFrame, useVideoConfig } from "remotion";
+
+export interface CaretProps {
+ color?: string;
+ width?: number;
+ height?: number;
+ radius?: number;
+ opacity?: number;
+ blink?: boolean;
+ blinkPerSecond?: number;
+ speed?: number;
+ marginLeft?: number;
+ className?: string;
+ style?: CSSProperties;
+}
+
+export function caretBlinkOpacity(
+ frame: number,
+ opts: { fps: number; blinkPerSecond: number; speed: number },
+): number {
+ const cycles = opts.blinkPerSecond <= 0 ? 1 : opts.blinkPerSecond;
+ const halfPeriod = opts.fps / cycles / 2;
+ if (halfPeriod <= 0) return 1;
+ return Math.floor((frame * opts.speed) / halfPeriod) % 2 === 0 ? 1 : 0;
+}
+
+export function Caret({
+ color = "currentColor",
+ width = 2,
+ height = 18,
+ radius = 1,
+ opacity,
+ blink = false,
+ blinkPerSecond = 1,
+ speed = 1,
+ marginLeft = 0,
+ className,
+ style,
+}: CaretProps) {
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+
+ const resolvedOpacity =
+ opacity !== undefined
+ ? opacity
+ : blink
+ ? caretBlinkOpacity(frame, { fps, blinkPerSecond, speed })
+ : 1;
+
+ return (
+ <span
+ className={className}
+ style={{
+ display: "inline-block",
+ flexShrink: 0,
+ width,
+ height,
+ borderRadius: radius,
+ background: color,
+ opacity: resolvedOpacity,
+ marginLeft,
+ ...style,
+ }}
+ />
+ );
+}
diff --git a/registry/remocn-ui/caret/preview.tsx b/registry/remocn-ui/caret/preview.tsx
new file mode 100644
index 00000000..6724976e
--- /dev/null
+++ b/registry/remocn-ui/caret/preview.tsx
@@ -0,0 +1,55 @@
+"use client";
+
+import { useRemocnTheme } from "@/lib/remocn-ui";
+import { Caret } from "@/registry/remocn-ui/caret";
+
+export interface CaretPreviewProps {
+ height?: number;
+ width?: number;
+ radius?: number;
+ blink?: boolean;
+ blinkPerSecond?: number;
+ color?: string;
+}
+
+export function CaretPreview({
+ height = 28,
+ width = 3,
+ radius = 1,
+ blink = true,
+ blinkPerSecond = 1,
+ color,
+}: CaretPreviewProps) {
+ const theme = useRemocnTheme();
+
+ return (
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ background: theme.background,
+ color: theme.foreground,
+ fontFamily:
+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif",
+ fontSize: 28,
+ letterSpacing: "-0.01em",
+ }}
+ >
+ <span style={{ display: "inline-flex", alignItems: "center" }}>
+ <span>Type something</span>
+ <Caret
+ color={color ?? theme.foreground}
+ height={height}
+ width={width}
+ radius={radius}
+ blink={blink}
+ blinkPerSecond={blinkPerSecond}
+ marginLeft={4}
+ />
+ </span>
+ </div>
+ );
+}
diff --git a/registry/remocn-ui/combobox/index.tsx b/registry/remocn-ui/combobox/index.tsx
index ac3afbeb..d35f9cf7 100644
--- a/registry/remocn-ui/combobox/index.tsx
+++ b/registry/remocn-ui/combobox/index.tsx
@@ -1,6 +1,6 @@
"use client";
-import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+import { type RemocnTheme, revealedText, useRemocnTheme } from "@/lib/remocn-ui";
import {
inputStyle,
inputStyleContext,
@@ -43,7 +43,7 @@ export function filterComboboxItems(
revealCount?: number,
): string[] {
const visible = (
- revealCount === undefined ? query : query.slice(0, revealCount)
+ revealCount === undefined ? query : revealedText(query, revealCount)
)
.trim()
.toLowerCase();
@@ -122,7 +122,7 @@ export function Combobox({
const v = style ?? comboboxStyle(state, ctx);
const visibleQuery =
- revealCount === undefined ? query : query.slice(0, revealCount);
+ revealCount === undefined ? query : revealedText(query, revealCount);
const filtered = filterComboboxItems(items, query, revealCount);
const trigger: InputStyle =
diff --git a/registry/remocn-ui/command-menu/index.tsx b/registry/remocn-ui/command-menu/index.tsx
index f5b2031a..9eecefef 100644
--- a/registry/remocn-ui/command-menu/index.tsx
+++ b/registry/remocn-ui/command-menu/index.tsx
@@ -1,6 +1,6 @@
"use client";
-import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+import { type RemocnTheme, revealedText, useRemocnTheme } from "@/lib/remocn-ui";
import {
CommandMenuItemRow,
commandMenuItemStyle,
@@ -44,7 +44,7 @@ export function filterCommandItems(
revealCount?: number,
): CommandMenuEntry[] {
const visible = (
- revealCount === undefined ? query : query.slice(0, revealCount)
+ revealCount === undefined ? query : revealedText(query, revealCount)
)
.trim()
.toLowerCase();
@@ -145,7 +145,7 @@ export function CommandMenu({
const v = style ?? commandMenuStyle(state, ctx);
const visibleQuery =
- revealCount === undefined ? query : query.slice(0, revealCount);
+ revealCount === undefined ? query : revealedText(query, revealCount);
const filtered = filterCommandItems(items, query, revealCount);
return (
diff --git a/registry/remocn-ui/core/__tests__/timeline.test.ts b/registry/remocn-ui/core/__tests__/timeline.test.ts
index 98480551..2ca0e4ac 100644
--- a/registry/remocn-ui/core/__tests__/timeline.test.ts
+++ b/registry/remocn-ui/core/__tests__/timeline.test.ts
@@ -56,6 +56,34 @@ describe("revealCount (typewriter math)", () => {
});
});
+function revealedText(full: string, count: number): string {
+ const c = Math.max(0, Math.min(full.length, Math.floor(count)));
+ return full.slice(0, c);
+}
+
+describe("revealedText", () => {
+ it("returns an empty string for a count of 0 or less", () => {
+ expect(revealedText("hello", 0)).toBe("");
+ expect(revealedText("hello", -5)).toBe("");
+ });
+
+ it("returns the full string once count reaches the length", () => {
+ expect(revealedText("hello", 5)).toBe("hello");
+ });
+
+ it("clamps a count beyond the length to the full string", () => {
+ expect(revealedText("hello", 99)).toBe("hello");
+ });
+
+ it("returns the leading slice for a mid-flight count", () => {
+ expect(revealedText("hello", 3)).toBe("hel");
+ });
+
+ it("floors a fractional count", () => {
+ expect(revealedText("hello", 2.9)).toBe("he");
+ });
+});
+
interface Step<S extends string = string> {
at: number;
state: S;
diff --git a/registry/remocn-ui/core/index.ts b/registry/remocn-ui/core/index.ts
index e34de09a..dd0d6d70 100644
--- a/registry/remocn-ui/core/index.ts
+++ b/registry/remocn-ui/core/index.ts
@@ -3,9 +3,12 @@ export {
clamp01,
framesFor,
revealCount,
+ revealedText,
useCurrentState,
useStateTransition,
+ useTypewriter,
} from "./timeline";
+export type { TypewriterOptions, TypewriterState } from "./timeline";
export {
mixOklch,
oklchToRgb,
diff --git a/registry/remocn-ui/core/timeline.ts b/registry/remocn-ui/core/timeline.ts
index c6fa9d03..e584bfe8 100644
--- a/registry/remocn-ui/core/timeline.ts
+++ b/registry/remocn-ui/core/timeline.ts
@@ -1,4 +1,4 @@
-import { useCurrentFrame } from "remotion";
+import { useCurrentFrame, useVideoConfig } from "remotion";
import type { Step } from "./types";
export function framesFor(d: number | { seconds: number }, fps: number): number {
@@ -20,6 +20,41 @@ export function clamp01(t: number): number {
return Math.max(0, Math.min(1, t));
}
+export function revealedText(full: string, count: number): string {
+ const c = Math.max(0, Math.min(full.length, Math.floor(count)));
+ return full.slice(0, c);
+}
+
+export interface TypewriterOptions {
+ cps?: number;
+ speed?: number;
+ startFrame?: number;
+}
+
+export interface TypewriterState {
+ text: string;
+ count: number;
+ done: boolean;
+ typing: boolean;
+}
+
+export function useTypewriter(
+ full: string,
+ options: TypewriterOptions = {},
+): TypewriterState {
+ const { cps = 20, speed = 1, startFrame = 0 } = options;
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const local = frame * speed - startFrame;
+ const count = local <= 0 ? 0 : revealCount(local, fps, full.length, cps);
+ return {
+ text: revealedText(full, count),
+ count,
+ done: count >= full.length,
+ typing: count > 0 && count < full.length,
+ };
+}
+
export function useCurrentState<S extends string>(
steps: Step<S>[],
defaultState: S,
diff --git a/registry/remocn-ui/input/index.tsx b/registry/remocn-ui/input/index.tsx
index a469fa1b..eccc5235 100644
--- a/registry/remocn-ui/input/index.tsx
+++ b/registry/remocn-ui/input/index.tsx
@@ -1,6 +1,12 @@
"use client";
-import { mixOklch, type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";
+import {
+ mixOklch,
+ type RemocnTheme,
+ revealedText,
+ useRemocnTheme,
+} from "@/lib/remocn-ui";
+import { Caret } from "@/components/remocn/caret";
export type InputState =
| "idle"
@@ -162,7 +168,7 @@ export function Input({
const sizeStyle = SIZE_STYLES[size];
const ctx = inputStyleContext(theme);
const v = style ?? inputStyle(state, ctx);
- const revealed = value.slice(0, Math.round(value.length * v.valueReveal));
+ const revealed = revealedText(value, Math.round(value.length * v.valueReveal));
return (
<div
@@ -212,16 +218,12 @@ export function Input({
<span style={{ whiteSpace: "nowrap", color: ctx.foreground }}>
{revealed}
</span>
- <span
- style={{
- flexShrink: 0,
- width: 2,
- height: Math.round(sizeStyle.fontSize * 1.1),
- borderRadius: 1,
- background: ctx.foreground,
- opacity: v.caretOpacity,
- marginLeft: revealed.length > 0 ? 4 : 0,
- }}
+ <Caret
+ color={ctx.foreground}
+ height={Math.round(sizeStyle.fontSize * 1.1)}
+ radius={1}
+ opacity={v.caretOpacity}
+ marginLeft={revealed.length > 0 ? 4 : 0}
/>
</div>
</div>
diff --git a/registry/remocn-ui/registry.json b/registry/remocn-ui/registry.json
index 40de9455..e8935cdb 100644
--- a/registry/remocn-ui/registry.json
+++ b/registry/remocn-ui/registry.json
@@ -57,6 +57,21 @@
}
]
},
+ {
+ "name": "caret",
+ "type": "registry:component",
+ "title": "UI Caret",
+ "description": "A blinking text caret — a controlled vertical bar, or a pure motion atom that blinks deterministically from useCurrentFrame.",
+ "dependencies": ["remotion"],
+ "registryDependencies": [],
+ "files": [
+ {
+ "path": "caret/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/caret.tsx"
+ }
+ ]
+ },
{
"name": "button",
"type": "registry:component",
@@ -243,7 +258,7 @@
"title": "UI Input",
"description": "A text input whose idle/hover/active/typing/invalid state is a pure function of the timeline; the focus ring, border, caret, and value reveal are keyframed presets.",
"dependencies": ["remotion"],
- "registryDependencies": ["@remocn/remocn-ui"],
+ "registryDependencies": ["@remocn/remocn-ui", "@remocn/caret"],
"files": [
{
"path": "input/index.tsx",
diff --git a/registry/remocn/claude-chat/__tests__/claude-chat.test.ts b/registry/remocn/claude-chat/__tests__/claude-chat.test.ts
new file mode 100644
index 00000000..bfec4c43
--- /dev/null
+++ b/registry/remocn/claude-chat/__tests__/claude-chat.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from "vitest";
+
+import { TYPING_CPS, TYPING_START_FRAME, morphProgressAt } from "../index";
+
+const FPS = 30;
+
+describe("typing constants", () => {
+ it("starts typing on a positive frame offset", () => {
+ expect(TYPING_START_FRAME).toBeGreaterThan(0);
+ });
+
+ it("types at a positive characters-per-second rate", () => {
+ expect(TYPING_CPS).toBeGreaterThan(0);
+ });
+});
+
+describe("morphProgressAt", () => {
+ it("is at or near 0 before the start frame", () => {
+ for (let f = 0; f < TYPING_START_FRAME; f++) {
+ const val = morphProgressAt(f, { fps: FPS, speed: 1 });
+ expect(val).toBeLessThanOrEqual(0.001);
+ }
+ });
+
+ it("increases after the start frame", () => {
+ const early = morphProgressAt(TYPING_START_FRAME + 3, {
+ fps: FPS,
+ speed: 1,
+ });
+ const later = morphProgressAt(TYPING_START_FRAME + 12, {
+ fps: FPS,
+ speed: 1,
+ });
+ expect(later).toBeGreaterThan(early);
+ });
+
+ it("stays within [0, 1] for every frame", () => {
+ for (let f = 0; f <= 300; f++) {
+ const val = morphProgressAt(f, { fps: FPS, speed: 1 });
+ expect(val).toBeGreaterThanOrEqual(0);
+ expect(val).toBeLessThanOrEqual(1);
+ }
+ });
+
+ it("approaches 1 for large frames", () => {
+ expect(morphProgressAt(300, { fps: FPS, speed: 1 })).toBeCloseTo(1, 2);
+ });
+});
diff --git a/registry/remocn/claude-chat/config.ts b/registry/remocn/claude-chat/config.ts
new file mode 100644
index 00000000..c8bbd3a9
--- /dev/null
+++ b/registry/remocn/claude-chat/config.ts
@@ -0,0 +1,38 @@
+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";
+
+export const claudeChatConfig: ComponentConfig = {
+ componentName: "ClaudeChat",
+ importPath: "@/components/remocn/claude-chat",
+ controls: {
+ greeting: { type: "text", default: "Back at it, Dima", label: "Greeting" },
+ placeholder: {
+ type: "text",
+ default: "Try: draft an email · summarize a doc · plan your week",
+ label: "Placeholder",
+ },
+ prompt: {
+ type: "text",
+ default: "Draft a launch tweet for our new release",
+ label: "Prompt",
+ },
+ modelName: { type: "text", default: "Opus 4.8", label: "Model" },
+ modelTier: { type: "text", default: "Max", label: "Tier" },
+ accentColor: { type: "color", default: "#D97757", label: "Accent" },
+ theme: {
+ type: "select",
+ default: "light",
+ options: ["light", "dark"],
+ label: "Theme",
+ },
+ background: {
+ type: "select",
+ default: "surface",
+ options: ["surface", "transparent"],
+ label: "Background",
+ },
+ },
+ durationInFrames: 150,
+ fps: FPS,
+ compositionWidth: W,
+ compositionHeight: H,
+};
diff --git a/registry/remocn/claude-chat/index.tsx b/registry/remocn/claude-chat/index.tsx
new file mode 100644
index 00000000..c3a99682
--- /dev/null
+++ b/registry/remocn/claude-chat/index.tsx
@@ -0,0 +1,442 @@
+"use client";
+
+import { loadFont as loadHeadingFont } from "@remotion/google-fonts/Fraunces";
+import { loadFont as loadBodyFont } from "@remotion/google-fonts/Inter";
+import {
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+import { Caret } from "@/components/remocn/caret";
+import { useTypewriter } from "@/lib/remocn-ui";
+
+const { fontFamily: SANS_FAMILY } = loadBodyFont();
+
+export interface ClaudeChatProps {
+ greeting?: string;
+ placeholder?: string;
+ prompt?: string;
+ modelName?: string;
+ modelTier?: string;
+ accentColor?: string;
+ theme?: "light" | "dark";
+ background?: "surface" | "transparent";
+ speed?: number;
+}
+
+interface Theme {
+ page: string;
+ cardBg: string;
+ cardBorder: string;
+ fg: string;
+ fgMuted: string;
+ placeholder: string;
+ iconBtnBorder: string;
+}
+
+export const THEMES: Record<"light" | "dark", Theme> = {
+ light: {
+ page: "#F5F4EF",
+ cardBg: "#FFFFFF",
+ cardBorder: "#E8E5DD",
+ fg: "#1F1E1D",
+ fgMuted: "#73726C",
+ placeholder: "#A3A097",
+ iconBtnBorder: "#E0DDD4",
+ },
+ dark: {
+ page: "#262624",
+ cardBg: "#1F1E1D",
+ cardBorder: "#3A3936",
+ fg: "#F0EEE6",
+ fgMuted: "#9B9892",
+ placeholder: "#73726C",
+ iconBtnBorder: "#3A3936",
+ },
+};
+
+export const TYPING_START_FRAME = 42;
+
+export const TYPING_CPS = 22;
+
+export function morphProgressAt(
+ frame: number,
+ opts: { startFrame?: number; fps: number; speed: number },
+): number {
+ const startFrame = opts.startFrame ?? TYPING_START_FRAME;
+ const value = spring({
+ fps: opts.fps,
+ frame: frame * opts.speed - startFrame,
+ config: { damping: 14, stiffness: 200, mass: 0.6 },
+ });
+ return Math.max(0, Math.min(value, 1));
+}
+
+export function introBounceIn(
+ frame: number,
+ fps: number,
+): { translateY: number; scale: number } {
+ const s = spring({
+ fps,
+ frame,
+ config: { damping: 14, stiffness: 110, mass: 0.7 },
+ });
+ const translateY = interpolate(s, [0, 1], [28, 0]);
+ const scale = interpolate(s, [0, 1], [0.97, 1]);
+ return { translateY, scale };
+}
+
+export function fadeUpAt(
+ frame: number,
+ range: [number, number],
+): { opacity: number; translateY: number } {
+ const opts = {
+ extrapolateLeft: "clamp" as const,
+ extrapolateRight: "clamp" as const,
+ };
+ return {
+ opacity: interpolate(frame, range, [0, 1], opts),
+ translateY: interpolate(frame, range, [12, 0], opts),
+ };
+}
+
+function ChevronDown({ size, color }: { size: number; color: string }) {
+ return (
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
+ <title>Expand</title>
+ <path
+ d="M6 9l6 6 6-6"
+ stroke={color}
+ strokeWidth={2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+function PlusIcon({ size, color }: { size: number; color: string }) {
+ return (
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
+ <title>Add</title>
+ <path
+ d="M12 5v14M5 12h14"
+ stroke={color}
+ strokeWidth={2}
+ strokeLinecap="round"
+ />
+ </svg>
+ );
+}
+
+function MicIcon({ size, color }: { size: number; color: string }) {
+ return (
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
+ <title>Voice input</title>
+ <rect
+ x={9}
+ y={3}
+ width={6}
+ height={11}
+ rx={3}
+ stroke={color}
+ strokeWidth={1.8}
+ />
+ <path
+ d="M5.5 11a6.5 6.5 0 0013 0M12 17.5V21M9 21h6"
+ stroke={color}
+ strokeWidth={1.8}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+function WaveformIcon({ size, color }: { size: number; color: string }) {
+ const bars = [
+ { x: 4, h: 8 },
+ { x: 9, h: 16 },
+ { x: 14, h: 12 },
+ { x: 19, h: 20 },
+ ];
+ return (
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
+ <title>Voice</title>
+ {bars.map((bar) => (
+ <rect
+ key={bar.x}
+ x={bar.x - 1}
+ y={(24 - bar.h) / 2}
+ width={2.4}
+ height={bar.h}
+ rx={1.2}
+ fill={color}
+ />
+ ))}
+ </svg>
+ );
+}
+
+function SendIcon({ size }: { size: number }) {
+ return (
+ <svg width={size} height={size} viewBox="0 0 24 24" fill="none">
+ <title>Send</title>
+ <path
+ d="M12 19V5M12 5l-6 6M12 5l6 6"
+ stroke="#FFFFFF"
+ strokeWidth={2.2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+function IconButton({
+ size,
+ border,
+ children,
+}: {
+ size: number;
+ border: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div
+ style={{
+ width: size,
+ height: size,
+ borderRadius: "100%",
+ border: `1px solid ${border}`,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ flexShrink: 0,
+ }}
+ >
+ {children}
+ </div>
+ );
+}
+
+export function ClaudeChat({
+ placeholder = "Try: draft an email · summarize a doc · plan your week",
+ prompt = "Draft a launch tweet for our new release",
+ modelName = "Opus 4.8",
+ modelTier = "Max",
+ accentColor = "#D97757",
+ theme = "light",
+ background = "surface",
+ speed = 1,
+}: ClaudeChatProps) {
+ const frame = useCurrentFrame();
+ const { width, height, fps } = useVideoConfig();
+ const t = THEMES[theme] ?? THEMES.light;
+
+ const refW = 1280;
+ const refH = 720;
+ const stageScale = Math.min(width / refW, height / refH);
+
+ const tw = useTypewriter(prompt, {
+ cps: TYPING_CPS,
+ speed,
+ startFrame: TYPING_START_FRAME,
+ });
+ const visibleText = tw.text;
+ const showText = tw.count > 0;
+ const morph = morphProgressAt(frame, { fps, speed });
+
+ const intro = introBounceIn(frame * speed, fps);
+ const cardFade = fadeUpAt(frame * speed, [6, 22]);
+
+ const pageBg = background === "transparent" ? "transparent" : t.page;
+
+ const cardWidth = 860;
+ const cardLeft = (refW - cardWidth) / 2;
+ const iconBtnSize = 36;
+ const morphSize = 40;
+
+ return (
+ <AbsoluteFill style={{ background: pageBg }}>
+ <div
+ style={{
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ width: refW,
+ height: refH,
+ transform: `translate(-50%, -50%) scale(${stageScale})`,
+ }}
+ >
+ <div
+ style={{
+ position: "absolute",
+ left: cardLeft,
+ top: 300,
+ width: cardWidth,
+ background: t.cardBg,
+ border: `1px solid ${t.cardBorder}`,
+ borderRadius: 24,
+ boxShadow:
+ theme === "light"
+ ? "0 8px 30px -12px rgba(31,30,29,0.12)"
+ : "0 8px 30px -12px rgba(0,0,0,0.5)",
+ opacity: cardFade.opacity,
+ transform: `translateY(${cardFade.translateY + intro.translateY}px) scale(${intro.scale})`,
+ transformOrigin: "center top",
+ }}
+ >
+ <div
+ style={{
+ padding: "26px 28px",
+ minHeight: 58,
+ fontFamily: SANS_FAMILY,
+ fontSize: 21,
+ lineHeight: 1.3,
+ display: "flex",
+ alignItems: "center",
+ }}
+ >
+ {showText ? (
+ <span style={{ color: t.fg }}>
+ {visibleText}
+ <Caret
+ color={t.fg}
+ blink={!tw.typing}
+ speed={speed}
+ height={24}
+ radius={0}
+ marginLeft={1}
+ style={{
+ verticalAlign: "text-bottom",
+ transform: "translateY(3px)",
+ }}
+ />
+ </span>
+ ) : (
+ <span
+ style={{
+ color: t.placeholder,
+ display: "inline-flex",
+ alignItems: "center",
+ }}
+ >
+ <Caret
+ color={t.fg}
+ blink={!tw.typing}
+ speed={speed}
+ height={24}
+ radius={0}
+ marginLeft={1}
+ style={{
+ verticalAlign: "text-bottom",
+ transform: "translateY(3px)",
+ }}
+ />
+ <span style={{ marginLeft: 2 }}>{placeholder}</span>
+ </span>
+ )}
+ </div>
+
+ <div
+ style={{
+ padding: "14px 18px",
+ display: "flex",
+ justifyContent: "space-between",
+ alignItems: "center",
+ }}
+ >
+ <IconButton size={iconBtnSize} border={t.iconBtnBorder}>
+ <PlusIcon size={20} color={t.fg} />
+ </IconButton>
+
+ <div
+ style={{
+ display: "flex",
+ alignItems: "center",
+ gap: 14,
+ }}
+ >
+ <div
+ style={{
+ display: "flex",
+ alignItems: "center",
+ gap: 7,
+ }}
+ >
+ <span
+ style={{
+ fontFamily: SANS_FAMILY,
+ fontSize: 18,
+ fontWeight: 500,
+ color: t.fg,
+ }}
+ >
+ {modelName}
+ </span>
+ <span
+ style={{
+ fontFamily: SANS_FAMILY,
+ fontSize: 18,
+ fontWeight: 400,
+ color: t.fgMuted,
+ }}
+ >
+ {modelTier}
+ </span>
+ <ChevronDown size={16} color={t.fgMuted} />
+ </div>
+
+ <IconButton size={iconBtnSize} border={t.iconBtnBorder}>
+ <MicIcon size={20} color={t.fg} />
+ </IconButton>
+
+ <div
+ style={{
+ position: "relative",
+ width: morphSize,
+ height: morphSize,
+ flexShrink: 0,
+ }}
+ >
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ borderRadius: "100%",
+ border: `1px solid ${t.iconBtnBorder}`,
+ opacity: 1 - morph,
+ transform: `scale(${1 - 0.1 * morph})`,
+ }}
+ >
+ <WaveformIcon size={22} color={t.fg} />
+ </div>
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ borderRadius: 10,
+ background: accentColor,
+ opacity: morph,
+ transform: `scale(${0.8 + 0.2 * morph})`,
+ }}
+ >
+ <SendIcon size={22} />
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+}
diff --git a/registry/remocn/registry.json b/registry/remocn/registry.json
index a881a0ed..96cd578e 100644
--- a/registry/remocn/registry.json
+++ b/registry/remocn/registry.json
@@ -23,6 +23,7 @@
"title": "Typewriter",
"description": "Character-by-character text reveal with a deterministic blinking cursor.",
"dependencies": ["remotion"],
+ "registryDependencies": ["@remocn/remocn-ui", "@remocn/caret"],
"files": [
{
"path": "typewriter/index.tsx",
@@ -705,6 +706,21 @@
}
]
},
+ {
+ "name": "claude-chat",
+ "type": "registry:component",
+ "title": "Claude Chat",
+ "description": "Animated Claude chat input — types a prompt character-by-character and the waveform button morphs into a terracotta send button the moment text appears. Warm light/dark themes.",
+ "dependencies": ["remotion", "@remotion/google-fonts"],
+ "registryDependencies": ["@remocn/caret", "@remocn/remocn-ui"],
+ "files": [
+ {
+ "path": "claude-chat/index.tsx",
+ "type": "registry:component",
+ "target": "components/remocn/claude-chat.tsx"
+ }
+ ]
+ },
{
"name": "confetti",
"type": "registry:component",
diff --git a/registry/remocn/typewriter/index.tsx b/registry/remocn/typewriter/index.tsx
index 9d280b61..5faacdb1 100644
--- a/registry/remocn/typewriter/index.tsx
+++ b/registry/remocn/typewriter/index.tsx
@@ -1,13 +1,12 @@
"use client";
-import { interpolate, useCurrentFrame, useVideoConfig } from "remotion";
+import { Caret } from "@/components/remocn/caret";
+import { useTypewriter } from "@/lib/remocn-ui";
export interface TypewriterProps {
text: string;
cursor?: boolean;
- /** Typing speed in characters per second. */
charsPerSecond?: number;
- /** Playback speed multiplier (1 = normal, 2 = twice as fast). */
speed?: number;
fontSize?: number;
color?: string;
@@ -27,20 +26,7 @@ export function Typewriter({
fontWeight = 600,
className,
}: TypewriterProps) {
- const frame = useCurrentFrame() * speed;
- const { fps } = useVideoConfig();
-
- const charsToRevealOver = (text.length / charsPerSecond) * fps;
-
- const revealed = Math.floor(
- interpolate(frame, [0, charsToRevealOver], [0, text.length], {
- extrapolateLeft: "clamp",
- extrapolateRight: "clamp",
- }),
- );
-
- const visibleText = text.substring(0, revealed);
- const isCursorVisible = Math.floor((frame / fps) * 2) % 2 === 0;
+ const tw = useTypewriter(text, { cps: charsPerSecond, speed });
return (
<div
@@ -65,17 +51,18 @@ export function Typewriter({
whiteSpace: "pre",
}}
>
- {visibleText}
+ {tw.text}
{cursor && (
- <span
+ <Caret
+ color={cursorColor}
+ blink={!tw.typing}
+ speed={speed}
+ radius={0}
style={{
- display: "inline-block",
width: "0.08em",
height: "1em",
marginLeft: "0.04em",
verticalAlign: "text-bottom",
- background: cursorColor,
- opacity: isCursorVisible ? 1 : 0,
}}
/>
)}