Yet Another React Lightbox (YARL) is a modern, performant, and highly customizable React component designed for displaying images and and videos in a lightbox interface. Currently at stable version 3.31.0, it receives frequent updates, with several patch and minor releases in recent months, indicating an active development cadence. Key differentiators include its focus on responsive images using `srcset` and `sizes` for optimal loading, support for various navigation methods (keyboard, mouse, touch), and a modular architecture that utilizes optional plugins for features like zoom, captions, and video support. It is built to work with React versions 16.8.0 through 19, provides built-in TypeScript definitions, and is compatible with RTL layouts, ensuring broad compatibility and developer experience.
npm install yet-another-react-lightboxVerified import paths — ran on the pinned version, not inferred.
This example demonstrates the minimal setup for Yet Another React Lightbox, showing how to open and close the lightbox and provide a basic array of image slides.
Add `import 'yet-another-react-lightbox/styles.css';` to your entry file or a component where the Lightbox is used.
Import desired plugins (e.g., `import Zoom from 'yet-another-react-lightbox/plugins/zoom';`) and include them in the `plugins={[Zoom]}` array prop of the Lightbox component. Remember to also import any associated plugin CSS (e.g., `import 'yet-another-react-lightbox/plugins/zoom.css';`).Ensure your project's `react` and `react-dom` peer dependencies are updated to `^16.8.0` or newer.
For each image slide, provide `width`, `height`, and an array of `srcSet` objects containing different resolutions: `slides={[{ src: '/image.jpg', width: 1200, height: 800, srcSet: [{ src: '/image_sm.jpg', width: 320 }] }]}`.Review the full v3 changelog on GitHub. Ensure `slides` and `index` are treated as stable array references (e.g., using `useState` or `useMemo`). Adjust animation settings if custom easing was previously applied.
Ensure you have `import Lightbox from 'yet-another-react-lightbox';` at the top of your file.
Add `import 'yet-another-react-lightbox/styles.css';` to your application's entry point or the component file where the Lightbox is used.
Upgrade your `react` and `react-dom` packages to version `^16.8.0` or newer in your `package.json` and reinstall dependencies.
Plugins must be imported from their specific paths, e.g., `import Zoom from 'yet-another-react-lightbox/plugins/zoom';`.