Text that scrolls across the screen and skews/speeds up based on the users scroll velocity.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- framer-motion
Code
"use client";
import { useRef } from "react";
import { ScrollBasedVelocity } from "@/components/ui/scroll-based-velocity";
import { ChevronDown } from "lucide-react";
export function ScrollBasedVelocityDemo() {
const containerRef = useRef<HTMLDivElement>(null);
return (
<div
ref={containerRef}
className="relative w-full h-full overflow-y-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]"
>
{/* Tall scrollable content */}
<div className="min-h-[300vh] flex flex-col items-center">
{/* Top hint */}
<div className="flex flex-col items-center gap-3 pt-16 pb-8 animate-pulse">
<span className="text-sm font-medium text-muted-foreground/70">
Scroll to see the effect
</span>
<ChevronDown className="w-4 h-4 text-muted-foreground/50" />
</div>
{/* Spacer */}
<div className="h-[20vh]" />
{/* Sticky velocity text */}
<div className="sticky top-1/3 w-full py-8">
<ScrollBasedVelocity
text="Velocity Scroll"
default_velocity={5}
containerRef={containerRef}
className="font-display text-center text-4xl font-bold tracking-[-0.02em] text-foreground drop-shadow-sm md:text-7xl md:leading-[5rem]"
/>
</div>
{/* Bottom spacer for scrolling room */}
<div className="flex-1" />
</div>
</div>
);
}
import * as __R from "react";
export default function __InfinityFrame() {
__R.useEffect(() => {
// Simulated cursor: a slow figure-eight, so pointer-driven effects draw something.
let t = 0;
const id = setInterval(() => {
t += 0.05;
const x = innerWidth * (0.5 + 0.32 * Math.sin(t));
const y = innerHeight * (0.5 + 0.22 * Math.sin(2 * t));
const el = document.elementFromPoint(x, y);
if (!el) return;
const init = { clientX: x, clientY: y, pageX: x, pageY: y, bubbles: true, cancelable: true, view: window };
el.dispatchEvent(new PointerEvent("pointermove", { ...init, pointerType: "mouse", isPrimary: true }));
el.dispatchEvent(new MouseEvent("mousemove", init));
}, 30);
return () => clearInterval(id);
}, []);
return (
<div style={{ position: "relative", width: "100vw", height: "100vh", display: "flex", alignItems: "center", justifyContent: "center", overflow: "hidden" }}>
<ScrollBasedVelocityDemo />
</div>
);
}




























