Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
faet: added value-swap animation
dev_wandry2b94ca553bc3
diff --git a/components/docs/examples/value-swap-example.tsx b/components/docs/examples/value-swap-example.tsxnew file mode 100644index 00000000..4aff7325--- /dev/null+++ b/components/docs/examples/value-swap-example.tsx@@ -0,0 +1,57 @@+"use client";++import { AbsoluteFill } from "remotion";+import { ValueSwap } from "@/registry/remocn/value-swap";++const FONT_FAMILY =+ "var(--font-geist-sans), -apple-system, BlinkMacSystemFont, sans-serif";++export function ValueSwapExampleScene({+ duration,+ distance,+ direction,+}: {+ duration?: number;+ distance?: number;+ direction?: "up" | "down";+}) {+ return (+ <AbsoluteFill+ style={{+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span style={{ fontFamily: FONT_FAMILY, fontSize: 40, fontWeight: 600, color: "#f2f2f2" }}>+ <ValueSwap+ values={["Draft", "In review", "Shipped"]}+ at={[30, 60]}+ duration={duration}+ distance={distance}+ direction={direction}+ />+ </span>+ </AbsoluteFill>+ );+}++export const valueSwapExampleCode = (+ values: Record<string, unknown>,+): string => {+ const duration = (values.duration as number) ?? 10;+ const distance = (values.distance as number) ?? 12;+ const direction = (values.direction as string) ?? "up";+ return `import { ValueSwap } from "@/components/remocn/value-swap";++export const MyScene = () => (+ <span style={{ fontSize: 40, fontWeight: 600 }}>+ <ValueSwap+ values={["Draft", "In review", "Shipped"]}+ at={[30, 60]}+ duration={${duration}}+ distance={${distance}}+ direction="${direction}"+ />+ </span>+);`;+};diff --git a/config/site.ts b/config/site.tsindex 03837a50..7a0860c2 100644--- a/config/site.ts+++ b/config/site.ts@@ -67,6 +67,7 @@ export const NEW_BADGE_PATHS = new Set<string>(["/docs/transitions/zoom-blur","/docs/layout/drift","/docs/typography/rolodex-flip",+ "/docs/typography/value-swap",]);export const FOOTER_NAV: NavLink[] = [diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex c93206c9..4e71e25b 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -162,6 +162,12 @@ Text effects, reveals, and kinetic type.status: "stable",href: "/docs/typography/rolodex-flip",},+ {+ name: "ValueSwap",+ description: "Swap a value in place with a vertical slide so the layout never shifts",+ status: "stable",+ href: "/docs/typography/value-swap",+ },]}/>diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex e3aa3a18..5db938f1 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -31,6 +31,7 @@"number-wheel","rolling-number","rolodex-flip",+ "value-swap","infinite-marquee","perspective-marquee","matrix-decode",diff --git a/content/docs/typography/rolodex-flip.mdx b/content/docs/typography/rolodex-flip.mdxindex 33d0878a..6472eea1 100644--- a/content/docs/typography/rolodex-flip.mdx+++ b/content/docs/typography/rolodex-flip.mdx@@ -28,7 +28,7 @@ export const MyScene = () => (The sizer uses the longest item by character count as real hidden text, so it works in any font. In a proportional font two equal-length strings can differ in width, so if your values are the same length put the visually widest one last — or anywhere, it just needs to be in the list.-`slot-machine-roll` and `number-wheel` are numeric reels, `per-word-crossfade` is a flat opacity swap — reach for `RolodexFlip` when arbitrary strings should cycle with physical depth at a fixed width.+`slot-machine-roll` and `number-wheel` are numeric reels, `per-word-crossfade` is a flat opacity swap, and `value-swap` slides values vertically at explicit frames — reach for `RolodexFlip` when arbitrary strings should cycle with physical depth at a fixed width.## Propsdiff --git a/content/docs/typography/value-swap.mdx b/content/docs/typography/value-swap.mdxnew file mode 100644index 00000000..83c955e6--- /dev/null+++ b/content/docs/typography/value-swap.mdx@@ -0,0 +1,83 @@+---+title: Value Swap+description: Swap a value in place with a vertical slide so the layout never shifts+---++<ComponentPreview name="value-swap" />++## Installation++<InstallBlock name="value-swap" />++## Usage++`ValueSwap` renders an inline `span` that inherits the surrounding typography and swaps its content at the exact frames you pass in `at` — the outgoing value slides up and fades as the incoming one rides in from below, one continuous upward motion, while an invisible sizer holds the width of the longest value so the layout never shifts. It is the string analog of `rolling-number` for arbitrary text.++```tsx+import { ValueSwap } from "@/components/remocn/value-swap";++export const MyScene = () => (+ <span style={{ fontSize: 40, fontWeight: 600 }}>+ <ValueSwap values={["$99", "$199"]} at={45} />+ </span>+);+```++Chain more than one swap by passing an array of frames, one per transition:++```tsx+<ValueSwap values={["Draft", "In review", "Shipped"]} at={[30, 60]} />+```++A tight before/after pair reads best with a snappier swap — try `duration={9} distance={9}`. `direction="down"` mirrors the motion for downward narratives — a price dropping, a rank falling.++`rolodex-flip` is a 3D card flip with its own rhythm (`interval`) — reach for it when values cycle as a montage; `ValueSwap` is a flat vertical slide at explicit frames — reach for it for a point change (before → after, a status or price flip); `rolling-number` animates numeric digits individually.++## Props++<PropsTable+ rows={[+ {+ name: "values",+ type: "string[]",+ default: "—",+ description: "Values in order. Two or more.",+ },+ {+ name: "at",+ type: "number | number[]",+ default: "—",+ description: "Frame of each swap. A number for a pair, an array of length values.length - 1 for a chain.",+ },+ {+ name: "duration",+ type: "number",+ default: "10",+ description: "Frames per swap.",+ },+ {+ name: "distance",+ type: "number",+ default: "12",+ description: "Vertical travel in pixels.",+ },+ {+ name: "direction",+ type: '"up" | "down"',+ default: '"up"',+ description: "Direction of the through-motion.",+ },+ {+ name: "className",+ type: "string",+ default: "—",+ description: "Passed to the wrapper span.",+ },+ {+ name: "style",+ type: "CSSProperties",+ default: "—",+ description: "Merged onto the wrapper span.",+ },+ ]}+/>diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 1bd595ae..13891867 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -87,6 +87,7 @@ import { topDownLettersConfig } from "@/registry/remocn/top-down-letters/config"import { trackingInConfig } from "@/registry/remocn/tracking-in/config";import { typewriterConfig } from "@/registry/remocn/typewriter/config";import { v0Config } from "@/registry/remocn/v0/config";+import { valueSwapConfig } from "@/registry/remocn/value-swap/config";import { warpDissolveConfig } from "@/registry/remocn/warp-dissolve/config";import { waveWipeConfig } from "@/registry/remocn/wave-wipe/config";import { whipPanConfig } from "@/registry/remocn/whip-pan/config";@@ -710,6 +711,13 @@ const registry: Record<string, RegistryEntry> = {})),config: rolodexFlipConfig,},+ "value-swap": {+ load: () =>+ import("@/components/docs/examples/value-swap-example").then((m) => ({+ default: m.ValueSwapExampleScene,+ })),+ config: valueSwapConfig,+ },"x-follow-card": {load: () =>import("@/registry/remocn/x-follow-card").then((m) => ({diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex e260d704..d0bebc54 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -894,6 +894,20 @@}]},+ {+ "name": "value-swap",+ "type": "registry:component",+ "title": "Value Swap",+ "description": "Swaps a value in place with a vertical slide — the old value exits up as the new one enters from below while an invisible sizer keeps the width stable.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "value-swap/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/value-swap.tsx"+ }+ ]+ },{"name": "chat-to-preview-layout","type": "registry:component",diff --git a/registry/remocn/value-swap/config.ts b/registry/remocn/value-swap/config.tsnew file mode 100644index 00000000..d6333773--- /dev/null+++ b/registry/remocn/value-swap/config.ts@@ -0,0 +1,37 @@+import { valueSwapExampleCode } from "@/components/docs/examples/value-swap-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const valueSwapConfig: ComponentConfig = {+ componentName: "ValueSwap",+ importPath: "@/components/remocn/value-swap",+ controls: {+ duration: {+ type: "number",+ default: 10,+ min: 4,+ max: 24,+ step: 1,+ label: "Duration",+ },+ distance: {+ type: "number",+ default: 12,+ min: 4,+ max: 32,+ step: 2,+ label: "Distance",+ },+ direction: {+ type: "select",+ default: "up",+ options: ["up", "down"],+ label: "Direction",+ },+ },+ durationInFrames: 100,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#141318" },+ snippet: valueSwapExampleCode,+};diff --git a/registry/remocn/value-swap/index.tsx b/registry/remocn/value-swap/index.tsxnew file mode 100644index 00000000..9f11b92f--- /dev/null+++ b/registry/remocn/value-swap/index.tsx@@ -0,0 +1,75 @@+"use client";++import type React from "react";+import { Easing, interpolate, useCurrentFrame } from "remotion";++const clampOpts = {+ extrapolateLeft: "clamp" as const,+ extrapolateRight: "clamp" as const,+};++export interface ValueSwapProps {+ values: string[];+ at: number | number[];+ duration?: number;+ distance?: number;+ direction?: "up" | "down";+ className?: string;+ style?: React.CSSProperties;+}++export function ValueSwap({+ values,+ at,+ duration = 10,+ distance = 12,+ direction = "up",+ className,+ style,+}: ValueSwapProps) {+ const frame = useCurrentFrame();+ const ats = Array.isArray(at) ? at : [at];+ const d = direction === "down" ? -distance : distance;+ const count = Math.min(values.length, ats.length + 1);+ const rendered = values.slice(0, count);+ const sizer = rendered.reduce((a, b) => (b.length > a.length ? b : a), "");+ const swapP = (start: number) =>+ interpolate(frame, [start, start + duration], [0, 1], {+ ...clampOpts,+ easing: Easing.inOut(Easing.cubic),+ });+ return (+ <span+ className={className}+ style={{+ position: "relative",+ display: "inline-block",+ ...style,+ }}+ >+ <span style={{ visibility: "hidden" }}>{sizer}</span>+ {rendered.map((value, i) => {+ const pIn = i > 0 ? swapP(ats[i - 1]) : 1;+ const pOut = i < count - 1 ? swapP(ats[i]) : 0;+ const opacity = pIn * (1 - pOut);+ if (opacity <= 0.001) return null;+ const y = (1 - pIn) * d + pOut * -d;+ return (+ <span+ key={`${i}-${value}`}+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ whiteSpace: "nowrap",+ opacity,+ transform: `translateY(${y}px)`,+ }}+ >+ {value}+ </span>+ );+ })}+ </span>+ );+}