v0.2 · zero deps · no CSS · ~2 KB

GhostReveal

A modern JavaScript scroll-reveal library

Scroll reveals that feel expensive and weigh nothing

npm i ghost-reveal <div data-reveal>
Scroll

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.

See the full demonstration

See it, then add it. #

The docs start with the attribute and one script, then cover every option and a guide for each framework. The Playground plays all 23 animations.

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.

Blur

Choose how soft the start is.

data-reveal-blur="0" is a crisp fade. A higher number starts more out of focus.

blur 0

Crisp

Opacity and travel only.

blur 4 (default)

Subtle

A light blur. This is the default.

blur 12 · 1000ms

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.

Ghost.

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.

fade-up
fade-down
fade-left
fade-right
zoom-in
zoom-out
zoom-in-up
flip-up
flip-left
slide-up
slide-left
slide-right

Migrate from AOS

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.