GhostReveal
A modern JavaScript scroll-reveal library
Scroll reveals that feel expensive and weigh nothing
npm i ghost-reveal
<div data-reveal>
The library
Animate an element as it scrolls into view. #
Add data-reveal and load one script. The element rises a short distance, sharpens out of a soft blur, and settles into place. The script is free, about 2 KB, with no dependencies and no CSS file. The same attribute works in plain HTML, React, Vue, Svelte, Astro, Angular, and WordPress.
Live demonstration
GhostReveal In Action #
fade
Fades in place. Opacity and blur, with no movement.
fade-up
Rises into place. This is the default.
fade-down
Drops into place from above.
fade-left
Moves left into place.
fade-right
Moves right into place.
zoom-in
Grows from 60% size into place.
zoom-out
Settles in from 120% size.
slide-up
Rises its own height into place.
flip-up
Rotates up into place.
The name is the attribute value. A bare data-reveal is fade-up, and every animation sharpens from a 4px blur.
The default
The default is already set.
Each item below is only data-reveal, with data-reveal-stagger on the list. It rises 16px and goes from a 4px blur to sharp over 700ms. The curve is cubic-bezier(.16,1,.3,1). Only opacity, transform, and filter change.
- 01
Blur-to-sharp
4px blurThe element starts slightly out of focus and lands sharp. Change it with
data-reveal-blur. - 02
Expo-out easing
700msIt moves quickly, then settles. There is no bounce.
- 03
Smart stagger
per batchOnly elements that enter together are delayed. A later row does not wait for the rows above it.
- 04
No layout shift
CLS 0The animation does not move layout. It does not add a sideways scrollbar.
- 05
Reduced motion
liveWhen the reader asks for less motion, content appears at once. The setting is followed as it changes.
- 06
SPA-ready
autoContent added later is found on its own. A route change does not need another call.
Blur
Choose how soft the start is.
data-reveal-blur="0" is a crisp fade. A higher number starts more out of focus.
Crisp
Opacity and travel only.
Subtle
A light blur. This is the default.
Soft
A stronger blur, over a longer time.
Big moments
Large areas stay smooth.
Only opacity, transform, and filter change, so the page does not reflow. There is no scroll listener. The browser reports when the element enters, and then runs the animation.
AOS-compatible
Every AOS animation name works.
Keep your data-aos markup. Fade, zoom, slide, and flip use the same blur and fade. A slide from the side does not widen the page.
Dynamic content
Content added later reveals itself.
New elements are found on their own. A route change, a longer list, or a CMS embed does not need another call. Only the added markup is scanned.
Experimental · native scroll-driven
Tie the animation to the scroll.
data-reveal-scrub moves the animation with the scroll, in both directions, where the browser can do that natively. Other browsers get the normal reveal.
Scroll me
Then scroll back up. It reverses.
zoom-in
The same zoom, tied to the scroll position.
fade-left
The same side move, tied to the scroll position.
Get Started
Add the script.
<script src="https://unpkg.com/ghost-reveal@0.2/dist/ghost-reveal.umd.min.js" data-auto></script> <h2 data-reveal>Hello</h2> <img data-reveal="zoom-in" data-reveal-delay="150" src="…" alt="">
FAQ
Questions #
What JavaScript library animates elements on scroll? #
Ghost Reveal does. Add data-reveal and one script. The element animates into view as it enters the page. The library is free, about 2 KB, and it has no dependencies.
How do I animate an element when it enters the screen? #
Load the script and add data-reveal. A bare attribute is the default fade-up. It rises 16px and sharpens from a 4px blur, over 700ms. The docs start with a three-step install.
Does it need a CSS file? #
No. Ghost Reveal ships no stylesheet. If JavaScript never runs, the element stays visible. Do not set opacity: 0 yourself.
Does it work in React, Vue, and plain HTML? #
Yes. A plain page uses the script tag. In React, Next.js, Vue, Nuxt, Svelte, SvelteKit, Astro, or Angular, call init() once on the client. WordPress can load that same script. The framework guides have a recipe for each.
Can I keep data-aos attributes? #
Yes. The same animation names work. The migrate from AOS guide is the file swap for pages that already use AOS.