Reveal on scroll. Never flash.

Reveal
Motion that respects the page.

Add data-reveal and content fades, slides, zooms, blurs, rotates or wipes in as it scrolls into view, alone or combined, in cascade when it enters together.
Install it, scroll the live preview, then read the full reference.

npm install @samline/reveal

About 2.9 KB gzipZero dependenciesMIT licensed

Reveal previewLive preview
Effect
Card 01
Card 02
Card 03
Card 04
Card 05
Card 06
Card 07
Card 08
Card 09
Card 10
Card 11
Card 12
Card 13
Card 14
Card 15
Card 16
Card 17
Card 18
Card 19
Card 20
Card 21
Card 22
Card 23
Card 24

Scroll the box. Cards that start in view are never hidden.

ONE SMALL SCRIPT. RIGHT AT HOME IN YOUR STACK.

JavaScript TypeScript React Vue Svelte Astro Shopify WordPress
01 / More than a fade-in

Only what is below the fold.
Nothing else moves.

No flash on load

Elements already in view, or above it, are never hidden, so the first paint and anchor links stay intact.

Safe by default

Without JavaScript, with reduced motion or when printing, every element is visible. The CSS only hides what the script marked.

Cascades in order

Items that enter together are delayed one after another per data-reveal-stagger container: from the start, the center, the edges or at random, over a grid, and split text word by word or character by character.

Repeat or once

Reveal once by default, or hide again on leaving with data-reveal-repeat so it plays on every entry.

Scrub with CSS only

data-reveal-scrub ties the effect to the scroll position with animation-timeline: view(), no script running.

Your styles win

Every rule uses :where(), and effects use translate, scale, rotate and filter, so your own transform is never overwritten.

02 / Fit it into your stack

Attributes first. Script when you need it.

Configure with attributes or options; one stylesheet holds every effect.

Package

@samline/reveal

reveal and autoReveal as ESM or CommonJS.

Elements

reveal(target, options)

Reveal a selector, element or list; returns a controller.

Whole page

autoReveal(options)

Every [data-reveal], including content added later.

HTML / CDN

window.Reveal

A classic script that starts on its own.

Effects

up · down · left · right · fade · zoom · blur · rotate · wipe-up · wipe-down · wipe-left · wipe-right

Picked with the value of data-reveal.

Stylesheet

@samline/reveal/style.css

Effects, timing variables and the scrub mode.

03 / Install and reveal

One stylesheet. One call.

Reveal a list in cascade as it scrolls into view.

Read the installation guide
1

Install

npm

Terminal
npm install @samline/reveal

pnpm

Terminal
pnpm add @samline/reveal

yarn

Terminal
yarn add @samline/reveal

bun

Terminal
bun add @samline/reveal

HTML / CDN

Terminal
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@samline/reveal@2.0.0/dist/style.css">
<script src="https://cdn.jsdelivr.net/npm/@samline/reveal@2.0.0/dist/browser/reveal.global.js" defer></script>
2

Add attributes

Mark elements with data-reveal and cascade a container with data-reveal-stagger.

index.html
<ul data-reveal-stagger="80">
  <li data-reveal>Fast</li>
  <li data-reveal>Typed</li>
  <li data-reveal="zoom">Tiny</li>
</ul>
3

Start revealing

main.js
import '@samline/reveal/style.css'
import { autoReveal } from '@samline/reveal'

autoReveal()
Copy complete working files

Continue with every attribute, option and CSS variable.

Explore the options
04 / Beyond a fade

Timing in attributes.
Effects in CSS.

Three common jobs, without writing a single keyframe.

data-reveal-*

Slower, further, later

Set duration, delay and distance per element.

Read the options
index.html
<h2 data-reveal="left" data-reveal-duration="900" data-reveal-distance="3rem">
  Slides in from the right
</h2>
repeat

Play on every entry

Hide again on leaving and reveal on the way back.

Read the API
main.js
reveal('.stat', { effect: 'zoom', repeat: true })
CSS variables

Your own easing

Theme every effect from any ancestor.

Read the options
style.css
.hero {
  --reveal-duration: 1s;
  --reveal-easing: cubic-bezier(0.16, 1, 0.3, 1);
}
Explore working examples
05 / Before you build

A few details. Clearly answered.

Why is content in view on load not animated?
Hiding it would flash the first paint and move content the visitor is already reading. Only elements that start below the fold are hidden until they enter; with repeat, elements above the viewport are hidden too, so they play on the way back.
Does it work without a bundler?
Yes. Load dist/style.css and dist/browser/reveal.global.js; it reveals every [data-reveal] on its own. Add data-manual to the script tag to start it yourself with Reveal.auto(). Pin the version in production.
How do I change the speed or the distance?
Per element with data-reveal-duration, data-reveal-delay and data-reveal-distance, per call with the same options, or for the whole site with the --reveal-duration, --reveal-easing, --reveal-distance, --reveal-scale, --reveal-blur and --reveal-rotate CSS variables.
What happens without JavaScript?
Everything is visible. The stylesheet only hides elements whose data-reveal-state the script set to pending, so a failed or blocked script never leaves a blank page.
How is reduced motion handled?
With prefers-reduced-motion: reduce, nothing is hidden or animated, and turning the preference on while browsing shows hidden content at once. Add data-reveal-reduced="fade" to keep a plain fade instead.
Does it see content added later?
autoReveal and the CDN script watch the page, so elements added by AJAX, infinite scroll or page swaps are revealed and removed elements are released.
Which browsers support scrub?
Browsers with scroll-driven animations (animation-timeline: view()). Elsewhere, scrub elements simply stay visible.
Will it break my transforms?
No. Effects use the individual translate, scale, rotate and filter properties, and the transition only exists while revealing, so your transform and transitions keep working.
Motion, kept polite

Reveal what is next, not what is there.

Try the examples or follow the first steps.

Guides, the complete API and release notes, in one place.

Read the documentation