Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
yet-another-react-lightbox
Advanced tools
yet-another-react-lightbox is a React component for creating customizable lightbox galleries. It supports various features such as image zoom, fullscreen mode, and keyboard navigation, making it a versatile choice for displaying images in a modern web application.
Basic Lightbox
This code demonstrates how to create a basic lightbox gallery with a set of images. The `Lightbox` component is imported and used with an array of image objects.
import Lightbox from 'yet-another-react-lightbox';
import 'yet-another-react-lightbox/styles.css';
const images = [
{ src: 'image1.jpg', alt: 'Image 1' },
{ src: 'image2.jpg', alt: 'Image 2' }
];
function App() {
return (
<Lightbox slides={images} />
);
}
Fullscreen Mode
This code sample shows how to enable fullscreen mode in the lightbox. By adding the `fullscreen` prop to the `Lightbox` component, users can view images in fullscreen.
import Lightbox from 'yet-another-react-lightbox';
import 'yet-another-react-lightbox/styles.css';
const images = [
{ src: 'image1.jpg', alt: 'Image 1' },
{ src: 'image2.jpg', alt: 'Image 2' }
];
function App() {
return (
<Lightbox slides={images} fullscreen />
);
}
Image Zoom
This code demonstrates how to enable image zoom functionality in the lightbox. By adding the `zoom` prop to the `Lightbox` component, users can zoom in on images.
import Lightbox from 'yet-another-react-lightbox';
import 'yet-another-react-lightbox/styles.css';
const images = [
{ src: 'image1.jpg', alt: 'Image 1' },
{ src: 'image2.jpg', alt: 'Image 2' }
];
function App() {
return (
<Lightbox slides={images} zoom />
);
}
Keyboard Navigation
This code sample shows how to enable keyboard navigation in the lightbox. By adding the `keyboard` prop to the `Lightbox` component, users can navigate through images using the keyboard.
import Lightbox from 'yet-another-react-lightbox';
import 'yet-another-react-lightbox/styles.css';
const images = [
{ src: 'image1.jpg', alt: 'Image 1' },
{ src: 'image2.jpg', alt: 'Image 2' }
];
function App() {
return (
<Lightbox slides={images} keyboard />
);
}
react-image-lightbox is a flexible lightbox component for React applications. It supports features like image zoom, keyboard navigation, and customizable UI. Compared to yet-another-react-lightbox, it offers similar functionalities but with a different API and customization options.
react-photo-gallery is a React component for creating responsive photo galleries. It focuses on layout and presentation, offering features like dynamic resizing and image sorting. While it does not provide a lightbox out of the box, it can be combined with lightbox components like yet-another-react-lightbox for a complete solution.
Modern lightbox component for React.
https://yet-another-react-lightbox.vercel.app/
npm install yet-another-react-lightbox
or
yarn add yet-another-react-lightbox
import * as React from "react";
import Lightbox from "yet-another-react-lightbox";
import "yet-another-react-lightbox/styles.css";
const App = () => {
const [open, setOpen] = React.useState(false);
return (
<>
<button type="button" onClick={() => setOpen(true)}>
Open Lightbox
</button>
<Lightbox
open={open}
close={() => setOpen(false)}
slides={[
{ src: "/image1.jpg" },
{ src: "/image2.jpg" },
{ src: "/image3.jpg" },
]}
/>
</>
);
};
export default App;
MIT © Igor Danchenko
FAQs
Modern React lightbox component
The npm package yet-another-react-lightbox receives a total of 93,053 weekly downloads. As such, yet-another-react-lightbox popularity was classified as popular.
We found that yet-another-react-lightbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.