Skip to content

@redot-src/glarev1.2.1Zero dependenciesMIT

Click any frame.

Glare is a touch-first lightbox for the web. It opens images, video, YouTube, Vimeo, maps, iframes, nodes from the page, and plain HTML, with zoom, swipe, thumbnails, and a slideshow built in.

Get started

Any content

Image galleries are the default. Everything else opens the same way: Glare detects the type from the URL, or you set type yourself.

Options, live

Each card runs the call it shows. slides is the six frames from the light table.

Slideshow

Autoplays on open. Controls hide after two idle seconds.

Glare.open(slides, {
  loop: true,
  slideshow: {
    autoStart: true,
    speed: 2200,
  },
  idleTime: 2,
})

Thumbnails

The thumbnail strip is visible from the start.

Glare.open(slides, {
  loop: true,
  thumbs: {
    autoStart: true,
  },
})

Circular transition

Slides rotate through; the dialog fades in instead of zooming.

Glare.open(slides, {
  loop: true,
  transitionEffect: 'circular',
  animationEffect: 'fade',
})

Start at a slide

The third argument is the index to open on.

Glare.open(slides, {
  loop: true,
}, 2)

Protected images

Blocks the context menu and dragging. Only zoom and close remain.

Glare.open(slides, {
  protect: true,
  buttons: ['zoom', 'close'],
})

Modal

Only the close button dismisses it. Keyboard and backdrop clicks are ignored.

Glare.open(slides, {
  modal: true,
})

Install

bash
npm install @redot-src/glare
js
import Glare from '@redot-src/glare'
import '@redot-src/glare/style.css'

Glare.bind('[data-glare]', { loop: true })
html
<a data-glare="gallery" href="photo.jpg" data-caption="Hello">
  <img src="thumb.jpg" alt="Hello" />
</a>
html
<link rel="stylesheet" href="https://unpkg.com/@redot-src/glare/dist/glare.css" />
<script src="https://unpkg.com/@redot-src/glare/dist/glare.js"></script>
<script>
  Glare.bind('[data-glare]')
</script>

Continue with Getting started or the API reference.

Keyboard

KeyAction
EscClose
Previous, next
SpaceStart or stop the slideshow
FToggle fullscreen
ClickZoom an image
Drag, pinchPan and zoom when zoomed in
SwipeChange slide, or pull to close

Released under the MIT License.