Thumbnails
The strip of previews at the bottom of the lightbox, loaded lazily at low priority and rendered only in view past 100 slides.
The strip lists every slide as a button. It shows when there is more than one slide.
Live demo. Click a thumbnail to open it.
- The current thumbnail has
aria-current="true"and an outline, and the strip scrolls to center it whenever the slide changes. - The strip scrolls natively with touch, the wheel and the keyboard.
- Images use
slide.thumbnail, thenslide.poster, then the YouTube poster, thenslide.srcfor images, withloading="lazy"and low fetch priority. Thesrcfallback downloads the full image, so pass a small file. Videos without athumbnailorposterget an empty frame, never the video file.previewOf(slide)returns the same choice. - The strip is a
navnamed bylabels.thumbnails. Each button is named bylabels.thumbnail(index, total, slide). - Past 100 slides the strip renders only the thumbnails in view, with spacers standing in for the rest. Each item keeps
aria-setsizeandaria-posinset, so the full count is still announced. This assumes every thumbnail has the width set by--eg-thumbnail-width, including custom content. Jumps longer than the strip, such as Home and End, scroll instantly.
Turning it off
<Lightbox thumbnails={false} {...props} />Custom content
render.thumbnail replaces what is inside each button. The button and its accessible name stay.
<Lightbox
labels={{ thumbnails: "Miniaturas", thumbnail: (i) => `Ver imagem ${i}` }}
render={{
thumbnail: (slide, index, current) => (
<img src={slide.thumbnail} alt="" data-current={current || undefined} />
),
}}
{...props}
/>Styling
Size and look come from these variables:
| Variable | Default |
|---|---|
--eg-thumbnail-width | 72px (56px under 640px) |
--eg-thumbnail-height | 54px (42px under 640px) |
--eg-thumbnail-gap | 6px |
--eg-thumbnail-radius | var(--eg-radius) |
--eg-thumbnail-opacity | 0.5 |
--eg-thumbnail-active-color | var(--eg-color) |
--eg-thumbnails-height | thumbnail height plus spacing |
classNames.thumbnails and classNames.thumbnail add your own classes.