1.1.1 • Published 4 years ago

react-lightboxable v1.1.1

Weekly downloads
16
License
MIT
Repository
github
Last release
4 years ago

React Lightboxable - :bulb: :package:

Simple React.js component that displays an image on a fullscreen lightbox, toggled with a click event on the provided thumbail element.

License: MIT Tests

Features

  • zero external dependencies :ok_hand:;
  • uses React Portals for the lightbox container :cyclone:;
  • easily extendable and overwritable css classes :art:;
  • handles the Escape key as a medium to close the lightbox.

Installation

$ npm install --save-dev react-lightboxable

Demo

A live demo is available on Codesandbox.io

Usage

import React from 'react';

import ReactLightboxable from 'react-lightboxable';

// the thumbnail element
const Preview = _ => <img src="https://source.unsplash.com/300x200" />;
// or just <img src="https://source.unsplash.com/300x200" />

// main component
function Example () {
    return (
        <ReactLightboxable
            preview={<Preview />}
            fullWidthUrl="https://source.unsplash.com/1200x800"
            fullWidthAlt="lightbox image alt tag"
        />
    );
}

Props and usage

Super simple, just three props

prop namedescription
previewThe thumbail element, can be a React component or a DOM element
fullWidthUrlThe url of the image to display in full screen inside the lightbox
fullWidthAltThe alt tag of the image to display in full screen inside the lightbox

Css and classes overwrite

The css classes used in the default styling

class namedescription
.lightboxable-modalwrapper element for the lightbox component
.lightboxable-modal__closeclose button on top right corner
.lightboxable-modal__backgrounddark background with click-away listener
.lightboxable-modal__imagethe actual image
.lightboxable-previewwrapper element for the thumbail component prop
1.1.1

4 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago