Coder Social home page Coder Social logo

kjaenicke / react-modal-image Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aautio/react-modal-image

1.0 2.0 0.0 3.27 MB

A tiny React component providing modal image Lightbox.

Home Page: https://aautio.github.io/react-modal-image/

License: MIT License

JavaScript 100.00%

react-modal-image's Introduction

react-modal-image

CircleCI 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 15.x and 16.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 polyfill if you use old Internet Explorers.

Simple API

import ModalImage from "react-modal-image";

<ModalImage
  small={urlToTinyImageFile}
  large={urlToHugeImageFile}
  alt="Hello World!"
/>;
Prop Type Description
className String Optional. class for the small preview image.
alt String Optional. alt for the small image and the heading text in Lightbox.
small URL src for the small preview image.
smallSrcSet String Optional. srcSet for the small preview image.
medium URL Optional if large is defined. Image shown when zoomed out in Lightbox.
large URL Optional if medium is defined. Image shown when zoomed in Lightbox. Downloadable.
hideDownload boolean Optional. Set to true to hide download-button from the Lightbox.
hideZoom boolean Optional. Set to true to hide zoom-button from the Lightbox.
showRotate boolean Optional. Set to true to show rotate-button within the Lightbox.
imageBackgroundColor String Optional. 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}
    />
  );
}
Prop Type Description
onClose function Will be invoked when the Lightbox requests to be closed

react-modal-image's People

Contributors

aautio avatar ivankoop avatar dependabot[bot] avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.