Scroll Based Velocity Demo

PreviousNext

Example showing text speed changes based on scroll velocity.

Docs
magicuiexample

Preview

Loading preview…
registry/example/scroll-based-velocity-demo.tsx
import {
  ScrollVelocityContainer,
  ScrollVelocityRow,
} from "@/registry/magicui/scroll-based-velocity"

export default function ScrollBasedVelocityDemo() {
  return (
    <div className="relative flex w-full flex-col items-center justify-center overflow-hidden">
      <ScrollVelocityContainer className="text-4xl font-bold tracking-[-0.02em] md:text-7xl md:leading-[5rem]">
        <ScrollVelocityRow baseVelocity={20} direction={1}>
          Velocity Scroll
        </ScrollVelocityRow>
        <ScrollVelocityRow baseVelocity={20} direction={-1}>
          Velocity Scroll
        </ScrollVelocityRow>
      </ScrollVelocityContainer>
      <div className="from-background pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r"></div>
      <div className="from-background pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l"></div>
    </div>
  )
}

Installation

npx shadcn@latest add @magicui/scroll-based-velocity-demo

Usage

import { ScrollBasedVelocityDemo } from "@/components/scroll-based-velocity-demo"
<ScrollBasedVelocityDemo />