Skip to content

Options

Every option, grouped the way you will reach for it. Pass options to Glare.bind() or Glare.open(), or change Glare.defaults once for the whole app.

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

Options given to bind() or open() are merged over Glare.defaults. Module options (slideshow, thumbs, fullscreen, share) merge one level deeper, so { slideshow: { speed: 5000 } } keeps autoStart at its default.

Behavior

OptionDefaultWhat it does
loopfalseWrap around at the ends of a gallery. When off, the arrows are disabled on the first and last slide.
closeExistingfalseClose any open lightbox before opening this one. Otherwise instances stack.
keyboardtrueKeyboard shortcuts: Esc, arrows, Space, F.
protectfalseBlock the context menu and image dragging, to discourage saving.
modalfalseDialog mode: no keyboard shortcuts, no idle fade, and clicks on the backdrop or around the media do nothing.
idleTime3Seconds without activity before arrows, counter, and caption fade. The toolbar stays. false keeps everything visible.
hideScrollbartrueLock page scrolling while open, compensating for the scrollbar width so the page does not shift.
autoFocustrueMove focus into the dialog on open.
trapFocustrueKeep Tab inside the dialog.
backFocustrueReturn focus to the trigger on close.
defaultType'image'Type to assume when the URL has no recognizable extension. See detection rules.
parentEl'body'Where the dialog is mounted: a selector or an element.
baseClass''Extra class for the container, for scoping your CSS.
slideClass''Extra class for every slide.

A one-slide dialog that only the close button can dismiss:

js
Glare.open([{ type: 'html', html: '<h3>Saved</h3><p>Your changes are live.</p>' }], { modal: true })

Chrome

The chrome is everything around the media: arrows, counter, caption, and toolbar.

OptionDefaultWhat it does
arrowstruePrevious and next buttons. Hidden automatically for single-slide groups.
infobartrueThe 2 / 12 counter. Hidden automatically for single-slide groups.
toolbar'auto''auto' shows the toolbar on image slides only; true on every slide; false never. Slides without a toolbar get a compact close button.
smallBtn'auto'The compact close button on the slide itself. 'auto' uses it whenever the toolbar is hidden.
buttonssee belowToolbar buttons, in order. Buttons that do not apply (thumbnails for one slide, fullscreen without browser support) are skipped.
captionA string, or (instance, current) => string, that replaces the slide's own caption.

The default buttons list is ['zoom', 'slideshow', 'thumbs', 'share', 'download', 'fullscreen', 'close']. Read more in Toolbar & UI.

Motion

OptionDefaultWhat it does
animationEffect'zoom'Open and close animation. 'zoom' flies the image from its trigger; 'fade' cross-fades; false opens instantly.
animationDuration366Open and close duration in milliseconds.
zoomOpacitytrueAlso fade the image while it flies in with 'zoom'.
transitionEffect'fade'Effect between slides: 'fade', 'slide', 'circular', 'tube', 'rotate', 'zoom-in-out', or false.
transitionDuration366Slide change duration in milliseconds.

Both durations are written to the container as --glare-duration and --glare-transition-duration, so custom CSS can reuse them. Users with prefers-reduced-motion get instant changes regardless.

Interaction

OptionDefaultWhat it does
clickContentzoom images, ignore other typesClick on the media itself.
clickSlide'close'Click on the empty area around the media, or on the backdrop.
dblclickContentfalseDouble-click on the media.
dblclickSlidefalseDouble-click around the media.
wheel'auto'Mouse wheel changes slides. 'auto' only over images that are not zoomed; true always; false never.
touch{ vertical: true, momentum: true }Swipe, pinch, and pan. vertical allows swipe-down to close; momentum keeps panning briefly after release. false disables gestures.
mobilesee belowOption overrides applied on touch-first devices.

Click actions accept false, 'close', 'next', 'nextOrClose', 'toggleControls', 'zoom', or a function (current, event) that returns one of those. When a double-click action is set, single clicks wait briefly so a double-tap does not trigger both.

On touch-first devices the built-in mobile overrides change what a tap does: a tap on an image toggles the controls, a double tap zooms, a tap around non-image content closes, and idleTime is off so the controls never disappear on their own. Override any of them the same way:

js
{
  mobile: {
    dblclickContent: false, // keep double-tap zoom off
    idleTime: 3,
  },
}

Content

OptionDefaultWhat it does
image.preloadfalseStart loading the previous and next image while the current one is shown.
video{ autoStart: true, format: '', tpl }HTML5 video. format is a MIME type; when empty it is inferred from the extension.
iframe{ preload: true, css: {}, attr: {…}, tpl }Iframe slides. preload: false shows the slide before the frame has loaded. attr sets iframe attributes.
ajax.settings{ headers: { 'X-Requested-With': 'XMLHttpRequest' } }fetch() init for AJAX slides.
mediaYouTube, Vimeo, Google MapsURL matchers that turn share links into embeds. See Media providers.

Modules

Each module accepts true for its defaults, false to turn it off, or an object that is merged over the defaults.

OptionDefaultWhat it does
hashtrueKeep the URL hash in sync with the current slide of a named gallery.
slideshow{ autoStart: false, speed: 3000 }Autoplay. speed is the time per slide in milliseconds.
thumbs{ autoStart: false, axis: 'x' }Thumbnail strip. axis: 'y' places it on the side.
fullscreen{ autoStart: false }Fullscreen toggle. Not created where the browser lacks the Fullscreen API.
sharetrueShare overlay. Accepts { url, tpl }.

Details for each live in Modules.

Text and templates

OptionDefaultWhat it does
lang'en'Which i18n dictionary to use.
i18n{ en: { … } }Dictionaries keyed by language. Missing keys fall back to English. See Labels.
baseTpl, btnTpl, spinnerTpl, errorTplbuilt inHTML templates for the dialog, each toolbar button, the spinner, and the error message. See Templates.

Events

Callbacks such as afterShow and beforeClose are options too. They are listed in Events.

Changing defaults globally

Glare.defaults is a plain object. Changes apply to every lightbox opened afterwards:

js
Glare.defaults.loop = true
Glare.defaults.buttons = ['zoom', 'close']

Released under the MIT License.