Scroll Reveal

Animated

A block that wipes into view when first scrolled to.

Source
$npx @dinachi/cli@latest add scroll-reveal

Scroll down.

Uncovered edge-first as it arrives.
direction
distance
duration
repeat

Usage

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

export function Features() {
  return (
    <ScrollReveal>
      <FeatureGrid />
    </ScrollReveal>
  )
}

Examples

Scroll down.

Uncovered edge-first as it arrives.
A block uncovered edge-first as it arrives.
import { ScrollReveal } from '@/components/ui/scroll-reveal';

export function Example() {
  return (
    <ScrollReveal>
      <FeatureGrid />
    </ScrollReveal>
  );
}

Notes

Motion tier

Needs motion. add --all skips it; install with add --motion or by name.

Direction

The aperture opens against the travel. Use up for content read top to bottom.

| Direction | Content travels | Aperture opens from | | --- | --- | --- | | up | Up | Top | | down | Down | Bottom | | left | Left | Right | | right | Right | Left |

When to use it

  • One hero block or feature grid the reader has not seen yet.
  • Skip it for content reached by deep link or revisited, and for content that must show without JS: the hidden state is a real style.
  • For a list, use Stagger List.

Behaviour

  • Reveals once by default. With repeat, leaving view resets the block instantly.
  • A block shorter than the margin inset at the very bottom of the page never reveals. Pass "0px" for trailing content.
  • root must be an ancestor of the content, or the block stays hidden. Set it inside a dialog body, sidebar or other scroll container.
  • A plain wrapper div is observed. ref, className and other props go to the inner animated element.

API

direction"up" | "down" | "left" | "right" = "up"
Direction of travel. The aperture opens against it.
distancenumber = 8
Travel in pixels.
durationnumber = 0.3
Seconds. The easing front-loads the travel.
delaynumber = 0
Seconds after entering view. Keep cascade steps between 0.03 and 0.08.
repeatboolean = false
Replays each time the block re-enters view.
marginstring = "0px 0px -100px 0px"
Root margin for the trigger. Pass "0px" for trailing content with nothing below it.
amountnumber | "some" | "all" = "some"
How much must be visible. A block taller than the root never reaches a number.
rootRefObject<Element>
A scrollable ancestor to observe instead of the viewport.

Accessibility

  • Reduced motion keeps the fade, drops the wipe and travel. <MotionConfig reducedMotion> is honoured.
  • The hidden block stays in the DOM, so screen readers reach it early.