About
An odometer-style number with sliding or split-flap digits, directional flips, currency affixes, grouping, decimals, signed values, and per-digit styling.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Sliding Number to your project and fits it to your theme.
Code
How Sliding Number is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
/**
* PrequelUI Animate — MIT — https://prequeluianimate.terravidhal.me
*/
import * as React from "react";
import { ArrowDownRight, ArrowUpRight } from "lucide-react";
import { useReducedMotion } from "motion/react";
import { SlidingNumber } from "@/components/ui/sliding-number";
export default function SlidingNumberDemo() {
const [{ value, delta }, setState] = React.useState({
value: 2_480_500,
delta: 18.2,
});
const reduce = useReducedMotion();
React.useEffect(() => {
if (reduce) return;
const timer = window.setInterval(() => {
setState((current) => {
const nextDelta = Math.min(
32,
Math.max(-14, current.delta + (Math.random() - 0.45) * 1.6),
);
const step = 12 + Math.round(Math.random() * 84);
return {
value: Math.max(
0,
current.value + (nextDelta >= 0 ? step : -step),
),
delta: Number(nextDelta.toFixed(1)),
};
});
}, 2200);
return () => window.clearInterval(timer);
}, [reduce]);
const up = delta >= 0;
return (
<main className="flex min-h-screen w-full flex-col items-center justify-center gap-5 bg-background px-6">
<SlidingNumber
number={value}
fromNumber={2_479_000}
padStart
variant="flip"
flipDirection="up"
thousandSeparator=","
prefix="$"
announce={false}
delay={120}
className="text-5xl font-semibold tracking-tight text-foreground sm:text-7xl md:text-8xl"
affixClassName="text-muted-foreground"
/>
<div
className={
up
? "flex items-center gap-1.5 text-lg font-medium text-emerald-600 dark:text-emerald-400 sm:text-xl"
: "flex items-center gap-1.5 text-lg font-medium text-rose-600 dark:text-rose-400 sm:text-xl"
}
>
{up ? (
<ArrowUpRight aria-hidden="true" className="size-5" />
) : (
<ArrowDownRight aria-hidden="true" className="size-5" />
)}
<SlidingNumber
number={Math.abs(delta)}
fromNumber={0}
variant="roll"
decimalPlaces={1}
suffix="%"
announce={false}
transition={{ stiffness: 140, damping: 18, mass: 0.5 }}
/>
</div>
</main>
);
}








