Skip to content
English

How it works

Two layers: a still outer placeholder that IntersectionObserver watches, and an inner layer that animates only opacity, transform and a soft blur (6px by default, set --ds-scroll-reveal-blur to 0px for a crisp entrance). Observing the still layer avoids flicker, because an offset would change the element's own visibility. Instances with the same root and options share one observer, so items entering together are staggered by page position while later ones appear at once. It never listens to scroll.

Use it for

  • Long pages revealed section by section: selling points, process steps, highlights.
  • Cards, course lists and review walls that scroll down, where the first few items should appear in rhythm.
  • Campaign and landing pages that need a little pacing to guide the eye.

Look elsewhere when

  • Key content on the first screen, such as the headline, price or main button: people should not wait, and it stays transparent when rendered on the server before JavaScript runs.
  • Tool-like pages such as admin tables, forms and order details: content must be readable at once.
  • Virtualized lists with hundreds of items: nodes are created and destroyed repeatedly and would reveal every time.
  • A headline that should appear word by word: use a text reveal.

Usage

import { useRef } from 'react'
import { ScrollReveal } from './ScrollReveal.jsx'

// Whole-page scrolling: no root needed
export function Features() {
  return (
    <>
      <ScrollReveal as="section">
        <h2>Free returns</h2>
      </ScrollReveal>
      <ScrollReveal variant="scale" delay={120}>
        <img src="/returns.png" alt="How returns work" />
      </ScrollReveal>
    </>
  )
}

// Scrolling inside a container: pass the container's ref as root
export function PopularStays({ list }) {
  const scrollRef = useRef(null)
  return (
    <div ref={scrollRef} style={{ height: 360, overflowY: 'auto', overflowX: 'hidden' }}>
      <ul>
        {list.map((stay) => (
          <ScrollReveal key={stay.id} as="li" root={scrollRef}>
            <StayCard stay={stay} />
          </ScrollReveal>
        ))}
      </ul>
    </div>
  )
}

Props

PropTypeDefaultWhat it does
variant'fade-up' | 'fade' | 'scale' | 'slide-left' | 'slide-right''fade-up'How it appears: rise and fade, fade only, scale up from 0.92, slide in from the right, slide in from the left.
delaynumber0Extra wait in ms after entering the viewport.
staggernumber60Gap in ms between elements entering together, ordered by page position, up to 6. Items entering alone are unaffected; 0 turns it off.
durationnumber560Reveal time in ms. When omitted, follows --ds-duration-slower.
distancenumber24Offset in px, used by fade-up, slide-left and slide-right.
oncebooleantruePlays once. When false, it resets after fully leaving the viewport and replays on re-entry.
thresholdnumber0.2Fraction that must be visible to count as entered, 0 to 1. Elements larger than the viewport count as soon as they peek in.
rootRefObject | Element | nullbrowser viewportScroll container (element or its ref). Required when content scrolls inside an overflow: auto container.
rootMarginstring'0px'Grows or shrinks the detection area, CSS margin syntax, such as '0px 0px -10% 0px'.
onReveal() => void—Called when it starts to appear (every re-entry when once is false). Handy for impression tracking.
as'div' | 'section' | 'article' | 'li' | 'header' | 'footer' | 'aside' | 'figure''div'Root tag. Use 'li' inside a <ul>.
...restHTMLAttributes<HTMLElement>—Other attributes, such as className, style and id, go to the root (the still placeholder).

Accessibility

  • Before entering it is only opacity: 0, never visibility: hidden or display: none, so content stays in the accessibility tree and screen readers still read it.
  • Tabbing into content that has not appeared yet shows it at once (:focus-within), so focus never lands on something invisible.
  • With reduced motion, content is visible with no offset, blur or transition; onReveal still fires on real entry.
  • Where IntersectionObserver is missing, or rootMargin is invalid, content is shown directly.
  • Semantic tags are kept: as can be section, article, li and so on, with no meaningless extra levels.

Motion

Reveal: opacity 0 to 1, a 6px blur clearing, plus a 24px offset (or scale 0.92 to 1) over 560ms with the reveal curve cubic-bezier(0.22, 1, 0.36, 1). Items entering together are staggered by 60ms, up to 6. The reset after leaving has no transition.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.

ScrollReveal.jsxscroll-reveal.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Lists & layout
Arc carousel comes with Pro. Its preview shows once you unlock it.
Cylinder carousel comes with Pro. Its preview shows once you unlock it.