Skip to content

Parallax

Content that drifts against the page while the frame scrolls past.

From the Nitip template — see it in context
Rolling hills in morning mist

Scroll the page — the photo drifts inside the frame.

Installation

$ npx shadcn@latest add https://framebrick.co/r/parallax.json

Usage

import { Parallax } from "@/components/ui/parallax";

<Parallax speed={30} className="h-[60vh] w-full">
  <Image src={photo} alt="" fill className="object-cover" />
</Parallax>

Props

PropTypeDefaultDescription
childrenReactNode—What drifts. The frame clips it and the layer is oversized so no edge shows.
speednumber20How far the content travels over one pass, as a percentage of the frame height.
direction"vertical" | "horizontal""vertical"Axis of the drift.
classNamestring—Sizes the frame — always give it a height.
  • Framer ties the shift to the whole page scroll, which drifts further the longer the page is; here it is bounded to one pass of the frame through the viewport, so no gap can appear.
  • The transform is written in a passive scroll listener, so it never lags a frame behind. Static with reduced motion.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.

Create a React + Tailwind CSS component called Parallax (no animation library).
- A frame (position relative, overflow-hidden) sized by className, holding an absolutely positioned layer that is
  oversized by `speed` percent (inset -speed/2% top and bottom) and stretches its children to fill it.
- In a passive scroll listener, measure the frame with getBoundingClientRect and compute
  progress = (innerHeight - rect.top) / (innerHeight + rect.height), clamped to 0–1.
- Write transform = translate3d(0, (0.5 - progress) * distance, 0) straight to the layer's style,
  where distance = frame height * speed / 100. Re-measure on resize (ResizeObserver) — never animate with state.
- direction "horizontal" shifts on X instead, using the frame width.
- Skip everything when prefers-reduced-motion is set.

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy