liftbox

Class names and data attributes

Stable eg-* classes and state attributes to select on.

Adding your own classes

classNames adds classes next to the built-in ones, part by part. className and style go on the root.

<Lightbox
  className="my-lightbox"
  classNames={{ caption: "prose prose-invert", thumbnail: "rounded-full" }}
  {...props}
/>

Prop

Type

Built-in classes

Every part has a stable class you can target from your own CSS:

ClassPart
eg-rootThe dialog
eg-backdropThe background
eg-stageThe area that holds slides and receives swipes
eg-slideEach mounted slide
eg-zoom, eg-rotateWrappers that carry the zoom and rotation
eg-image, eg-video, eg-embed, eg-embed-posterMedia
eg-errorThe message shown when an image fails
eg-top-bar, eg-counter, eg-toolbarThe top bar and its contents
eg-buttonEvery built-in button
eg-arrow, eg-arrow-prev, eg-arrow-nextThe arrows
eg-caption, eg-caption-title, eg-caption-descriptionThe caption
eg-slide-captionThe box over each media with captionPosition="slide"
eg-thumbnails, eg-thumbnails-track, eg-thumbnails-itemThe thumbnail strip
eg-thumbnail, eg-thumbnail-imageEach thumbnail button and its image
eg-progressThe slideshow progress bar
eg-more, eg-menu, eg-menu-item, eg-menu-scrimThe overflow menu button, menu, items and backdrop
eg-pager, eg-pager-dotThe pager dots
eg-iconEvery icon drawn with Icon
eg-sr-onlyText for screen readers only

Data attributes

State is exposed as attributes:

AttributeOnValues
data-state.eg-rootopening, open, closing
data-transition.eg-rootslide, fade, zoom
data-dragging.eg-roothorizontal, vertical, only while dragging
data-zoomed.eg-rootpresent while the image is magnified
data-thumbnails.eg-rootpresent when the strip is shown
data-playing.eg-rootpresent while the slideshow plays
data-pager.eg-rootpresent when the pager dots are shown
data-idle.eg-rootpresent while idle controls are hidden
data-menu.eg-rootpresent while the overflow menu is open
dir.eg-rootltr, rtl
data-current.eg-slidepresent on the visible slide
data-status.eg-slideloading, loaded, error, built-in images only
data-gesture.eg-zoompresent while a pinch, pan or wheel zoom follows the pointer
.eg-root[data-zoomed] .eg-caption {
  opacity: 0;
}

.eg-slide[data-status="error"] {
  background: repeating-linear-gradient(45deg, #111 0 8px, #181818 8px 16px);
}

Opting out of gestures

Add data-eg-no-gestures to any element inside a slide, and drags that start inside it are left alone. It is meant for custom controls in render overrides.

Edit this page on GitHub

On this page