Slideshow Plugin
Slideshow plugin adds slideshow autoplay feature to the lightbox.
Documentation
The plugin adds the following Lightbox
properties.
Property | Type | Description |
---|---|---|
slideshow | { | Slideshow plugin settings:
Defaults: { autoplay: false, delay: 3000 } |
render | { | Custom render functions:
|
on | { | Lifecycle callbacks.
|
Slideshow Ref
The Slideshow plugin provides a ref object to control the plugin features externally.
// Slideshow ref usage example
const slideshowRef = React.useRef(null);
// ...
return (
<Lightbox
plugins={[Slideshow]}
slideshow={{ ref: slideshowRef }}
on={{
click: () => {
(slideshowRef.current?.playing
? slideshowRef.current?.pause
: slideshowRef.current?.play)?.();
},
}}
// ...
/>
);
Property | Type | Description |
---|---|---|
playing | boolean | Current slideshow playback status. |
disabled | boolean | If true , the slideshow playback is disabled. |
play | () => void | Start the slideshow playback. |
pause | () => void | Pause the slideshow playback. |
Example
import Lightbox from "yet-another-react-lightbox";
import Slideshow from "yet-another-react-lightbox/plugins/slideshow";
import "yet-another-react-lightbox/styles.css";
// ...
return (
<Lightbox
plugins={[Slideshow]}
// ...
/>
);
Live Demo
You can adjust the live demo settings below.
Sandbox
Edit on StackBlitzPlease be advised that StackBlitz sandboxes may not work correctly in your browser. StackBlitz currently fully supports only Chromium-based browsers.