Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: rolodex flip
dev_wandry31a56a637094
diff --git a/components/docs/examples/rolodex-flip-example.tsx b/components/docs/examples/rolodex-flip-example.tsxnew file mode 100644index 00000000..269fd992--- /dev/null+++ b/components/docs/examples/rolodex-flip-example.tsx@@ -0,0 +1,55 @@+"use client";++import { AbsoluteFill } from "remotion";+import { RolodexFlip } from "@/registry/remocn/rolodex-flip";++const MONO_FONT =+ "var(--font-geist-mono), ui-monospace, SFMono-Regular, Menlo, monospace";++export function RolodexFlipExampleScene({+ interval,+ flipDuration,+}: {+ interval?: number;+ flipDuration?: number;+}) {+ return (+ <AbsoluteFill+ style={{+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <span style={{ fontFamily: MONO_FONT, fontSize: 36 }}>+ <span style={{ color: "#6f6c7a" }}>$ </span>+ <span style={{ color: "#8a8794" }}>npx shadcn add </span>+ <span style={{ color: "#f2f2f2" }}>+ <RolodexFlip+ items={["button", "dialog", "command", "tabs", "chart-area"]}+ interval={interval}+ flipDuration={flipDuration}+ />+ </span>+ </span>+ </AbsoluteFill>+ );+}++export const rolodexFlipExampleCode = (+ values: Record<string, unknown>,+): string => {+ const interval = (values.interval as number) ?? 20;+ const flipDuration = (values.flipDuration as number) ?? 10;+ return `import { RolodexFlip } from "@/components/remocn/rolodex-flip";++export const MyScene = () => (+ <span style={{ fontFamily: "monospace", fontSize: 36 }}>+ $ npx shadcn add{" "}+ <RolodexFlip+ items={["button", "dialog", "command", "tabs", "chart-area"]}+ interval={${interval}}+ flipDuration={${flipDuration}}+ />+ </span>+);`;+};diff --git a/config/site.ts b/config/site.tsindex 17606f69..03837a50 100644--- a/config/site.ts+++ b/config/site.ts@@ -66,6 +66,7 @@ export const NEW_BADGE_PATHS = new Set<string>(["/docs/transitions/focus-pull","/docs/transitions/zoom-blur","/docs/layout/drift",+ "/docs/typography/rolodex-flip",]);export const FOOTER_NAV: NavLink[] = [diff --git a/content/docs/components.mdx b/content/docs/components.mdxindex 00d43e18..c93206c9 100644--- a/content/docs/components.mdx+++ b/content/docs/components.mdx@@ -156,6 +156,12 @@ Text effects, reveals, and kinetic type.status: "stable",href: "/docs/typography/slot-machine-roll",},+ {+ name: "RolodexFlip",+ description: "Cycle a word through a list of values with a 3D rolodex card flip",+ status: "stable",+ href: "/docs/typography/rolodex-flip",+ },]}/>diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex 6d16e0d8..e3aa3a18 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -30,6 +30,7 @@"slot-machine-roll","number-wheel","rolling-number",+ "rolodex-flip","infinite-marquee","perspective-marquee","matrix-decode",diff --git a/content/docs/typography/rolodex-flip.mdx b/content/docs/typography/rolodex-flip.mdxnew file mode 100644index 00000000..33d0878a--- /dev/null+++ b/content/docs/typography/rolodex-flip.mdx@@ -0,0 +1,74 @@+---+title: Rolodex Flip+description: Cycle a word through a list of values with a 3D rolodex card flip+---++<ComponentPreview name="rolodex-flip" />++## Installation++<InstallBlock name="rolodex-flip" />++## Usage++`RolodexFlip` renders an inline `span` and inherits the surrounding typography — drop it into the middle of a line and it flips through `items` while the rest of the line stays perfectly still: the outgoing value tips up and away, the incoming one turns in from below half a flip later, and an invisible sizer holds the width and baseline of the longest value. The first value is visible from the start and the last one stays for the rest of the scene.++```tsx+import { RolodexFlip } from "@/components/remocn/rolodex-flip";++export const MyScene = () => (+ <span style={{ fontFamily: "monospace", fontSize: 36 }}>+ $ npx shadcn add{" "}+ <RolodexFlip items={["button", "dialog", "command", "tabs", "chart-area"]} />+ </span>+);+```++## Sizing++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.++## Props++<PropsTable+ rows={[+ {+ name: "items",+ type: "string[]",+ default: "—",+ description: "Values shown in order. The last one stays.",+ },+ {+ name: "from",+ type: "number",+ default: "0",+ description: "Frame of the first flip.",+ },+ {+ name: "interval",+ type: "number",+ default: "20",+ description: "Frames each value holds before flipping.",+ },+ {+ name: "flipDuration",+ type: "number",+ default: "10",+ description: "Length of the flip itself in frames.",+ },+ {+ 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 735a3b99..1bd595ae 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -47,6 +47,7 @@ import { pushThroughConfig } from "@/registry/remocn/push-through/config";import { rgbGlitchTextConfig } from "@/registry/remocn/rgb-glitch-text/config";import { rippleZoomConfig } from "@/registry/remocn/ripple-zoom/config";import { rollingNumberConfig } from "@/registry/remocn/rolling-number/config";+import { rolodexFlipConfig } from "@/registry/remocn/rolodex-flip/config";import { scaleDownFadeConfig } from "@/registry/remocn/scale-down-fade/config";import { shaderColorPanelsConfig } from "@/registry/remocn/shader-color-panels/config";import { shaderDitheringConfig } from "@/registry/remocn/shader-dithering/config";@@ -702,6 +703,13 @@ const registry: Record<string, RegistryEntry> = {})),config: rollingNumberConfig,},+ "rolodex-flip": {+ load: () =>+ import("@/components/docs/examples/rolodex-flip-example").then((m) => ({+ default: m.RolodexFlipExampleScene,+ })),+ config: rolodexFlipConfig,+ },"x-follow-card": {load: () =>import("@/registry/remocn/x-follow-card").then((m) => ({diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 5a0125c8..e260d704 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -880,6 +880,20 @@}]},+ {+ "name": "rolodex-flip",+ "type": "registry:component",+ "title": "Rolodex Flip",+ "description": "Cycles a word through a list of values with a 3D rolodex card flip while an invisible sizer keeps the line width and baseline stable.",+ "dependencies": ["remotion"],+ "files": [+ {+ "path": "rolodex-flip/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/rolodex-flip.tsx"+ }+ ]+ },{"name": "chat-to-preview-layout","type": "registry:component",diff --git a/registry/remocn/rolodex-flip/config.ts b/registry/remocn/rolodex-flip/config.tsnew file mode 100644index 00000000..a5fb3469--- /dev/null+++ b/registry/remocn/rolodex-flip/config.ts@@ -0,0 +1,31 @@+import { rolodexFlipExampleCode } from "@/components/docs/examples/rolodex-flip-example";+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const rolodexFlipConfig: ComponentConfig = {+ componentName: "RolodexFlip",+ importPath: "@/components/remocn/rolodex-flip",+ controls: {+ interval: {+ type: "number",+ default: 20,+ min: 10,+ max: 40,+ step: 2,+ label: "Interval",+ },+ flipDuration: {+ type: "number",+ default: 10,+ min: 4,+ max: 20,+ step: 1,+ label: "Flip duration",+ },+ },+ durationInFrames: 110,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#141318" },+ snippet: rolodexFlipExampleCode,+};diff --git a/registry/remocn/rolodex-flip/index.tsx b/registry/remocn/rolodex-flip/index.tsxnew file mode 100644index 00000000..5b5c2985--- /dev/null+++ b/registry/remocn/rolodex-flip/index.tsx@@ -0,0 +1,94 @@+"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 RolodexFlipProps {+ items: string[];+ from?: number;+ interval?: number;+ flipDuration?: number;+ className?: string;+ style?: React.CSSProperties;+}++export function RolodexFlip({+ items,+ from = 0,+ interval = 20,+ flipDuration = 10,+ className,+ style,+}: RolodexFlipProps) {+ const frame = useCurrentFrame();+ const sizer = items.reduce((a, b) => (b.length > a.length ? b : a), "");+ return (+ <span+ className={className}+ style={{+ position: "relative",+ display: "inline-block",+ perspective: 420,+ verticalAlign: "bottom",+ ...style,+ }}+ >+ <span style={{ visibility: "hidden" }}>{sizer}</span>+ {items.map((item, i) => {+ const inStart = from + (i - 1) * interval + flipDuration / 2;+ const outStart = from + i * interval;++ let rotate = 0;+ let y = 0;+ let opacity = 1;++ if (i > 0) {+ const pIn = interpolate(+ frame,+ [inStart, inStart + flipDuration],+ [0, 1],+ { ...clampOpts, easing: Easing.out(Easing.cubic) },+ );+ rotate = (1 - pIn) * -85;+ y = (1 - pIn) * 20;+ opacity = pIn;+ }+ if (i < items.length - 1) {+ const pOut = interpolate(+ frame,+ [outStart, outStart + flipDuration],+ [0, 1],+ { ...clampOpts, easing: Easing.in(Easing.cubic) },+ );+ rotate += pOut * 85;+ y -= pOut * 20;+ opacity *= 1 - pOut;+ }+ if (opacity <= 0.001) return null;++ return (+ <span+ key={`${i}-${item}`}+ style={{+ position: "absolute",+ left: 0,+ top: 0,+ whiteSpace: "nowrap",+ opacity,+ transform: `translateY(${y}px) rotateX(${rotate}deg)`,+ transformOrigin: "50% 50%",+ backfaceVisibility: "hidden",+ }}+ >+ {item}+ </span>+ );+ })}+ </span>+ );+}