liftbox

Styling

Restyle the lightbox with --eg-* CSS variables for colors, fonts, sizes and timings, without CSS-in-JS or inline style tags.

The lightbox is neutral by default: a black backdrop, the counter top left, the toolbar top right and the caption at the bottom. Restyle it with CSS variables on .eg-root, on any ancestor, or through style.

.eg-root {
  --eg-background: #101418;
  --eg-color: #f3efe6;
  --eg-color-muted: rgb(243 239 230 / 0.7);
  --eg-focus-color: #f2b544;
  --eg-arrow-background: rgb(242 181 68 / 0.16);
  --eg-radius: 999px;
  --eg-duration: 480ms;
}
<Lightbox style={{ "--eg-background": "#101418" } as React.CSSProperties} {...props} />

The demo below uses exactly the variables above, and nothing else.

Live demo. Click a thumbnail to open it.

To add your own classes to any part instead, use classNames. See Class names and data attributes.

Light theme

.eg-root {
  --eg-background: #f6f5f2;
  --eg-color: #0b0b0c;
  --eg-color-muted: rgb(11 11 12 / 0.64);
  --eg-focus-color: #0b0b0c;
  --eg-arrow-background: rgb(255 255 255 / 0.7);
  --eg-caption-background: none;
  --eg-selection-background: rgb(11 11 12 / 0.16);
}

Every variable

VariableDefaultUsed for
--eg-background#000Backdrop
--eg-color#fffText and icons
--eg-color-mutedrgb(255 255 255 / 0.72)Counter and description
--eg-focus-color#fffFocus ring
--eg-button-backgroundtransparentToolbar buttons
--eg-arrow-backgroundrgb(0 0 0 / 0.45)Arrows
--eg-caption-backgroundbottom gradientCaption
--eg-selection-backgroundrgb(255 255 255 / 0.28)Text selection
--eg-font-familyinheritAll text
--eg-font-size0.9375remCaption text
--eg-line-height1.5All text
--eg-title-font-size1remCaption title
--eg-title-font-weight600Caption title
--eg-counter-font-size0.875remCounter
--eg-spacing16px (12px under 640px)Outer spacing
--eg-gap24pxGap between slides while sliding
--eg-radius4pxButtons and focus ring
--eg-top-bar-height56pxTop bar
--eg-button-size44pxToolbar buttons
--eg-arrow-size48px (44px under 640px)Arrows
--eg-icon-size24pxIcons
--eg-stage-paddingtop bar height and room for the arrows (top bar height only under 640px)Space around the media
--eg-caption-max-width65chCaption line length
--eg-thumbnail-width72px (56px under 640px)Thumbnail width
--eg-thumbnail-height54px (42px under 640px)Thumbnail height
--eg-thumbnail-gap6pxSpace between thumbnails
--eg-thumbnail-radiusvar(--eg-radius)Thumbnail corners
--eg-thumbnail-opacity0.5Thumbnails other than the current one
--eg-thumbnail-active-colorvar(--eg-color)Outline of the current thumbnail
--eg-thumbnails-heightthumbnail height plus spacingSpace reserved for the strip
--eg-spinner-size32pxLoading indicator
--eg-spinner-delay400msHow long an image may load before the indicator shows
--eg-media-background#111Behind videos, embeds and posters
--eg-placeholder-sizecoverThumbnail placeholder behind a loading image
--eg-progress-height2pxSlideshow progress bar
--eg-progress-colorvar(--eg-color)Slideshow progress bar
--eg-button-opacity0.8Buttons at rest
--eg-button-opacity-hover1Buttons on hover and focus
--eg-disabled-opacity0.32Disabled arrows and buttons
--eg-drag-shrink0.2How much the image shrinks while dragged down
--eg-duration320msEvery animation, including the open and close flight
--eg-easingcubic-bezier(0.2, 0, 0, 1)Every animation
--eg-z-index1000Stacking
--eg-menu-backgroundrgb(24 24 24 / 0.96)Overflow menu
--eg-menu-colorvar(--eg-color)Overflow menu text and icons
--eg-menu-radius8pxOverflow menu corners
--eg-menu-shadow0 8px 24px rgb(0 0 0 / 0.4)Overflow menu shadow
--eg-menu-item-height44pxOverflow menu items
--eg-menu-item-hover-backgroundrgb(255 255 255 / 0.1)Hovered and focused menu item
--eg-pager-height40pxSpace reserved for the pager dots
--eg-pager-dot-size8pxVisible dot, the button is at least 24 by 24px
--eg-pager-dot-gap4pxSpace on each side of a dot
--eg-pager-dot-colorrgb(255 255 255 / 0.4)Dots other than the current one
--eg-pager-dot-active-colorvar(--eg-color)Current dot

Other --eg-* names you may see in the inspector, such as --eg-x, --eg-scale or --eg-drag-progress, are written by the lightbox while it animates. Do not set them.

Tailwind CSS

The stylesheet has no Tailwind dependency and works next to it. Set variables with arbitrary properties on className:

<Lightbox className="[--eg-background:var(--color-zinc-950)] [--eg-radius:9999px]" {...props} />
Edit this page on GitHub

On this page