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

react-photo-gallery

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-photo-gallery

Responsive React Photo Gallery Image Component for Masonry Layout

  • 6.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
increased by18.3%
Maintainers
1
Weekly downloads
 
Created
Source

Join the chat at https://gitter.im/react-photo-gallery/Lobby npm version Build Status Coverage Status Dependency Status

  • Responsive, accessible, composable, and customizable image gallery component
  • Maintains the original aspect ratio of your photos
  • Creates a 'masonry' style layout
  • Uses actual image elements, optionally pass in srcSet and sizes attributes
  • Supports row or column direction layout
  • Supports passing in a custom image component for implementation of things like image selection, favorites, captions, or whatever your little heart desires!
  • SSR app compatible

Preview

Installation

To install:

yarn add react-photo-gallery

Documentation and Examples

http://neptunian.github.io/react-photo-gallery/

To build some examples locally, run:

yarn install
yarn start

Then open localhost:8000 in a browser.

Use


import Gallery from 'react-photo-gallery';

export default class Sample extends React.Component {
    render() {
	return (
	    <Gallery photos={PHOTO_SET} />
	);
    }
}
const PHOTO_SET = [
  {
    src: 'http://example.com/example/img1.jpg',
    width: 4,
    height: 3
  },
  {
    src: 'http://example.com/example/img2.jpg',
    width: 1,
    height: 1
  }
];

PropertyTypeDefaultDescription
photosarrayundefinedrequired; array of objects
columnsnumber3optional; number of photos per row
onClickfunctionundefinedoptional; do something when the user clicks a photo; receives arguments event and an object containing the index, photo obj originally sent and the next and previous photos in the gallery if they exist
marginnumber2optional; number of margin pixels around each entire image
directionstring'row'optional; column or row based layout
ImageComponentfunctiondefault componentoptional; use a different image component than the default provided to display your photo

Photos array item properties (passed into Gallery's photos property)

PropertyTypeDefaultDescription
srcstringundefinedrequired; the img src attribute value of the image
srcSetarray or stringundefinedoptional; srcSet attribute of the image
sizesarray or stringundefinedoptional; sizes attribute of the image
widthnumberundefinedrequired; original width of the gallery image (only used for calculating aspect ratio)
heightnumberundefinedrequired; original height of the gallery image (only used for calculating aspect ratio)
altstringundefinedoptional; alt text of the gallery image
keystringsrcoptional; key to be used on component

ImageComponent props

If you're passing a function component to ImageComponent you will receive back these props:

PropertyTypeValue
marginstringoptional; margin prop optionally passed into Gallery by user
indexnumberrequired; the index of the photo within the Gallery
photoobjectrequired; the individual object passed into Gallery's photos array prop, with all the same props except recalculated height and width
directionstringoptional; direction passed into Gallery
topnumberrequired if direction is 'column'; top position of this image, only passed if direction prop was 'column'
leftnumberrequired if direction is 'column'; left position of this image, only passed if direction prop was 'column'
onClickfunctionoptional; the onClick function optionally passsed into Gallery by user

Keywords

FAQs

Package last updated on 13 Aug 2018

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