A modern, accessible lightbox gallery with no dependencies. Perfect for creating responsive image galleries with features like zoom, fullscreen, slideshow, and touch support.
- πΌοΈ Responsive grid layout
- β¨οΈ Full keyboard navigation
- π± Touch gesture support
- π Image zoom capability
- βΆ Fullscreen mode
βΆοΈ Slideshow option- π Thumbnail navigation
- π Image captions
- βΏ Fully accessible (ARIA support)
- π¨ Customizable themes
- π± Mobile-friendly
- 0οΈβ£ Zero dependencies
npm install simple-lightbox-gallery
<!-- Add to your HTML head -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.css">
<script src="https://cdn.jsdelivr.net/npm/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.js"></script>
or
<!-- Add to your HTML head -->
<link rel="stylesheet" href="https://unpkg.com/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.css">
<script src="https://unpkg.com/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.js"></script>
import SimpleLightboxGallery from 'simple-lightbox-gallery';
import 'simple-lightbox-gallery/dist/simple-lightbox-gallery.css';
const gallery = new SimpleLightboxGallery({
containerClass: 'gallery',
showCaption: true
});
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.css">
</head>
<body>
<div class="gallery">
<img src="image1.jpg" alt="Image 1">
<img src="image2.jpg" alt="Image 2">
<img src="image3.jpg" alt="Image 3">
</div>
<script src="https://cdn.jsdelivr.net/npm/simple-lightbox-gallery@1.0.0/dist/simple-lightbox-gallery.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const gallery = new SimpleLightboxGallery({
containerClass: 'gallery'
});
});
</script>
</body>
</html>
Option | Type | Default | Description |
---|---|---|---|
containerClass |
string | 'gallery' | Class name for the gallery container |
lightboxClass |
string | 'lightbox' | Class name for the lightbox element |
animation |
string | 'fade' | Animation type ('fade' or none) |
animationSpeed |
number | 300 | Animation duration in milliseconds |
infinite |
boolean | true | Enable infinite scrolling through images |
showThumbnails |
boolean | false | Show thumbnail navigation panel |
showCaption |
boolean | true | Show image captions |
captionPosition |
string | 'bottom' | Caption position ('top' or 'bottom') |
overlayColor |
string | 'rgba(0, 0, 0, 0.9)' | Background color of the lightbox |
zoomEnabled |
boolean | true | Enable zoom functionality |
zoomLevel |
number | 1.5 | Maximum zoom level |
fullscreen |
boolean | true | Enable fullscreen mode |
swipeEnabled |
boolean | true | Enable touch swipe navigation |
slideshow |
boolean | false | Enable slideshow functionality |
slideshowSpeed |
number | 3000 | Slideshow interval in milliseconds |
Option | Type | Default | Description |
---|---|---|---|
ariaLabels.gallery |
string | 'Image gallery' | ARIA label for gallery |
ariaLabels.lightbox |
string | 'Image lightbox' | ARIA label for lightbox |
ariaLabels.close |
string | 'Close lightbox' | ARIA label for close button |
ariaLabels.next |
string | 'Next image' | ARIA label for next button |
ariaLabels.prev |
string | 'Previous image' | ARIA label for previous button |
ariaLabels.zoom |
string | 'Toggle zoom' | ARIA label for zoom button |
ariaLabels.fullscreen |
string | 'Toggle fullscreen' | ARIA label for fullscreen button |
ariaLabels.slideshow |
string | 'Toggle slideshow' | ARIA label for slideshow button |
const gallery = new SimpleLightboxGallery({
containerClass: 'my-gallery',
showThumbnails: true,
showCaption: true,
animation: 'fade',
zoomEnabled: true,
zoomLevel: 2,
fullscreen: true,
slideshow: true,
slideshowSpeed: 5000,
ariaLabels: {
gallery: 'My custom gallery',
lightbox: 'Image viewer'
}
});
Method | Description |
---|---|
openLightbox(index) |
Opens lightbox at specified image index |
closeLightbox() |
Closes the lightbox |
prevImage() |
Shows previous image |
nextImage() |
Shows next image |
toggleZoom() |
Toggles image zoom |
toggleFullscreen() |
Toggles fullscreen mode |
toggleSlideshow() |
Toggles slideshow |
destroy() |
Removes event listeners and cleans up |
Key | Action |
---|---|
β |
Previous image |
β |
Next image |
Esc |
Close lightbox |
F |
Toggle fullscreen |
Space |
Play/pause slideshow |
Z |
Toggle zoom |
Gesture | Action |
---|---|
Swipe left | Next image |
Swipe right | Previous image |
- β Chrome (latest)
- β Firefox (latest)
- β Safari (latest)
- β Edge (latest)
- β Opera (latest)
- β Chrome for Android
- β Safari iOS
You can customize the appearance using CSS variables:
:root {
--lightbox-overlay: rgba(0, 0, 0, 0.9);
--lightbox-text: #ffffff;
--control-bg: rgba(0, 0, 0, 0.5);
--control-hover-bg: rgba(0, 0, 0, 0.8);
--thumbnail-size: 60px;
--caption-bg: rgba(0, 0, 0, 0.7);
}
- Fully keyboard navigable
- ARIA labels and roles
- Screen reader announcements
- Focus trap in modal
- High contrast support
- Reduced motion support
If you want to use this plugin to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Read more about the commercial license.
If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use this project under the terms of the GPLv3.
Raghu Chinnannan
- Website: https://raghu.ch
- GitHub: @raghuchinnannan
- Twitter: @raghuchinnannan
For support, please open an issue in the GitHub repository.