---
title: "Parallax Scroll"
description: "Free React parallax wrapper: children drift at a speed factor as they cross the viewport, on either axis. Reduced-motion safe. Framer Motion, shadcn install."
category: "Components"
parent: "https://beui.dev/components/motion/scroll-animation"
publishedAt: "2026-06-24"
updatedAt: "2026-11-10"
documentation: "https://beui.dev/components/motion/scroll-animation/parallax"
markdown: "https://beui.dev/components/motion/scroll-animation/parallax.md"
license: "MIT"
---

# Parallax Scroll

> Free React parallax wrapper: children drift at a speed factor as they cross the viewport, on either axis. Reduced-motion safe. Framer Motion, shadcn install.

## Install

```bash
npx shadcn@latest add @beui/parallax
```

## Dependencies

- `clsx`
- `motion`
- `react`
- `tailwind-merge`

## Usage

### Parallax usage

Wrapper that drifts its children at a speed factor as they cross the viewport, on either axis. Reduced-motion safe.

```tsx
"use client";

import { useRef } from "react";

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

// On a real page <Parallax> tracks the viewport. Here it's scoped to the box
// via the container prop. Scroll inside the box: the background image drifts
// against the scroll, the label and avatar drift with it at different speeds.
export function ParallaxPreview() {
  const containerRef = useRef<HTMLDivElement>(null);

  return (
    <div
      ref={containerRef}
      className="relative h-[600px] w-full max-w-2xl overflow-y-auto scrollbar-hide rounded-2xl border border-border bg-card"
    >
      <div className="flex h-80 items-center justify-center text-sm text-muted-foreground">
        Scroll down ↓
      </div>

      <div className="relative h-96 overflow-hidden">
        <Parallax
          container={containerRef}
          speed={-0.6}
          className="absolute inset-x-0 -top-1/4 h-[150%]"
        >
          <img
            src="https://picsum.photos/seed/beui-parallax/800/600"
            alt=""
            className="size-full object-cover"
          />
        </Parallax>

        <Parallax
          container={containerRef}
          speed={0.5}
          className="absolute inset-0 grid place-items-center"
        >
          <span className="rounded-full bg-background/85 px-5 py-2 text-base font-medium text-foreground backdrop-blur">
            Parallax
          </span>
        </Parallax>

        <Parallax
          container={containerRef}
          speed={0.9}
          className="absolute bottom-4 right-4"
        >
          <img
            src="https://picsum.photos/seed/beui-avatar/120/120"
            alt=""
            className="size-12 rounded-full border-2 border-background object-cover shadow-lg"
          />
        </Parallax>
      </div>

      <div className="flex h-80 items-center justify-center text-sm text-muted-foreground">
        ↑ Scroll up
      </div>
    </div>
  );
}
```

## API Reference

### Parallax

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `speed` | `number` | `0.3` | No | Drift as a fraction of the element's travel through the viewport. Positive moves with the scroll (foreground), negative against it (background). ~0.1–0.5 reads best. |
| `axis` | `"x" \| "y"` | `y` | No | Drift sideways or up and down as the page scrolls. Default: "y" |
| `container` | `RefObject<HTMLElement \| null>` | — | No | Scroll container for contained scroll areas. Defaults to the viewport. |
| `spring` | `boolean` | `true` | No | Spring-smooth the drift. Disabled automatically under reduced motion. |
| `className` | `string` | — | No | Classes merged onto the root element. |

## More in Scroll Animation

- [Smooth Scroll](https://beui.dev/components/motion/scroll-animation/smooth-scroll.md)
- [Scroll Progress](https://beui.dev/components/motion/scroll-animation/scroll-progress.md)
- [Scroll To Button](https://beui.dev/components/motion/scroll-animation/scroll-to.md)
- [Scroll Reveal](https://beui.dev/components/motion/scroll-animation/scroll-reveal.md)

## Source

- Registry detail: https://beui.dev/r/parallax
- Raw source: https://beui.dev/r/parallax/raw
- GitHub: https://github.com/starc007/ui-components
