Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-lightbox-gallery

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-lightbox-gallery

A modern, accessible, simple lightbox gallery with no dependencies

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57
Maintainers
0
Weekly downloads
 
Created
Source

npm version npm downloads commit size hits

A modern, accessible lightbox gallery with no dependencies. Perfect for creating responsive image galleries with features like zoom, fullscreen, slideshow, and touch support.

Features

  • 🖼️ 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

Installation

NPM

npm install simple-lightbox-gallery

CDN

<!-- 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>

Usage

ES6 Module

import SimpleLightboxGallery from 'simple-lightbox-gallery';
import 'simple-lightbox-gallery/dist/simple-lightbox-gallery.css';

const gallery = new SimpleLightboxGallery({
    containerClass: 'gallery',
    showCaption: true
});

Script Tag

<!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>

Configuration Options

OptionTypeDefaultDescription
containerClassstring'gallery'Class name for the gallery container
lightboxClassstring'lightbox'Class name for the lightbox element
animationstring'fade'Animation type ('fade' or none)
animationSpeednumber300Animation duration in milliseconds
infinitebooleantrueEnable infinite scrolling through images
showThumbnailsbooleanfalseShow thumbnail navigation panel
showCaptionbooleantrueShow image captions
captionPositionstring'bottom'Caption position ('top' or 'bottom')
overlayColorstring'rgba(0, 0, 0, 0.9)'Background color of the lightbox
zoomEnabledbooleantrueEnable zoom functionality
zoomLevelnumber1.5Maximum zoom level
fullscreenbooleantrueEnable fullscreen mode
swipeEnabledbooleantrueEnable touch swipe navigation
slideshowbooleanfalseEnable slideshow functionality
slideshowSpeednumber3000Slideshow interval in milliseconds

Accessibility Options

OptionTypeDefaultDescription
ariaLabels.gallerystring'Image gallery'ARIA label for gallery
ariaLabels.lightboxstring'Image lightbox'ARIA label for lightbox
ariaLabels.closestring'Close lightbox'ARIA label for close button
ariaLabels.nextstring'Next image'ARIA label for next button
ariaLabels.prevstring'Previous image'ARIA label for previous button
ariaLabels.zoomstring'Toggle zoom'ARIA label for zoom button
ariaLabels.fullscreenstring'Toggle fullscreen'ARIA label for fullscreen button
ariaLabels.slideshowstring'Toggle slideshow'ARIA label for slideshow button

Example Usage

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'
    }
});

API Methods

MethodDescription
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

Keyboard Shortcuts

KeyAction
Previous image
Next image
EscClose lightbox
FToggle fullscreen
SpacePlay/pause slideshow
ZToggle zoom

Touch Gestures

GestureAction
Swipe leftNext image
Swipe rightPrevious image

Browser Compatibility

  • ✅ Chrome (latest)
  • ✅ Firefox (latest)
  • ✅ Safari (latest)
  • ✅ Edge (latest)
  • ✅ Opera (latest)
  • ✅ Chrome for Android
  • ✅ Safari iOS

CSS Customization

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);
}

Accessibility

  • Fully keyboard navigable
  • ARIA labels and roles
  • Screen reader announcements
  • Focus trap in modal
  • High contrast support
  • Reduced motion support

License

Commercial license

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.

Open source 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.

Author

Raghu Chinnannan

Support

For support, please open an issue in the GitHub repository.

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc