Scroll Based Velocity
- Source
- Magic UI ↗
- Author
- Magic UI
- Licence
- MIT
Loading…
Two text rows scroll in opposite directions and speed up while the page scrolls.
Code
"use client";
import { ScrollVelocityContainer, ScrollVelocityRow } from "@/lab/magicui/ui/scroll-based-velocity";
export default function ScrollBasedVelocityDemo() {
return (
<div className="@container relative flex h-full w-full flex-col items-center justify-center overflow-hidden text-neutral-950">
<ScrollVelocityContainer className="text-[clamp(2rem,8cqw,4.5rem)] leading-tight font-bold tracking-[-0.02em]">
<ScrollVelocityRow baseVelocity={20} direction={1}>
Velocity Scroll
</ScrollVelocityRow>
<ScrollVelocityRow baseVelocity={20} direction={-1}>
Velocity Scroll
</ScrollVelocityRow>
</ScrollVelocityContainer>
<div className="pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r from-[#fbfaf7]"></div>
<div className="pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l from-[#fbfaf7]"></div>
</div>
);
}
Prompt
Build "Scroll Based Velocity", a scroll animation. What it does: Two text rows scroll in opposite directions and speed up while the page scrolls. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: the Motion library. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/scroll-based-velocity (Magic UI, MIT).