Reveal · Library
Use it in your project
Any of the eleven effects, from either pack, between any two images: a sketch and the final design, a before and an after, a photo and its edit. One import, no dependencies.
- Sites using it
- …
- sites using it
- Page loads
- …
- page loads
Drag the slider, or press play. Click the image too: every effect does something different where you click.
Add it
Install it from npm, or import it straight from a CDN with no build step. Give an element a size, then call reveal on it with the two images.
npm install @brightkumedzro/reveal
<!-- the effect fills this box; anything you put inside stays on top --> <div id="hero" style="height: 80vh"></div> <script type="module"> import { reveal } from 'https://cdn.jsdelivr.net/npm/@brightkumedzro/reveal@1/js/lib.js'; // or, after npm install: import { reveal } from '@brightkumedzro/reveal'; reveal('#hero', { effect: 'water', // any of the eleven, by name from: '/sketch.png', // what gets taken away to: '/final.png', // what's revealed }); </script>
By default it follows the scroll: the reveal runs as the element rises through the screen. The version in the URL is pinned, so an update never changes your page until you bump it. Images from another domain need CORS headers, or they can't be drawn into WebGL.
Just one pack
The main import has every effect. If you only use one pack, import that pack instead for a smaller bundle:
import { reveal } from '@brightkumedzro/reveal/elemental'; // fire · water · air · earth · lightning import { reveal } from '@brightkumedzro/reveal/shinobi'; // clone · vortex · spiral · blade · storm · twister // from the CDN: …/@brightkumedzro/reveal@1/js/elemental/index.js or …/js/shinobi/index.js
Coming from @brightkumedzro/elemental-reveal? It's the same library under a new name. Swap the import for @brightkumedzro/reveal/elemental and everything works as before.
Three ways to drive it
// 1. Scroll (default). Or pin it in a tall wrapper, like the chapters on this site: reveal('#stage', { effect: 'fire', from, to, track: '#tall-wrapper' }); // #tall-wrapper { height: 400vh } #stage { position: sticky; top: 0; height: 100vh } // 2. Plays once when it comes into view reveal('#card', { effect: 'lightning', from, to, progress: 'auto', duration: 3000 }); // 3. You set it: a slider, a video's currentTime, a step in a form… const fx = reveal('#box', { effect: 'earth', from, to, progress: 'manual' }); fx.progress(0.5);
Options
| Option | Default | What it does |
|---|---|---|
effect | 'fire' | 'fire', 'water', 'air', 'earth', 'lightning' (elemental) or 'clone', 'vortex', 'spiral', 'blade', 'storm', 'twister' (shinobi). A pack's import defaults to its first effect. |
from | required | What gets taken away: an image URL, or an <img>, <canvas> or <video>. |
to | required | What's revealed underneath. Same types as from. |
progress | 'scroll' | 'scroll' follows the page, 'auto' plays once when it comes into view, and 'manual' waits for fx.progress(p). |
track | none | Scroll mode: a tall wrapper the element is pinned inside. Progress runs from the wrapper's top reaching the top of the screen to its bottom reaching the bottom. |
duration | 3500 | Auto mode: how long it takes, in milliseconds. |
interactive | true | Hover and click effects. |
fit | 'cover' | How the images fill the element: 'cover', 'contain' or 'fill', like CSS object-fit. |
background | '#0b0b0c' | Shown behind images that don't fill the element. |
sound | 'off' | Synthesised sound, no audio files. 'on' starts at the visitor's first click, tap or key press. 'toggle' waits for fx.sound(true) or any button with a data-reveal-sound attribute. |
onProgress | none | Called every frame with progress from 0 to 1. The draft is gone by about 0.9. |
telemetry | false | Opt in to the anonymous adoption ping (see below) with true. |
showcase | false | Ask to be listed under “Made with Reveal” on /stats. Sends the ping too; your site appears once it’s approved. |
credit | true | One line crediting the library in the browser console. false turns it off. |
What you get back
const fx = reveal(…); await fx.ready; // both images loaded, first frame drawn fx.progress(); // read progress fx.progress(0.3); // set it (switches to manual) fx.play(); // run it from the start over `duration` fx.reset(); // put the draft back and clear clicks fx.sound(true); // turn sound on or off for every reveal on the page fx.destroy(); // remove the canvases and listeners
Good to know
- Each call gets its own WebGL2 canvas. Browsers cap how many can run at once (often around 16), so a few per page is fine. Call
destroy()on ones you're done with. - Without WebGL2 it falls back to a wipe. With reduced motion turned on, it cross-fades, so lightning doesn't flash.
- Anything inside the element stays on top of the effect, so it works as a background behind your own headline or buttons.
- On slow devices it drops its render resolution automatically until it's smooth.
Telemetry
Off by default. If you turn it on with telemetry: true (thank you), the library sends one tiny request per page per effect. It contains the effect name and the library version. The server records your site's domain from the request itself. Nothing about your visitors is sent or stored: no cookies, no IPs, no paths. It never runs on localhost. The totals are public at /stats; no domain is shown unless you ask to be in the showcase with showcase: true. Versions before 0.2.0 sent it by default.
License and credit
MIT licensed: use it in anything, commercial or not. Keeping the copyright notice in the code is the only requirement. If it helps your project, a link back to reveal.brightkumedzro.com is appreciated, never required.
© 2026 Bright Kumedzro · reveal.brightkumedzro.com