Reveal elements as they scroll into view, with 12 combinable CSS effects, easing presets, cascades, repeat, lifecycle events and a CSS-only scrub mode, for vanilla JavaScript, any framework and plain HTML. Content already in view on load is never hidden, and everything stays visible without JavaScript, with reduced motion or when printing.
Demo · Examples · Documentation · Changelog
- Installation
- Quick start
- HTML / CDN
- Capabilities
- API at a glance
- Documentation
- Changelog
- AI agent skill
- License
npm install @samline/revealpnpm add @samline/revealbun add @samline/revealAny modern browser; without IntersectionObserver, content simply stays visible. On the server, every function returns a controller whose methods do nothing. No runtime dependencies.
import '@samline/reveal/style.css'
import { autoReveal } from '@samline/reveal'
autoReveal()<h2 data-reveal>Slides up</h2>
<ul data-reveal-stagger="80">
<li data-reveal="fade">Fades in first</li>
<li data-reveal="fade">80ms later</li>
</ul>
<figure data-reveal="zoom" data-reveal-repeat>Zooms in on every entry</figure>
<p data-reveal="up blur" data-reveal-easing="spring" data-reveal-duration="900">
Combined, with a spring
</p>For Shopify, WordPress or plain HTML pages without a build step, load the stylesheet and the browser bundle. It reveals every [data-reveal] as soon as the DOM is ready. Pin the version in production.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@samline/[email protected]/dist/style.css" />
<script
src="https://cdn.jsdelivr.net/npm/@samline/[email protected]/dist/browser/reveal.global.js"
defer
></script>The bundle defines window.Reveal. Add data-manual to the script tag and call Reveal.auto(options) to start it with your own options. Reveal.show(), Reveal.hide() and Reveal.refresh() act on the automatic run.
Only elements below the fold are hidden until they enter. Elements in view, or above it, are shown as they are, so the first paint and anchor links stay intact.
The stylesheet only hides elements the script marked data-reveal-state="pending". Without JavaScript, with prefers-reduced-motion: reduce or when printing, every element is visible.
Twelve effects (up, down, left, right, fade, zoom, blur, rotate, wipe-up, wipe-down, wipe-left, wipe-right) tuned with attributes or custom properties, and combinable with spaces: data-reveal="up blur", one direction and one wipe at most. Every rule uses :where(), and effects use translate, scale, rotate and filter, so your own styles and transform always win.
data-reveal-easing takes smooth, snappy, spring or bounce, or any CSS timing function. Use 800 to 1000 ms for spring and bounce.
data-reveal-stagger cascades a container's elements that enter together, in document order. data-reveal-stagger-from (start, end, center, edges, random), data-reveal-stagger-grid (rows and columns measured from the layout), data-reveal-stagger-ease (linear, out) and data-reveal-stagger-max shape the pattern. data-reveal-repeat plays on every entry. data-reveal-scrub follows the scroll position with a CSS scroll-driven animation, no script running.
data-reveal-split="words" or "chars" animates a text element's words or characters one after another with its effect. Screen readers get the original text. Only plain inline formatting is split: anything with links, buttons, images or other blocks inside is revealed as a whole. Use it on short headings; chars costs kerning and ligatures.
data-reveal-media animates only while a media query matches, and data-reveal-threshold and data-reveal-margin override the observer per element. With data-reveal-reduced="fade", visitors who prefer reduced motion still get a fade instead of nothing.
reveal() and autoReveal() return a controller: show() reveals now, even off screen, with the transition and the cascade; hide() puts elements back instantly; update(options) and refresh() re-apply the options or the target without a flash; finished() resolves when nothing is queued or revealing; destroy() restores the markup.
A data-reveal value that is not a built-in effect is left as is, so your own CSS defines it ([data-reveal~='tilt'][data-reveal-state='pending'] { rotate: 8deg }); without CSS of its own it fades. The presets option names sets of per-element options: { hero: { effect: 'up blur', duration: 900 } } makes data-reveal="hero" use them.
reveal:show, reveal:end and reveal:hide bubble from the element with detail.animated, next to the onShow, onEnd and onHide callbacks.
| API | Purpose |
|---|---|
autoReveal(options?) |
Reveal every [data-reveal], including elements added later. Returns a RevealController. |
reveal(target?, options?) |
Reveal a selector, element or list. Returns a RevealController: elements, show, hide, update, refresh, finished, destroy. |
REVEAL_EFFECTS |
The effect names. |
REVEAL_EASINGS |
The easing preset names. |
REVEAL_STAGGER_FROM, REVEAL_STAGGER_EASE |
The cascade origins and spacings. |
REVEAL_SPLIT |
The split modes (words, chars). |
data-reveal-* attributes |
Effect, duration, delay, distance, easing, repeat, stagger (and its from, grid, ease and max), split, scrub, threshold, margin, media and reduced. |
--reveal-* custom properties |
Duration, delay, easing, distance, scale, blur, rotate and scrub range. |
reveal:show, reveal:end, reveal:hide |
Bubbling events with detail.animated (EVENT_PREFIX). |
easing, media, reducedMotion, presets, onEnd |
Options next to effect, duration, delay, distance, stagger, repeat, root, rootMargin, threshold, onShow and onHide. |
staggerFrom, staggerGrid, staggerEase, staggerMax, split |
Cascade pattern and split text options. |
| Entrypoint | When to use |
|---|---|
@samline/reveal |
ESM or CommonJS, reveal and autoReveal. |
@samline/reveal/vanilla |
reveal as the default export. |
@samline/reveal/style.css |
Effects, timing variables and scrub mode. |
@samline/reveal/browser |
Classic script that defines window.Reveal. |
Read the documentation for the full guides and API contracts, and explore working examples with complete and separate source files.
| Guide | What it covers |
|---|---|
| Installation | npm, CDN and the first reveal. |
| API reference | reveal, autoReveal and window.Reveal. |
| Options | Attributes, options, CSS variables and states. |
| Effects and timing | Custom effects, cascades and repeat. |
| Scrub mode | Scroll-driven reveals without JavaScript. |
| Frameworks | React, Vue, Svelte, Astro and page swaps. |
Read CHANGELOG.md or the published changelog for release history and explicitly marked breaking and behavior changes. Review the notes before upgrading.
The Reveal skill teaches verified package integration. Its maintained repository source and website download are the same file. Verify the installed package version before applying its guidance.
Download SKILL.md into a reveal/ folder in your agent's supported skill directory. For agents that discover project skills from .agents/skills/:
mkdir -p .agents/skills/reveal
curl --fail --location https://samline.github.io/reveal/skills/reveal/SKILL.md \
--output .agents/skills/reveal/SKILL.mdKeep the filename SKILL.md; discovery paths and invocation syntax depend on the agent.
MIT — LICENSE.md.