Scroll Reveal

Content that slides in with a soft blur as it enters the viewport.

Preview

"use client";

import { useRef } from "react";

import { ScrollReveal } from "@/components/motion/scroll-reveal";

// On a page <ScrollReveal> tracks the viewport. Here root points at the box so
// each card reveals as it scrolls into the contained view.
const CARDS = ["Spring slide", "Blur in", "Staggered by delay", "Reveal once"];

export function ScrollRevealPreview() {
  const containerRef = useRef<HTMLDivElement>(null);

  return (
    <div
      ref={containerRef}
      className="h-80 w-full max-w-lg overflow-y-auto scrollbar-hide rounded-2xl border border-border bg-card"
    >
      <div className="flex flex-col gap-16 p-6">
        <div className="text-center text-sm text-muted-foreground">
          Scroll ↓
        </div>
        {CARDS.map((label, i) => (
          <ScrollReveal
            key={label}
            root={containerRef}
            once={false}
            delay={i * 0.05}
            className="rounded-2xl border border-border bg-muted/50 px-4 py-16 text-center text-base font-medium text-foreground"
          >
            {label}
          </ScrollReveal>
        ))}
        <div className="text-center text-sm text-muted-foreground">End</div>
      </div>
    </div>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/scroll-reveal

API Reference

y?
number

Slide distance in px before reveal.

Default16
blur?
number

Enter blur in px (kept ≤ 10 per motion conventions).

Default8
duration?
number

Reveal duration in seconds.

Default0.6
delay?
number

Wait before the reveal starts, in seconds. Default: 0

Default0
once?
boolean

Reveal only once (default) or every time it enters view.

Defaulttrue
amount?
number | "all" | "some"

Portion of the element that must be visible to trigger.

Default0.3
root?
RefObject<Element | null>

Scroll root for contained scroll areas. Defaults to the viewport.

Default—
className?
string

Classes merged onto the wrapper element.

Default—

More in Scroll Animation

Updated