Nhatcapdang
Scroll

Scroll Opposite

A scroll-driven animation component that moves two columns in opposite directions as you scroll, creating a dynamic visual effect.

Usage

Installation

npx shadcn@latest add @nhatcapdang/scroll-opposite
yarn dlx shadcn@latest add @nhatcapdang/scroll-opposite
pnpm dlx shadcn@latest add @nhatcapdang/scroll-opposite

Props

PropTypeDefaultDescription
childrenReact.ReactNode[]-Array of elements to display (split evenly between columns)
heightstring-Height of the container with unit (e.g., "300px", "20rem")
classNamestring-Additional CSS classes for the container

Features

  • Opposite scroll directions: Left column moves down while right column moves up
  • Automatic splitting: Children array is automatically split in half between columns
  • Flexible height: Supports any CSS unit (px, rem, vh, etc.)
  • Scroll-linked animation: Animation progress tied to scroll position (30%-70% of viewport)
  • Smooth motion: Powered by Motion for fluid, performant animations

On this page