Lightweight, accessible and responsive lightbox.


Lity is a ultra-lightweight, accessible and responsive lightbox plugin which supports images, iframes and inline content out of the box.

Minified and gzipped, its total footprint weights about 3kB.

It requires jQuery or Zepto (with the callbacks, deferred and data modules).


Image Inline Google Maps YouTube Vimeo URL


All ready-to-use files are located in the dist/ directory.

Include the Lity javascript and css files and its dependencies in your HTML document:

<link href="dist/lity.css" rel="stylesheet">
<script src="vendor/jquery.js"></script>
<script src="dist/lity.js"></script>

Lity can also be installed via Bower or npm.



Add the data-lity attribute to <a> elements for which you want the links to be opened in a lightbox:

<a href="" data-lity data-lity-desc="Photo of a flower">Image</a>
<a href="#inline" data-lity>Inline</a>
<a href="//" data-lity>iFrame Youtube</a>
<a href="//" data-lity>iFrame Vimeo</a>
<a href="//,+Mountain+View,+CA" data-lity>Google Maps</a>

<div id="inline" style="background:#fff" class="lity-hide">
Inline content

If you want to open another URI than defined in the href attribute, just add a data-lity-target with the URI:

<a href="/image.html" data-lity data-lity-target="/image-preview.jpg">Image</a>


Use the global lity function to open URLs (or HTML) in a lightbox or as an event handler.

// Open a URL in a lightbox
var lightbox = lity('//');

// Bind as an event handler
$(document).on('click', '[data-lightbox]', lity);

If you want to close the opened lightbox, use lightbox.close().

Copyright (c) 2015- Jan Sorgalla. Released under the MIT license.

Fork me on GitHub