- Docs
Reveal
What @samline/reveal does, which elements it hides and when, and how effects, cascades, repeat and scrub fit together.
@samline/reveal reveals elements as they scroll into view. Mark them with data-reveal, load the stylesheet and call autoReveal() (or load the CDN script). The script only decides when; the stylesheet does the animation.
What is hidden, and when
| Element on load | Without repeat | With repeat |
|---|---|---|
| In view | Shown, never hidden | Shown, hidden after it leaves |
| Below the fold | Hidden, revealed on entry | Hidden, revealed on every entry |
| Above the viewport | Shown | Hidden, revealed on the way back |
No box (display: none) | Shown | Shown |
Without JavaScript, without IntersectionObserver, with prefers-reduced-motion: reduce or when printing, every element is visible.
Pieces
| Job | How |
|---|---|
| Pick effects | data-reveal="up" (default), down, left, right, fade, zoom, blur, rotate, wipe-up, wipe-down, wipe-left or wipe-right, combined with spaces (up blur) |
| Time one element | data-reveal-duration, data-reveal-delay, data-reveal-distance, data-reveal-easing |
| Cascade a group | data-reveal-stagger="80" on the container, with -from, -grid, -ease and -max for patterns |
| Split text | data-reveal-split="words" or "chars" |
| Play every time | data-reveal-repeat |
| Follow the scroll | data-reveal-scrub (CSS only) |
| Theme everything | --reveal-duration, --reveal-easing and the other CSS variables |
Choose your next step
Package managers, the CDN and the first reveal.
ExamplesLive previews with the complete, copyable source of each one.
API referenceSignatures and behavior of reveal, autoReveal and window.Reveal.
Attributes, options, CSS variables and states.
Effects and timingCustom effects, cascades and repeat.
Scrub modeScroll-driven reveals without JavaScript.
Accessibility and motionReduced motion, screen readers and what your page provides.
Framework integrationsReact, Vue, Svelte, Astro and page swaps.