react-image-gallery vs react-images vs v-viewer vs react-photo-gallery
React Image Gallery Libraries Comparison
1 Year
react-image-galleryreact-imagesv-viewerreact-photo-gallery
What's React Image Gallery Libraries?

These libraries provide various functionalities for displaying images in a gallery format within React applications. They cater to different use cases, from simple image galleries to more complex features like lightboxes and responsive layouts. Each library has its unique strengths, making them suitable for different project requirements. Understanding their features and design principles can help developers choose the right tool for their specific needs.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
react-image-gallery236,9123,883204 kB123 months agoMIT
react-images36,5022,342-504 years agoMIT
v-viewer27,4312,56958.1 kB347 months agoMIT
react-photo-gallery15,0171,994-806 years agoMIT
Feature Comparison: react-image-gallery vs react-images vs v-viewer vs react-photo-gallery

Gallery Layout

  • react-image-gallery:

    react-image-gallery provides a simple and responsive layout that automatically adjusts to different screen sizes. It supports thumbnails and allows for easy navigation between images, making it user-friendly for basic gallery needs.

  • react-images:

    react-images focuses on a modal lightbox layout, displaying images one at a time in a centered view. It does not offer a gallery layout per se but excels in presenting images in a clean and distraction-free manner.

  • v-viewer:

    v-viewer does not provide a gallery layout but enhances the viewing experience of individual images with features like zoom and pan. It is designed to work alongside other gallery implementations.

  • react-photo-gallery:

    react-photo-gallery offers a customizable grid layout that can adapt to various screen sizes and aspect ratios. It allows for complex arrangements and is ideal for showcasing multiple images in a visually appealing manner.

Interactivity

  • react-image-gallery:

    react-image-gallery includes interactive features like autoplay, pause on hover, and thumbnail navigation, enhancing user engagement with the gallery.

  • react-images:

    react-images provides a lightbox with interactive capabilities such as image zooming and keyboard navigation, ensuring a smooth user experience when viewing images.

  • v-viewer:

    v-viewer offers extensive interactivity with images, including zooming, rotating, and panning, allowing users to explore images in detail.

  • react-photo-gallery:

    react-photo-gallery allows for interactive features through custom components, enabling developers to implement their own interactivity based on the gallery's layout and design.

Customization

  • react-image-gallery:

    react-image-gallery is relatively easy to customize with props for styling and behavior, allowing developers to tailor the gallery to fit their application's design.

  • react-images:

    react-images is minimalistic and provides limited customization options, focusing instead on a clean user experience without overwhelming the user with choices.

  • v-viewer:

    v-viewer allows for customization of viewer options and styles, enabling developers to create a tailored image viewing experience.

  • react-photo-gallery:

    react-photo-gallery is highly customizable, allowing developers to define their own gallery layouts and styles, making it suitable for unique design requirements.

Performance

  • react-image-gallery:

    react-image-gallery is optimized for performance with lazy loading of images, ensuring that only the images in view are loaded, which helps reduce initial load times.

  • react-images:

    react-images is lightweight and performs well for displaying single images in a lightbox, but may not be suitable for large galleries due to its lack of built-in gallery features.

  • v-viewer:

    v-viewer is efficient for image viewing but can be resource-intensive if used with high-resolution images without proper optimization.

  • react-photo-gallery:

    react-photo-gallery is designed for performance with responsive layouts and efficient rendering, making it suitable for galleries with many images.

Ease of Use

  • react-image-gallery:

    react-image-gallery is user-friendly and easy to integrate, making it a great choice for developers looking for a quick setup with minimal configuration.

  • react-images:

    react-images has a straightforward API, making it easy to implement lightbox functionality without a steep learning curve.

  • v-viewer:

    v-viewer can be slightly more complex to implement due to its advanced features, but it provides a rich user experience for detailed image interactions.

  • react-photo-gallery:

    react-photo-gallery may require more initial setup due to its customizable nature, but it offers flexibility for developers familiar with React.

How to Choose: react-image-gallery vs react-images vs v-viewer vs react-photo-gallery
  • react-image-gallery:

    Choose react-image-gallery if you need a simple, responsive image gallery with built-in support for thumbnails, fullscreen mode, and autoplay features. It's easy to set up and customize, making it ideal for straightforward gallery implementations.

  • react-images:

    Opt for react-images if you're looking for a lightweight solution that focuses on a clean lightbox experience. It offers a straightforward API for displaying images in a modal view, making it suitable for projects that prioritize simplicity and user experience.

  • v-viewer:

    Use v-viewer if you need a comprehensive image viewer with advanced features like zooming, rotating, and panning. It's particularly useful for applications that require detailed image interactions and a more immersive viewing experience.

  • react-photo-gallery:

    Select react-photo-gallery for a more flexible and customizable grid layout. It allows for responsive image arrangements and is perfect for applications that require a more complex layout or integration with other UI components.

README for react-image-gallery

React Image Gallery

npm version Download Count Bundle size

Live Demo (try it on mobile for swipe support)

linxtion.com/demo/react-image-gallery

demo gif

React image gallery is a React component for building image galleries and carousels

Features

  • Mobile swipe gestures
  • Thumbnail navigation
  • Fullscreen support
  • Custom rendered slides
  • RTL support
  • Responsive design
  • Tons of customization options (see props below)

Getting started

React Image Gallery requires React 16.0.0 or later.

npm install react-image-gallery

Style import options

# scss file import
@import "~react-image-gallery/styles/scss/image-gallery.scss";

# css file import
@import "~react-image-gallery/styles/css/image-gallery.css";

# js file import (using webpack)
import "react-image-gallery/styles/css/image-gallery.css";

Example

Need more example? See example/App.jsx

import ImageGallery from "react-image-gallery";
// import stylesheet if you're not already using CSS @import
import "react-image-gallery/styles/css/image-gallery.css";

const images = [
  {
    original: "https://picsum.photos/id/1018/1000/600/",
    thumbnail: "https://picsum.photos/id/1018/250/150/",
  },
  {
    original: "https://picsum.photos/id/1015/1000/600/",
    thumbnail: "https://picsum.photos/id/1015/250/150/",
  },
  {
    original: "https://picsum.photos/id/1019/1000/600/",
    thumbnail: "https://picsum.photos/id/1019/250/150/",
  },
];

class MyGallery extends React.Component {
  render() {
    return <ImageGallery items={images} />;
  }
}

Props

  • items: (required) Array of objects, see example above,

    • Available Properties
      • original - image src url
      • thumbnail - image thumbnail src url
      • fullscreen - image for fullscreen (defaults to original)
      • originalHeight - image height (html5 attribute)
      • originalWidth - image width (html5 attribute)
      • loading - image loading. Either "lazy" or "eager" (html5 attribute)
      • thumbnailHeight - image height (html5 attribute)
      • thumbnailWidth - image width (html5 attribute)
      • thumbnailLoading - image loading. Either "lazy" or "eager" (html5 attribute)
      • originalClass - custom image class
      • thumbnailClass - custom thumbnail class
      • renderItem - Function for custom rendering a specific slide (see renderItem below)
      • renderThumbInner - Function for custom thumbnail renderer (see renderThumbInner below)
      • originalAlt - image alt
      • thumbnailAlt - thumbnail image alt
      • originalTitle - image title
      • thumbnailTitle - thumbnail image title
      • thumbnailLabel - label for thumbnail
      • description - description for image
      • srcSet - image srcset (html5 attribute)
      • sizes - image sizes (html5 attribute)
      • bulletClass - extra class for the bullet of the item
  • infinite: Boolean, default true

    • infinite sliding
  • lazyLoad: Boolean, default false

  • showNav: Boolean, default true

  • showThumbnails: Boolean, default true

  • thumbnailPosition: String, default bottom

    • available positions: top, right, bottom, left
  • showFullscreenButton: Boolean, default true

  • useBrowserFullscreen: Boolean, default true

    • if false, fullscreen will be done via css within the browser
  • useTranslate3D: Boolean, default true

    • if false, will use translate instead of translate3d css property to transition slides
  • showPlayButton: Boolean, default true

  • isRTL: Boolean, default false

    • if true, gallery's direction will be from right-to-left (to support right-to-left languages)
  • showBullets: Boolean, default false

  • showIndex: Boolean, default false

  • autoPlay: Boolean, default false

  • disableThumbnailScroll: Boolean, default false

    • disables the thumbnail container from adjusting
  • disableKeyDown: Boolean, default false

    • disables keydown listener for keyboard shortcuts (left arrow, right arrow, esc key)
  • disableSwipe: Boolean, default false

  • disableThumbnailSwipe: Boolean, default false

  • onErrorImageURL: String, default undefined

    • an image src pointing to your default image if an image fails to load
    • handles both slide image, and thumbnail image
  • indexSeparator: String, default ' / ', ignored if showIndex is false

  • slideDuration: Number, default 450

    • transition duration during image slide in milliseconds
  • swipingTransitionDuration: Number, default 0

    • transition duration while swiping in milliseconds
  • slideInterval: Number, default 3000

  • slideOnThumbnailOver: Boolean, default false

  • flickThreshold: Number (float), default 0.4

    • Determines the max velocity of a swipe before it's considered a flick (lower = more sensitive)
  • swipeThreshold: Number, default 30

    • A percentage of how far the offset of the current slide is swiped to trigger a slide event. e.g. If the current slide is swiped less than 30% to the left or right, it will not trigger a slide event.
  • stopPropagation: Boolean, default false

    • Automatically calls stopPropagation on all 'swipe' events.
  • startIndex: Number, default 0

  • onImageError: Function, callback(event)

    • overrides onErrorImage
  • onThumbnailError: Function, callback(event)

    • overrides onErrorImage
  • onThumbnailClick: Function, callback(event, index)

  • onBulletClick: Function, callback(event, index)

  • onImageLoad: Function, callback(event)

  • onSlide: Function, callback(currentIndex)

  • onBeforeSlide: Function, callback(nextIndex)

  • onScreenChange: Function, callback(boolean)

    • When fullscreen is toggled a boolean is passed to the callback
  • onPause: Function, callback(currentIndex)

  • onPlay: Function, callback(currentIndex)

  • onClick: Function, callback(event)

  • onTouchMove: Function, callback(event) on gallery slide

  • onTouchEnd: Function, callback(event) on gallery slide

  • onTouchStart: Function, callback(event) on gallery slide

  • onMouseOver: Function, callback(event) on gallery slide

  • onMouseLeave: Function, callback(event) on gallery slide

  • additionalClass: String,

    • Additional class that will be added to the root node of the component.
  • renderCustomControls: Function, custom controls rendering

    • Use this to render custom controls or other elements on the currently displayed image (like the fullscreen button)
      _renderCustomControls() {
        return <a href='' className='image-gallery-custom-action' onClick={this._customAction.bind(this)}/>
      }
    
  • renderItem: Function, custom item rendering

    • NOTE: Highly suggest looking into a render cache such as React.memo if you plan to override renderItem
    • On a specific item [{thumbnail: '...', renderItem: this.myRenderItem}]
    • As a prop passed into ImageGallery to completely override renderItem, see source for renderItem implementation
  • renderThumbInner: Function, custom thumbnail rendering

    • On a specific item [{thumbnail: '...', renderThumbInner: this.myRenderThumbInner}]
    • As a prop passed into ImageGallery to completely override _renderThumbInner, see source for reference
  • renderLeftNav: Function, custom left nav component

    • See <LeftNav />
    • Use this to render a custom left nav control
    • Args:
      • onClick callback that will slide to the previous item
      • disabled boolean for when the nav is disabled
    renderLeftNav: (onClick, disabled) => (
      <LeftNav onClick={onClick} disabled={disabled} />
    );
    
  • renderRightNav: Function, custom right nav component

    • See <RightNav />
    • Use this to render a custom right nav control
    • Args:
      • onClick callback that will slide to the next item
      • disabled boolean for when the nav is disabled
    renderRightNav: (onClick, disabled) => (
      <RightNav onClick={onClick} disabled={disabled} />
    );
    
  • renderPlayPauseButton: Function, play pause button component

    • See <PlayPause />
    • Use this to render a custom play pause button
    • Args:
      • onClick callback that will toggle play/pause
      • isPlaying boolean for when gallery is playing
    renderPlayPauseButton: (onClick, isPlaying) => (
      <PlayPause onClick={onClick} isPlaying={isPlaying} />
    );
    
  • renderFullscreenButton: Function, custom fullscreen button component

    • See <Fullscreen />
    • Use this to render a custom fullscreen button
    • Args:
      • onClick callback that will toggle fullscreen
      • isFullscreen argument for when fullscreen is active
      renderFullscreenButton: (onClick, isFullscreen) => (
        <Fullscreen onClick={onClick} isFullscreen={isFullscreen} />
      ),
    
  • useWindowKeyDown: Boolean, default true

    • If true, listens to keydown events on window (window.addEventListener)
    • If false, listens to keydown events on image gallery element (imageGalleryElement.addEventListener)

Functions

The following functions can be accessed using refs

  • play(): plays the slides
  • pause(): pauses the slides
  • toggleFullScreen(): toggles full screen
  • slideToIndex(index): slides to a specific index
  • getCurrentIndex(): returns the current index

Contributing

Each pull request (PR) should be specific and isolated to the issue you're trying to fix. Please do not stack features, chores, refactors, or enhancements in one PR. Describe your feature/implementation in the PR. If you're unsure whether it's useful or if it involves a major change, please open an issue first and seek feedback.

  • Follow eslint provided
  • Comment your code
  • Write clean code

Build the example locally (requires node >= 12.13)

git clone https://github.com/xiaolin/react-image-gallery.git
cd react-image-gallery
npm install --global yarn
yarn install
yarn start

Then open localhost:8001 in a browser.

License

MIT