Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
feat: added new component - rolling number
dev_wandryb1de3411058e
diff --git a/bun.lock b/bun.lockindex b6212f89..6cabe959 100644--- a/bun.lock+++ b/bun.lock@@ -11,6 +11,7 @@"@react-three/postprocessing": "^3.0.4","@remotion/bundler": "4.0.473","@remotion/google-fonts": "4.0.473",+ "@remotion/motion-blur": "4.0.473","@remotion/player": "4.0.473","@remotion/renderer": "4.0.473","class-variance-authority": "^0.7.1",@@ -448,6 +449,8 @@"@remotion/media-utils": ["@remotion/[email protected]", "", { "dependencies": { "mediabunny": "1.45.0", "remotion": "4.0.473" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-f4Ip10pkawlUBTunE++DZ6J/TrPtKalkxoTx7qQGBlhz3BcWRK7AbEGouZtcAmkLFVxq80hpH/1cBFOMF6FVfA=="],+ "@remotion/motion-blur": ["@remotion/[email protected]", "", { "dependencies": { "remotion": "4.0.473" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-SmeTVJT0sYrpKvaWKTEfgAdQRGaR/LqbHWMe9bQhtSQasBxwZ44v9m8d5u6chZ90SCYYI99WL4TaZleqjzaCiQ=="],+"@remotion/player": ["@remotion/[email protected]", "", { "dependencies": { "remotion": "4.0.473" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-giJ8cIQEdVxftpcX4m+9jWYCbIvpcdKRGVUc3ownxYEsJ30WUSP2+TuQ6aqqLXFAfwhY/SdBVLfopylh3BgMXA=="],"@remotion/renderer": ["@remotion/[email protected]", "", { "dependencies": { "@remotion/licensing": "4.0.473", "@remotion/streaming": "4.0.473", "execa": "5.1.1", "remotion": "4.0.473", "source-map": "0.8.0-beta.0", "ws": "8.20.1" }, "optionalDependencies": { "@remotion/compositor-darwin-arm64": "4.0.473", "@remotion/compositor-darwin-x64": "4.0.473", "@remotion/compositor-linux-arm64-gnu": "4.0.473", "@remotion/compositor-linux-arm64-musl": "4.0.473", "@remotion/compositor-linux-x64-gnu": "4.0.473", "@remotion/compositor-linux-x64-musl": "4.0.473", "@remotion/compositor-win32-x64-msvc": "4.0.473" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-WOOmT38O3ax78oDIE75FnsDi8eUMBKOdnqiXU3NeArNoA/xQZv7yDUgV3e1SxFaCHS7IbWHIATXUfVgS8TIXBA=="],diff --git a/components/docs/examples/blocks/index.tsx b/components/docs/examples/blocks/index.tsxindex 05ac742f..0aa82f05 100644--- a/components/docs/examples/blocks/index.tsx+++ b/components/docs/examples/blocks/index.tsx@@ -31,6 +31,10 @@ import {backdropImageCode,backdropLiveCode,} from "../backdrop-variants";+import {+ RollingNumberConfettiExampleScene,+ rollingNumberConfettiExampleCode,+} from "../rolling-number-confetti-example";/*** Blocks scene registry — parallel to the ui-tier `examples` map@@ -146,6 +150,15 @@ export const blockExamples: Record<string, BlockExampleEntry> = {width: W,height: H,},+ "rolling-number-confetti": {+ Component: RollingNumberConfettiExampleScene,+ code: rollingNumberConfettiExampleCode,+ durationInFrames: 210,+ fps: FPS,+ width: W,+ height: H,+ previewBackdrop: { type: "color", value: "#ffffff" },+ },};/**@@ -168,6 +181,7 @@ export const BLOCK_SCENE_META: Record<"backdrop-gradient": { code: backdropGradientCode },"backdrop-image": { code: backdropImageCode },"backdrop-live": { code: backdropLiveCode },+ "rolling-number-confetti": { code: rollingNumberConfettiExampleCode },};// Re-export so block entries can reference the shared timing constants withoutdiff --git a/components/docs/examples/rolling-number-confetti-example.tsx b/components/docs/examples/rolling-number-confetti-example.tsxnew file mode 100644index 00000000..185c17e1--- /dev/null+++ b/components/docs/examples/rolling-number-confetti-example.tsx@@ -0,0 +1,41 @@+"use client";++import { Backdrop } from "@/registry/remocn/backdrop";+import { Confetti } from "@/registry/remocn/confetti";+import { RollingNumber } from "@/registry/remocn/rolling-number";++export const RollingNumberConfettiExampleScene = () => (+ <Backdrop fill={{ type: "color", value: "#ffffff" }} shadow="0">+ <RollingNumber from={0} to={24813} fontSize={120} />+ <Confetti+ startFrame={168}+ originY={0.5}+ particleCount={160}+ lifetime={42}+ seed={1}+ />+ </Backdrop>+);++export const rollingNumberConfettiExampleCode = `import { Composition } from "remotion";+import { Backdrop } from "@/components/remocn/backdrop";+import { Confetti } from "@/components/remocn/confetti";+import { RollingNumber } from "@/components/remocn/rolling-number";++const RollingNumberConfetti = () => (+ <Backdrop fill={{ type: "color", value: "#ffffff" }} shadow="0">+ <RollingNumber from={0} to={24813} fontSize={120} />+ <Confetti startFrame={168} originY={0.5} particleCount={160} lifetime={42} seed={1} />+ </Backdrop>+);++export const RemotionRoot = () => (+ <Composition+ id="RollingNumberConfetti"+ component={RollingNumberConfetti}+ durationInFrames={210}+ fps={30}+ width={1280}+ height={720}+ />+);`;diff --git a/config/site.ts b/config/site.tsindex c0d5ee3e..0a35cabb 100644--- a/config/site.ts+++ b/config/site.ts@@ -51,6 +51,7 @@ export const NEW_BADGE_PATHS = new Set<string>(["/docs/ai/opencode","/docs/layout/backdrop","/docs/typography/number-wheel",+ "/docs/typography/rolling-number",]);export const FOOTER_NAV: NavLink[] = [diff --git a/content/docs/typography/meta.json b/content/docs/typography/meta.jsonindex bf556fbb..cb5a791f 100644--- a/content/docs/typography/meta.json+++ b/content/docs/typography/meta.json@@ -13,6 +13,7 @@"typewriter","slot-machine-roll","number-wheel",+ "rolling-number","infinite-marquee","perspective-marquee","matrix-decode",diff --git a/content/docs/typography/rolling-number.mdx b/content/docs/typography/rolling-number.mdxnew file mode 100644index 00000000..d8157d70--- /dev/null+++ b/content/docs/typography/rolling-number.mdx@@ -0,0 +1,106 @@+---+title: Rolling Number+description: Odometer where every place rolls at its own speed, new places rising into view, settling exactly on the target value+---++<ComponentPreview name="rolling-number" />++## Installation++<InstallBlock name="rolling-number" />++## Usage++```tsx+// src/Root.tsx+import { Composition } from "remotion";+import { RollingNumber } from "@/components/remocn/rolling-number";++const RollingNumberScene = () => (+ <RollingNumber from={0} to={24813} fontSize={120} />+);++export const RemotionRoot = () => (+ <Composition+ id="RollingNumber"+ component={RollingNumberScene}+ durationInFrames={150}+ fps={30}+ width={1280}+ height={720}+ />+);+```++## Props++<PropsTable+ rows={[+ {+ name: "from",+ type: "number",+ default: "0",+ description: "Starting value. Direction is inferred from whether to is greater or less than from.",+ },+ {+ name: "to",+ type: "number",+ default: "24813",+ description: "Target value the number settles on, landing pixel-exact on every place.",+ },+ {+ name: "fontSize",+ type: "number",+ default: "120",+ description: "Font size in pixels",+ },+ {+ name: "color",+ type: "string",+ default: "\"#171717\"",+ description: "Text color",+ },+ {+ name: "speed",+ type: "number",+ default: "1",+ description: "Multiplier for animation speed",+ },+ ]}+/>++Every place rolls at once, each travelling roughly ten times as far as the place to its left, so the ones spin fastest and the highest place barely turns. As the number grows past each power of ten, the new leading place rises gently into view rather than popping in, and the whole number settles pixel-exact on the target. All values must be integers and non-negative.++## Count Up++Rolls upward from 0 to 24813:++```tsx+import { Backdrop } from "@/components/remocn/backdrop";+import { RollingNumber } from "@/components/remocn/rolling-number";++<Backdrop fill={{ type: "color", value: "#ffffff" }}>+ <RollingNumber from={0} to={24813} fontSize={120} />+</Backdrop>+```++## Count Down++Rolls downward from 24813 to 0:++```tsx+import { Backdrop } from "@/components/remocn/backdrop";+import { RollingNumber } from "@/components/remocn/rolling-number";++<Backdrop fill={{ type: "color", value: "#ffffff" }}>+ <RollingNumber from={24813} to={0} fontSize={120} />+</Backdrop>+```++## With Confetti++Pair it with [Confetti](/docs/effects/confetti) to celebrate the moment the number lands — fire the burst on the frame the count settles (`durationInFrames × 0.8`):++<BlockPreview name="rolling-number-confetti" />++`Confetti` is a separate component — add it with `npx shadcn add @remocn/confetti`. Both render as full-canvas overlays, so the burst layers cleanly over the number. Keep `startFrame` equal to `durationInFrames × 0.8` (where the count settles): this 210-frame composition settles at frame 168, leaving the 42-frame `lifetime` room to play out before it loops.diff --git a/registry/__index__.tsx b/registry/__index__.tsxindex 0a71f204..0df72221 100644--- a/registry/__index__.tsx+++ b/registry/__index__.tsx@@ -73,6 +73,8 @@ import { ProgressSteps } from "@/registry/remocn/progress-steps";import { progressStepsConfig } from "@/registry/remocn/progress-steps/config";import { RGBGlitchText } from "@/registry/remocn/rgb-glitch-text";import { rgbGlitchTextConfig } from "@/registry/remocn/rgb-glitch-text/config";+import { RollingNumber } from "@/registry/remocn/rolling-number";+import { rollingNumberConfig } from "@/registry/remocn/rolling-number/config";import { ShimmerSweep } from "@/registry/remocn/shimmer-sweep";import { shimmerSweepConfig } from "@/registry/remocn/shimmer-sweep/config";import { SimulatedCursor } from "@/registry/remocn/simulated-cursor";@@ -338,6 +340,7 @@ const registry: Record<string, RegistryEntry> = {},"github-stars": { Component: GitHubStars, config: githubStarsConfig },"number-wheel": { Component: NumberWheel, config: numberWheelConfig },+ "rolling-number": { Component: RollingNumber, config: rollingNumberConfig },"x-follow-card": { Component: XFollowCard, config: xFollowCardConfig },"x-followers-overview": {Component: XFollowersOverview,@@ -465,6 +468,18 @@ if (numberWheel) {};}+const rollingNumber = registry["rolling-number"];+if (rollingNumber) {+ rollingNumber.config.controls.speed = {+ type: "number",+ default: 1,+ min: 1,+ max: 4,+ step: 0.25,+ label: "Speed",+ };+}+const xFollowCard = registry["x-follow-card"];if (xFollowCard) {xFollowCard.config.controls.speed = {diff --git a/registry/remocn/registry.json b/registry/remocn/registry.jsonindex 63805263..530a96fe 100644--- a/registry/remocn/registry.json+++ b/registry/remocn/registry.json@@ -797,6 +797,23 @@}]},+ {+ "name": "rolling-number",+ "type": "registry:component",+ "title": "Rolling Number",+ "description": "Odometer where every place rolls at its own speed, new places rising into view, settling exactly on the target value.",+ "dependencies": [+ "remotion",+ "@remotion/google-fonts"+ ],+ "files": [+ {+ "path": "rolling-number/index.tsx",+ "type": "registry:component",+ "target": "components/remocn/rolling-number.tsx"+ }+ ]+ },{"name": "x-follow-card","type": "registry:component",diff --git a/registry/remocn/rolling-number/config.ts b/registry/remocn/rolling-number/config.tsnew file mode 100644index 00000000..b0aa0dce--- /dev/null+++ b/registry/remocn/rolling-number/config.ts@@ -0,0 +1,38 @@+import { type ComponentConfig, FPS, H, W } from "@/lib/customizer-config";++export const rollingNumberConfig: ComponentConfig = {+ componentName: "RollingNumber",+ importPath: "@/components/remocn/rolling-number",+ controls: {+ from: {+ type: "number",+ default: 0,+ min: 0,+ max: 1000000,+ step: 1,+ label: "From",+ },+ to: {+ type: "number",+ default: 24813,+ min: 0,+ max: 1000000,+ step: 1,+ label: "To",+ },+ fontSize: {+ type: "number",+ default: 120,+ min: 24,+ max: 280,+ step: 4,+ label: "Font size",+ },+ color: { type: "color", default: "#171717", label: "Color" },+ },+ durationInFrames: 150,+ fps: FPS,+ compositionWidth: W,+ compositionHeight: H,+ previewBackdrop: { type: "color", value: "#ffffff" },+};diff --git a/registry/remocn/rolling-number/index.tsx b/registry/remocn/rolling-number/index.tsxnew file mode 100644index 00000000..56ffceec--- /dev/null+++ b/registry/remocn/rolling-number/index.tsx@@ -0,0 +1,190 @@+"use client";++import type React from "react";+import { loadFont as loadMono } from "@remotion/google-fonts/JetBrainsMono";+import {+ AbsoluteFill,+ Easing,+ interpolate,+ useCurrentFrame,+ useVideoConfig,+} from "remotion";++const { fontFamily: MONO_FAMILY } = loadMono();++export interface RollingNumberProps {+ from?: number;+ to?: number;+ fontSize?: number;+ color?: string;+ speed?: number;+}++const COUNT_PORTION = 0.8;+const COUNT_EASING = Easing.out(Easing.poly(4));+const REVEAL_BAND = 0.4;+const REVEAL_EASING = Easing.inOut(Easing.sin);+const REVEAL_RISE_EM = 0.32;++function easedProgress(+ frame: number,+ speed: number,+ durationInFrames: number,+): number {+ return interpolate(+ frame * speed,+ [0, durationInFrames * COUNT_PORTION],+ [0, 1],+ {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: COUNT_EASING,+ },+ );+}++function placeTravel(start: number, end: number, place: number): number {+ const pow = 10 ** place;+ const up = end >= start;+ const diff = Math.abs(end - start);+ const startDigit = Math.floor(start / pow) % 10;+ const finalDigit = Math.floor(end / pow) % 10;+ const fullTurns = Math.floor(diff / (pow * 10));+ const stepDelta = up+ ? (finalDigit - startDigit + 10) % 10+ : (startDigit - finalDigit + 10) % 10;+ const magnitude = fullTurns * 10 + stepDelta;+ return up ? magnitude : -magnitude;+}++function placeReveal(current: number, place: number): number {+ if (place === 0) return 1;+ const threshold = 10 ** place;+ return interpolate(current, [threshold * REVEAL_BAND, threshold], [0, 1], {+ extrapolateLeft: "clamp",+ extrapolateRight: "clamp",+ easing: REVEAL_EASING,+ });+}++function wrap10(value: number): number {+ return ((value % 10) + 10) % 10;+}++function DigitColumn({+ value,+ fontSize,+ reveal,+}: {+ value: number;+ fontSize: number;+ reveal: number;+}) {+ const cellHeight = fontSize * 1.1;+ return (+ <span+ style={{+ display: "inline-block",+ overflow: "hidden",+ height: cellHeight,+ width: "0.62em",+ verticalAlign: "top",+ textAlign: "center",+ opacity: reveal,+ transform: `translateY(${(1 - reveal) * fontSize * REVEAL_RISE_EM}px)`,+ }}+ >+ <span+ style={{+ display: "flex",+ flexDirection: "column",+ transform: `translateY(${-value * cellHeight}px)`,+ }}+ >+ {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0].map((d, i) => (+ <span+ key={i}+ style={{ height: cellHeight, lineHeight: `${cellHeight}px` }}+ >+ {d}+ </span>+ ))}+ </span>+ </span>+ );+}++export function RollingNumber({+ from = 0,+ to = 24813,+ fontSize = 120,+ color = "#171717",+ speed = 1,+}: RollingNumberProps) {+ const frame = useCurrentFrame();+ const { durationInFrames } = useVideoConfig();++ const start = Math.max(0, Math.round(from));+ const end = Math.max(0, Math.round(to));++ const e = easedProgress(frame, speed, durationInFrames);+ const current = start + e * (end - start);++ const maxVal = Math.max(start, end);+ const digits = String(maxVal);+ const cellHeight = fontSize * 1.1;++ const cells: React.ReactNode[] = [];+ for (let place = 0; place < digits.length; place++) {+ if (place > 0 && place % 3 === 0) {+ cells.unshift(+ <span+ key={`s${place}`}+ style={{+ display: "inline-block",+ width: "0.34em",+ height: cellHeight,+ }}+ />,+ );+ }+ const pow = 10 ** place;+ const startDigit = Math.floor(start / pow) % 10;+ const travel = placeTravel(start, end, place);+ const pos = startDigit + e * travel;+ cells.unshift(+ <DigitColumn+ key={`d${place}`}+ value={wrap10(pos)}+ fontSize={fontSize}+ reveal={placeReveal(current, place)}+ />,+ );+ }++ return (+ <AbsoluteFill+ style={{+ display: "flex",+ alignItems: "center",+ justifyContent: "center",+ }}+ >+ <div+ style={{+ display: "flex",+ alignItems: "flex-start",+ fontSize,+ fontWeight: 800,+ color,+ fontFamily: MONO_FAMILY,+ fontVariantNumeric: "tabular-nums",+ letterSpacing: "-0.03em",+ lineHeight: 1,+ }}+ >+ {cells}+ </div>+ </AbsoluteFill>+ );+}