Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-modal-image-responsive

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-modal-image-responsive

Lightweight Responsive Lightbox React Component

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by10%
Maintainers
2
Weekly downloads
 
Created
Source

react-modal-image

npm package

A lightweight React component providing modal image Lightbox.

DEMO

Features

  • Only 3 kB when gzipped.
  • Zero dependencies.
  • Includes builds for CommonJS and ES modules.
  • For React 16.x, 17.x and 18.x.
  • Esc, Enter & click outside the image close the lightbox
  • User can zoom & move the image or download the highest quality one
  • Download and Zoom -buttons can be hidden.
  • Image alt shown as title of lightbox
  • Background color of transparent images can be overridden.

You need to bring your own Set and fetch polyfills if you use old Internet Explorers.

Simple API

import ModalImage from "react-modal-image";

<ModalImage
  small={urlToTinyImageFile}
  large={urlToHugeImageFile}
  alt="Hello World!"
/>;
PropTypeDescription
classNameStringOptional. class for the small preview image.
altStringOptional. alt for the small image and the heading text in Lightbox.
smallURLsrc for the small preview image.
smallSrcSetStringOptional. srcSet for the small preview image.
mediumURLOptional if large is defined. Image shown when zoomed out in Lightbox.
largeURLOptional if medium is defined. Image shown when zoomed in Lightbox. Downloadable.
hideDownloadbooleanOptional. Set to true to hide download-button from the Lightbox.
hideZoombooleanOptional. Set to true to hide zoom-button from the Lightbox.
showRotatebooleanOptional. Set to true to show rotate-button within the Lightbox.
imageBackgroundColorStringOptional. Background color of the image shown in Lightbox. Defaults to black. Handy for transparent images.  

Lightbox-only API for advanced usage

You can also choose to import only the Lightbox.

To use the Lightbox only, you'll need to handle the open state by yourself:

import { Lightbox } from "react-modal-image";

// ...

const closeLightbox = () => {
  this.state.open = true;
};

// ...

{
  this.state.open && (
    <Lightbox
      medium={urlToLargeImageFile}
      large={urlToHugeImageFile}
      alt="Hello World!"
      onClose={this.closeLightbox}
    />
  );
}
PropTypeDescription
onClosefunctionWill be invoked when the Lightbox requests to be closed

Keywords

FAQs

Package last updated on 11 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc