Accessible Mobile-friendly Image Lightbox Library – Parvus.js

Category: Javascript , Modal & Popup | February 6, 2021
Author: deoostfreese
Views Total: 104 views
Official Page: Go to website
Last Update: February 6, 2021
License: MIT


Accessible Mobile-friendly Image Lightbox Library – Parvus.js


An accessible, touch-enabled, user-friendly image lightbox component written in plain JavaScript.


  • Zoom in/out images on hover.
  • Image loading indicator.
  • Scroll or swipe to close just like’s lightbox.
  • Useful API methods and event handlers.

How to use it:

1. You can also install & download the package with NPM.

$ npm i react-spinners-css

2. Add references to Parvus JavaScript & CSS files.

<link rel="stylesheet" href="dist/css/parvus.min.css" />
<script src="dist/js/parvus.min.js"></script>

3. Create a new instance of the Parvus.js and pass the options as follows:

const prvs = new parvus({
      // defaults
      selector: '.lightbox',
      lightboxLabel: 'This is a dialog window which overlays the main content of the page. The modal shows the enlarged image. Pressing the Escape key will close the modal and bring you back to where you were on the page.',
      lightboxLoadingIndicatorLabel: 'Image loading',
      swipeClose: true,
      scrollClose: true,
      threshold: 100,
      transitionDuration: 300,
      transitionTimingFunction: 'cubic-bezier(0.2, 0, 0.2, 1)'

4. Apply the image lightbox to an image element. That’s it.

<a href="full.jpg" class="image-lightbox">
  <img src="thumb.jpg" alt="Image Alt" />
imageSelector = document.querySelector('.image-lightbox');

5. More API methods.

// remove an image element

// open the lightbox;

// close the lightbox

// destroy the instance

// check if is open

6. Bind/unbind event listeners.

// prvs.on(eventName, listener)
//, listener)
prvs.on('open', listener);
prvs.on('close', listener);
prvs.on('destroy', listener);



  • Use rem instead of px

You Might Be Interested In:

Leave a Reply