Thumbnails Plugin
Thumbnails plugin adds a thumbnail preview to the lightbox. Image and video
slides are supported out of the box. You can specify a thumbnail image for
custom slide types or override the default thumbnail by adding a thumbnail
slide prop to your slides.
The plugin comes with an additional CSS stylesheet.
import "yet-another-react-lightbox/plugins/thumbnails.css";
Documentation
Thumbnails plugin adds the following Lightbox
properties:
Property | Type | Description |
---|---|---|
thumbnails | { | Thumbnails plugin settings:
Defaults: { position: "bottom", width: 120, height: 80, border: 1, borderRadius: 4, padding: 4, gap: 16, imageFit: "contain", vignette: true } |
render | { | Custom thumbnail render function. |
and the following Slide
properties:
Property | Type | Description |
---|---|---|
thumbnail | string | Thumbnail image. |
Thumbnails Ref
The plugin provides a ref object to control its features externally.
// Thumbnails ref usage example
const thumbnailsRef = React.useRef(null);
// ...
return (
<Lightbox
plugins={[Thumbnails]}
thumbnails={{ ref: thumbnailsRef }}
on={{
click: () => {
(thumbnailsRef.current?.visible
? thumbnailsRef.current?.hide
: thumbnailsRef.current?.show)?.();
},
}}
// ...
/>
);
Property | Type | Description |
---|---|---|
visible | boolean | If true , thumbnails are visible. |
show | () => void | Show thumbnails. |
hide | () => void | Hide thumbnails |
Example
import Lightbox from "yet-another-react-lightbox";
import Thumbnails from "yet-another-react-lightbox/plugins/thumbnails";
import "yet-another-react-lightbox/styles.css";
import "yet-another-react-lightbox/plugins/thumbnails.css";
// ...
return (
<Lightbox
plugins={[Thumbnails]}
// ...
/>
);
Live Demo
You can adjust the live demo settings below.