Skip to the content

Zoom lightbox

A picture viewer mounted by one attribute on a group of pictures.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The look of the preview is the zoom-lightbox-* classes of the paste. The code is longer than one Webflow Embed holds, so the paste brings two: this stylesheet and the settings are the first, the script of the next step the second. The first Embed holds the look of the viewer, and reads five variables, --zoom-lightbox-ground (the sheet behind the picture), --zoom-lightbox-ink, --zoom-lightbox-accent, --zoom-lightbox-label-font and --zoom-lightbox-pad: set them on the group, or on anything above it, in a rule of your own. The caption takes the typeface of the group.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-zoom-lightbox Marks the group of pictures. It takes no value: leave the value field empty. Every picture inside it opens in the viewer, in the order of the page, one picture or forty, any shape. The settings below go on the same element.
    data-zoom-lightbox-caption On a picture, with a few words as its value: the caption of that picture in the viewer, in place of its alt. Left empty, that picture has no caption. Without it the caption is the figcaption around the picture, or its alt. [ Optional ]
    data-zoom-lightbox-src On a picture, with the address of a larger file as its value: what the viewer lays over the picture of the page once it has arrived. Without it the viewer takes the file a link around the picture leads to, or the largest candidate of its srcset, which is what a Webflow Image carries, or the picture of the page itself. [ Optional ]
    data-zoom-lightbox-item On a few pictures of the group, with no value: only those open in the viewer and the others are left alone. Without it on any picture, every picture of the group opens. [ Optional ]
    data-zoom-lightbox-away Written by the engine on the thumbnail whose picture is in the viewer, so its place stays empty; each picture that opens also carries data-zoom-lightbox-trigger, the group data-zoom-lightbox-ready, and the viewer data-zoom-lightbox-state (opening, open, dragging, closing) and data-zoom-lightbox-ui while its words are shown. Never written by hand; the stylesheet reads them, and so can a rule of yours. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-zoom-lightbox-duration 0.95 The time the picture takes from its thumbnail to full size, in seconds. The way back, the change of picture and the words follow it.
    data-zoom-lightbox-arc 0.5 How much the trip bows away from the straight line, and how much the picture leans into it.
    data-zoom-lightbox-loop on Whether the last picture leads to the first. Options: on, Next on the last picture goes to the first and Prev on the first to the last; off, the two ends stop, and the button that leads nowhere is dimmed.
    data-zoom-lightbox-close Close The word of the button that closes the viewer. Options: any short word, in the language of the page: Fermer, Schliessen.
    data-zoom-lightbox-prev Prev The word of the button that goes to the picture before. Options: any short word, in the language of the page: Avant.
    data-zoom-lightbox-next Next The word of the button that goes to the picture after. Options: any short word, in the language of the page: Suivant.

What it does

Zoom lightbox is a site utility component for Webflow and vanilla JavaScript, with no library. Also called image lightbox gallery, lightbox custom or lightbox zoom from thumbnail.

A picture viewer mounted by one attribute on a group of pictures. A click on a thumbnail lifts that very picture off the page: it travels to the middle of the screen on a bow, leaning a little into the trip, and opens out of the crop its thumbnail had to its whole shape, while its dark ground spreads from the edges of the thumbnail to the edges of the screen as a sharp sheet, never a fade. The count, the caption and three words, Close, Prev and Next, come up from under their own feet once the picture is nearly there. From one picture to the next the frame stays: it takes the shape of the next picture while a line crosses it, the picture that leaves on one side and the one that comes on the other. On the way out the picture goes back to its thumbnail, the ground closing on it, and the page has been scrolled behind the ground so that the thumbnail is there to receive it. The picture can be dragged: across for the next one, up or down to take it off its ground and let it go home, with the mouse or a finger. A native dialog: focus kept inside, Escape, arrows, Home and End, the page held still without a sideways jump, the focus given back to the thumbnail. One picture or forty, any shape, a caption read from the alt, an attribute or a figcaption, a larger file from a link or a srcset laid over the small one when it has arrived. Reduced motion respected. No library. Pattern type lightbox, image viewer, gallery zoom.

Updated

Questions

Select the block that holds your Image elements and add the custom attribute data-zoom-lightbox with an empty value. Every image inside it opens in the viewer, in the order of the Navigator, one image or forty, any shape. The code goes in two Embeds, which the paste brings with it.

Yes, that is what this one does. The thumbnail itself leaves its place, travels to the middle of the screen on a curve and opens out of the crop the page gave it, object-fit: cover included, while a dark ground spreads from its edges. On the way out it flies back to the same thumbnail.

Yes. A drag across the picture goes to the next one or the one before, and a drag up or down takes the picture off its ground and sends it back to its thumbnail, with a finger or the mouse. Let go early and it returns to the middle.

The caption is the alt of the image. To say something else, put data-zoom-lightbox-caption on the image with your words, or leave that attribute empty for no caption. A figcaption in a figure around the image is read as well.

Yes. It opens in a native dialog: the focus stays among its three buttons, Left and Right change the picture, Home and End go to the first and the last, Escape closes, and the focus returns to the thumbnail. The page behind is held still without jumping sideways, and under reduced motion everything opens and closes at once.

Yes, three ways: a srcset on the image, which a Webflow Image already carries, a link around the image that leads to the large file, or data-zoom-lightbox-src. The viewer shows the file the page already has at once and lays the large one over it when it is decoded, so nothing blinks.