Scroll Swap Text

Scroll-driven text swap animation where text slides vertically based on scroll progress

Installation

pnpm dlx shadcn@latest add "https://vritti.thesatyajit.com/r/scroll-swap-text"

Dependencies

pnpm add motion

Props

Scroll Swap Text

PropTypeDefaultDescription
childrenReact.ReactNode-Text content to animate
asElementType"span"HTML element type to render as
containerRefReact.RefObject<HTMLElement | null>-Ref to the scrollable container element
offset[string, string]["0 0", "0 1"]Scroll offset range for the animation trigger
classNamestring-Additional CSS classes
springConfig{ stiffness?: number; damping?: number; mass?: number }{ stiffness: 200, damping: 30 }Spring physics configuration for the scroll animation