npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

turbolight

v1.0.5

Published

A lightweight, vanilla JavaScript lightbox that works with Turbo Streams

Downloads

5

Readme

TurboLight

Frustrated by the lack of support from existing lightbox plugins and disappointed I cannot use the original lightbox from lokesh I created a new and shiny plugin with all the features and none of the dependencies! It is lightweight, vanilla Javascript that works seamlessly with Turbo Streams and Rails but also as a standalone.

Features

  • 🪶 Lightweight with zero dependencies
  • 🚀 Turbo compatibility
  • 📱 Responsive design
  • ⌨️ Keyboard navigation
  • 📝 Caption support
  • 🔢 Counter display

Demo

Check out the live demo.

The npm package is available on the registry

Installation

For Rails Applications

1. Install

yarn add turbolight
# or
npm install turbolight

2. Import the module

with importmap-rails

In your config/importmap.rb:

pin "turbolight", to: "turbolight/dist/index.esm.js"
with jsbundling

In your JavaScript file:

import TurboLight from "turbolight";

// Or CommonJS require
const TurboLight = require('turbolight');

3. Add CSS

In your app/assets/stylesheets/application.scss:

@import "turbolight/dist/turbolight";

Or in your app/assets/stylesheets/application.css:

/*
 *= require turbolight/dist/turbolight
 */

4. Add your HTML markup

<!-- Single image -->
<%= link_to "path/to/image.jpg", data: { turbolight: "gallery1", title: "The caption" } do %>
    <%= faw_icon 'regular', 'expand-arrows-alt' %>
<% end %>

<!-- Multiple images in a gallery -->
<%= link_to "path/to/image.jpg", data: { turbolight: "gallery2", title: "The caption" } do %>
    <%= faw_icon 'regular', 'expand-arrows-alt' %>
<% end %>
<%= link_to "path/to/image.jpg", data: { turbolight: "gallery2", title: "The caption" } do %>
    <%= faw_icon 'regular', 'expand-arrows-alt' %>
<% end %>

What is faw_icon you ask? It is a gem I have built around fontawesome icons.

5. Initialize TurboLight

// Initialize with default options
new TurboLight();

// Or with custom options
new TurboLight({
  imageClass: 'custom-image-class',
  captionClass: 'custom-caption-class',
  // ... more options
});
Using with Stimulus

Create a Stimulus controller for TurboLight. If you are going to be using the controller then you don't really to import in application.js as well.

// app/javascript/controllers/turbo_light_controller.js
import { Controller } from "@hotwired/stimulus"
import TurboLight from "turbolight";

// Connects to data-controller="turbo-light"
export default class extends Controller {
  connect() {
    this.turboLight = new TurboLight();
  }

  disconnect() {
    if (this.turboLight && this.turboLight.isOpen) {
      this.turboLight.close();
    }
  }
}

Then register it in your controllers index:

// app/javascript/controllers/index.js
import { application } from "./application"
import TurboLightController from "./turbo_light_controller"
application.register("turbo-light", TurboLightController)

6. Enjoy

Enjoy the blazing fast performance.

Using as a standalone

1. Install

yarn add turbolight
# or
npm install turbolight

2. Import

Add the CSS to your page for styling the lightbox

<link rel="stylesheet" href="node_modules/turbolight/dist/turbolight.css">

Or import it in your CSS/SCSS file

@import 'turbolight/dist/turbolight.css';

For javascript there are a couple ways to do it

  <script type="module">
    import TurboLight from './node_modules/turbolight/dist/index.esm.js';
    const lightbox = new TurboLight();
  </script>

Or

    <script src="node_modules/turbolight/dist/index.umd.min.js" type="text/javascript"></script>

    document.addEventListener('DOMContentLoaded', function() {
        new TurboLight.default();
    });

API Documentation

Constructor Options

const lightbox = new TurboLight({
  // CSS class names for customization
  overlayClass: 'turbo-light-overlay',
  containerClass: 'turbo-light-container',
  imageClass: 'turbo-light-image',
  captionClass: 'turbo-light-caption',
  counterClass: 'turbo-light-counter',
  closeClass: 'turbo-light-close',
  prevClass: 'turbo-light-prev',
  nextClass: 'turbo-light-next',
  activeClass: 'turbo-light-active',
  loadingClass: 'turbo-light-loading'
});

Methods

init()

Initializes the lightbox by finding all links with data-turbolight attribute and setting up event listeners.

lightbox.init();

open(galleryName, index = 0)

Opens the lightbox for a specific gallery at the specified index.

// Open the first image in "gallery1"
lightbox.open('gallery1', 0);

close()

Closes the currently open lightbox.

lightbox.close();

next()

Shows the next image in the current gallery.

lightbox.next();

previous()

Shows the previous image in the current gallery.

lightbox.previous();

showImage(index)

Shows a specific image by index in the current gallery.

// Show the third image (index 2) in the current gallery
lightbox.showImage(2);

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request