Modus UI

Scroll Velocity

Web (React)

A marque text effect whose speed scales dynamically based on scroll velocity.

A high-performance text marquee powered by framer-motion's useVelocity, useScroll, and useTransform. As the user scrolls faster, the text marquee speed multiplies dynamically.

MODUS UI
REACT COMPONENTS
FRAMER MOTION

Installation

CLI

npx @modus-ui/cli add scroll-velocity

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/scroll-velocity.tsx.
  3. Paste the code.

Usage

tsx
import { ScrollVelocity } from "@/components/ui/scroll-velocity";

export default function Example() {
  return <ScrollVelocity texts={["FIRST LINE", "SECOND LINE", "THIRD LINE"]} velocity={50} />;
}

Props

PropTypeDefaultDescription
scrollContainerRefReact.RefObject<HTMLElement>-Scroll container to track instead of the window.
textsstring[][]One scrolling row per string.
velocitynumber100Base speed of the rows.
dampingnumber50Damping of the scroll-velocity spring.
stiffnessnumber400Stiffness of the scroll-velocity spring.
numCopiesnumber6Copies of the text per row.
velocityMapping{ input: number[]; output: number[] }{ input: [0, 1000], output: [0, 5] }Maps scroll velocity to the speed multiplier.
parallaxClassNamestring-Classes for each row's container.
scrollerClassNamestring-Classes for each moving row.
parallaxStyleReact.CSSProperties-Inline styles for each row's container.
scrollerStyleReact.CSSProperties-Inline styles for each moving row.

Comments

  • No comments yet.