Scroll Trigger

Horizontal infinite rows powered by motion. Base speed plus page-scroll velocity. Pauses when offscreen, hidden, or when the user prefers reduced motion. Wrap rows in ScrollTriggerContainer so they share one scroll signal.

Default

Three review rows: scroll the page to speed them up. Opposite direction values cross traffic.

Loading…

Installation

CLI
npx @sonojs/ui@latest add scroll-trigger
Also needsnpm i motion

Usage

page.tsx
"use client"

import {
  ScrollTriggerContainer,
  ScrollTriggerRow,
} from "@/components/3d/scroll-trigger"

export default function Page() {
  return (
    <ScrollTriggerContainer className="w-full">
      <ScrollTriggerRow baseVelocity={5} direction={1}>
        <div className="mx-4 rounded-lg bg-primary px-4 py-2 text-primary-foreground">
          Item 1
        </div>
        <div className="mx-4 rounded-lg bg-muted px-4 py-2">Item 2</div>
        <div className="mx-4 rounded-lg bg-muted px-4 py-2">Item 3</div>
      </ScrollTriggerRow>
    </ScrollTriggerContainer>
  )
}

Props

ScrollTriggerContainer

PropTypeDefaultDescription
childrenReactNode-Usually one or more `ScrollTriggerRow` elements.
classNamestring-Classes on the outer wrapper.

ScrollTriggerRow

PropTypeDefaultDescription
childrenReactNode-Items in the row. Duplicated automatically for a seamless loop.
baseVelocitynumber5Base speed as a percent of one content block width per second.
direction1 · -11Travel direction along the row.
scrollReactivitybooleantrueWhen false, ignore page-scroll speed boost.
classNamestring-Classes on the row overflow wrapper.