@cratejoy/lightbox

1.3.1 • Public • Published

@cratejoy/lightbox

styled-components friendly lightbox with portals

NPM JavaScript Style Guide

Install

npm install --save @cratejoy/lightbox

Usage

import React from 'react'

import Lightbox from '@cratejoy/lightbox'

const imgs = [
  {
    url: 'https://picsum.photos/400/400?random',
    thumb: 'https://picsum.photos/100/100'
  },
  {
    url: 'https://picsum.photos/500/700?random',
    thumb: 'https://picsum.photos/100/100'
  },
  {
    url: 'https://picsum.photos/500/500?random',
    thumb: 'https://picsum.photos/100/100'
  },
  {
    url: 'https://picsum.photos/800/800?random',
    thumb: 'https://picsum.photos/100/100'
  },
]

const Example = () => (
  <Lightbox src={imgs} open>
    {({ toggleOpen, openByIndex }) => (
      <div>
        <button onClick={toggleOpen}>Trigger Lightbox</button>
        <button onClick={openByIndex(2)}>Open the 3rd img</button>
        <button onClick={openByIndex(0)}>Open the first img</button>
      </div>
    )}
  </Lightbox>
)

export default Example

License

MIT © Cratejoy

Readme

Keywords

none

Package Sidebar

Install

npm i @cratejoy/lightbox

Weekly Downloads

3

Version

1.3.1

License

MIT

Unpacked Size

134 kB

Total Files

6

Last publish

Collaborators

  • cjengineers
  • mike3run
  • rblakemesser