No flash on load
Elements already in view, or above it, are never hidden, so the first paint and anchor links stay intact.
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/revealAbout 2.9 KB gzipZero dependenciesMIT licensed
Scroll the box. Cards that start in view are never hidden.
ONE SMALL SCRIPT. RIGHT AT HOME IN YOUR STACK.
Elements already in view, or above it, are never hidden, so the first paint and anchor links stay intact.
Without JavaScript, with reduced motion or when printing, every element is visible. The CSS only hides what the script marked.
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.
Reveal once by default, or hide again on leaving with data-reveal-repeat so it plays on every entry.
data-reveal-scrub ties the effect to the scroll position with animation-timeline: view(), no script running.
Every rule uses :where(), and effects use translate, scale, rotate and filter, so your own transform is never overwritten.
Configure with attributes or options; one stylesheet holds every effect.
Package
reveal and autoReveal as ESM or CommonJS.
Elements
Reveal a selector, element or list; returns a controller.
Whole page
Every [data-reveal], including content added later.
HTML / CDN
A classic script that starts on its own.
Effects
Picked with the value of data-reveal.
Stylesheet
Effects, timing variables and the scrub mode.
Reveal a list in cascade as it scrolls into view.
Read the installation guideInstall
npm
npm install @samline/revealpnpm
pnpm add @samline/revealyarn
yarn add @samline/revealbun
bun add @samline/revealHTML / CDN
<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>Add attributes
Mark elements with data-reveal and cascade a container with data-reveal-stagger.
<ul data-reveal-stagger="80">
<li data-reveal>Fast</li>
<li data-reveal>Typed</li>
<li data-reveal="zoom">Tiny</li>
</ul>Start revealing
import '@samline/reveal/style.css'
import { autoReveal } from '@samline/reveal'
autoReveal()Continue with every attribute, option and CSS variable.
Explore the optionsThree common jobs, without writing a single keyframe.
<h2 data-reveal="left" data-reveal-duration="900" data-reveal-distance="3rem">
Slides in from the right
</h2>reveal('.stat', { effect: 'zoom', repeat: true }).hero {
--reveal-duration: 1s;
--reveal-easing: cubic-bezier(0.16, 1, 0.3, 1);
}Try the examples or follow the first steps.
Guides, the complete API and release notes, in one place.
Read the documentation