react-image-gallery vs react-images vs react-photo-gallery
React Image Gallery Libraries
react-image-galleryreact-imagesreact-photo-gallery

React Image Gallery Libraries

React image gallery libraries provide developers with tools to create visually appealing and interactive galleries for displaying images in React applications. These libraries often come with features such as responsive design, customizable layouts, and various display modes, allowing for a rich user experience. They help streamline the process of integrating image galleries into applications, saving time and effort while enhancing the aesthetic appeal of the interface.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-image-gallery03,939123 kB143 months agoMIT
react-images02,337-505 years agoMIT
react-photo-gallery02,015-807 years agoMIT

Feature Comparison: react-image-gallery vs react-images vs react-photo-gallery

Gallery Features

  • react-image-gallery:

    react-image-gallery offers a comprehensive set of features including thumbnail support, autoplay, fullscreen mode, and custom rendering options for slides. It allows for a highly interactive experience with swipe gestures and keyboard navigation, making it suitable for complex gallery needs.

  • react-images:

    react-images provides a straightforward lightbox experience, focusing on displaying images in a modal with basic navigation controls. It is designed for simplicity, making it easy to implement without overwhelming users with options.

  • react-photo-gallery:

    react-photo-gallery focuses on providing a responsive grid layout for images, supporting various sizes and aspect ratios. It allows for a customizable layout, enabling developers to create unique gallery presentations without predefined constraints.

Customization

  • react-image-gallery:

    react-image-gallery is highly customizable, allowing developers to modify styles, transitions, and components to fit the application's design. It supports custom rendering for thumbnails and slides, providing flexibility in presentation.

  • react-images:

    react-images offers limited customization options, primarily focused on the modal display. While it allows for some styling adjustments, it is not as flexible as other libraries in terms of layout and presentation.

  • react-photo-gallery:

    react-photo-gallery excels in customization, allowing developers to define their own grid layouts and styles. It supports a variety of image sizes and can adapt to different screen sizes, making it versatile for different design needs.

Performance

  • react-image-gallery:

    react-image-gallery is optimized for performance with lazy loading capabilities, ensuring that images are only loaded when they are in view. This helps in reducing initial load times and improving user experience, especially for galleries with many images.

  • react-images:

    react-images is lightweight and performs well for simple use cases, but may not be as efficient for larger galleries due to its focus on modal display rather than a full gallery experience.

  • react-photo-gallery:

    react-photo-gallery is designed for performance with a focus on responsive design. It efficiently handles large sets of images by using CSS grid layouts, which helps maintain performance across various devices.

Ease of Use

  • react-image-gallery:

    react-image-gallery is user-friendly and provides a straightforward API, making it easy for developers to implement and customize. It is well-documented, which aids in quick integration into projects.

  • react-images:

    react-images is extremely easy to use, with minimal setup required. Its simplicity makes it a great choice for developers who need a quick solution for displaying images without extensive configuration.

  • react-photo-gallery:

    react-photo-gallery offers a moderate learning curve, as it requires some understanding of grid layouts and responsive design principles. However, it is still relatively easy to implement for developers familiar with React.

Community and Support

  • react-image-gallery:

    react-image-gallery has a strong community and is actively maintained, providing good support and regular updates. This ensures that developers can rely on the library for ongoing improvements and bug fixes.

  • react-images:

    react-images has a smaller community compared to others, which may result in less frequent updates and support. However, it is still a viable option for simple use cases.

  • react-photo-gallery:

    react-photo-gallery benefits from a growing community and active maintenance, ensuring that developers have access to support and resources for troubleshooting and enhancements.

How to Choose: react-image-gallery vs react-images vs react-photo-gallery

  • react-image-gallery:

    Choose react-image-gallery if you need a fully-featured gallery with support for thumbnails, fullscreen mode, and a responsive layout. It is suitable for applications that require a customizable gallery with a focus on user interaction and visual storytelling.

  • react-images:

    Select react-images if you are looking for a simple and lightweight solution for displaying images in a modal or lightbox format. It is ideal for projects that prioritize minimalism and ease of use, without the need for extensive gallery features.

  • react-photo-gallery:

    Opt for react-photo-gallery if you want a flexible grid layout for displaying images. This library is perfect for applications that require a responsive and customizable grid system, allowing for various image sizes and aspect ratios.

README for react-image-gallery

React Image Gallery

A responsive, customizable image gallery component for React


npm version Download Count Bundle size CI TypeScript License: MIT


ā–¶ļø VIEW LIVE DEMO


React Image Gallery Demo


✨ Features

FeatureDescription
šŸ“± Mobile SwipeNative touch gestures for smooth mobile navigation
šŸ–¼ļø ThumbnailsCustomizable thumbnail navigation with multiple positions
šŸ“ŗ FullscreenBrowser fullscreen or CSS-based fullscreen modes
šŸŽØ ThemingCSS custom properties for easy styling
āŒØļø Keyboard NavArrow keys, escape, and custom key bindings
šŸ”„ RTL SupportRight-to-left language support
ā†•ļø Vertical ModeSlide vertically instead of horizontally
šŸŽ¬ Custom SlidesRender videos, iframes, or any custom content

šŸš€ Getting Started

npm install react-image-gallery
import { useRef } from "react";
import ImageGallery from "react-image-gallery";
import "react-image-gallery/styles/image-gallery.css";
import type { GalleryItem, ImageGalleryRef } from "react-image-gallery";

const images: GalleryItem[] = [
  {
    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/",
  },
];

function MyGallery() {
  const galleryRef = useRef<ImageGalleryRef>(null);

  return (
    <ImageGallery
      ref={galleryRef}
      items={images}
      onSlide={(index) => console.log("Slid to", index)}
    />
  );
}

For more examples, see example/App.jsx


āš™ļø Props

  • items: (required) Array of objects. Available properties:
    • original - image source URL
    • thumbnail - thumbnail source URL
    • fullscreen - fullscreen image URL (defaults to original)
    • originalHeight - image height (html5 attribute)
    • originalWidth - image width (html5 attribute)
    • loading - "lazy" or "eager" (HTML5 attribute)
    • thumbnailHeight - image height (html5 attribute)
    • thumbnailWidth - image width (html5 attribute)
    • thumbnailLoading - "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 - loop infinitely
  • lazyLoad: Boolean, default false
  • showNav: Boolean, default true
  • showThumbnails: Boolean, default true
  • thumbnailPosition: String, default bottom - options: top, right, bottom, left
  • showFullscreenButton: Boolean, default true
  • useBrowserFullscreen: Boolean, default true - if false, uses CSS-based fullscreen
  • useTranslate3D: Boolean, default true - if false, uses translate instead of translate3d
  • showPlayButton: Boolean, default true
  • isRTL: Boolean, default false - right-to-left mode
  • showBullets: Boolean, default false
  • maxBullets: Number, default undefined - max bullets shown (minimum 3, active bullet stays centered)
  • showIndex: Boolean, default false
  • autoPlay: Boolean, default false
  • disableThumbnailScroll: Boolean, default false - disable thumbnail auto-scroll
  • disableKeyDown: Boolean, default false - disable keyboard navigation
  • disableSwipe: Boolean, default false
  • disableThumbnailSwipe: Boolean, default false
  • onErrorImageURL: String, default undefined - fallback image URL for failed loads
  • indexSeparator: String, default ' / ', ignored if showIndex is false
  • slideDuration: Number, default 550 - slide transition duration (ms)
  • swipingTransitionDuration: Number, default 0 - transition duration while swiping (ms)
  • slideInterval: Number, default 3000
  • slideOnThumbnailOver: Boolean, default false
  • slideVertically: Boolean, default false - slide vertically instead of horizontally
  • flickThreshold: Number, default 0.4 - swipe velocity threshold (lower = more sensitive)
  • swipeThreshold: Number, default 30 - percentage of slide width needed to trigger navigation
  • stopPropagation: Boolean, default false - call stopPropagation on swipe events
  • startIndex: Number, default 0
  • onImageError: Function, callback(event) - overrides onErrorImageURL
  • onThumbnailError: Function, callback(event) - overrides onErrorImageURL
  • 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(isFullscreen)
  • 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 for the root node
  • renderCustomControls: Function, render custom controls on the current slide
  • renderItem: Function, custom slide rendering
  • renderThumbInner: Function, custom thumbnail rendering
  • renderLeftNav: Function, custom left nav component
  • renderRightNav: Function, custom right nav component
  • renderTopNav: Function, custom top nav component (vertical mode)
  • renderBottomNav: Function, custom bottom nav component (vertical mode)
  • renderPlayPauseButton: Function, custom play/pause button
  • renderFullscreenButton: Function, custom fullscreen button
  • useWindowKeyDown: Boolean, default true - use window or element for key events

šŸ”§ Functions

The following functions can be accessed using refs

  • play(): starts the slideshow
  • pause(): pauses the slideshow
  • togglePlay(): toggles between play and pause
  • fullScreen(): enters fullscreen mode
  • exitFullScreen(): exits fullscreen mode
  • toggleFullScreen(): toggles fullscreen mode
  • slideToIndex(index): slides to a specific index
  • getCurrentIndex(): returns the current index

šŸ¤ Contributing

Pull requests should be focused on a single issue. If you're unsure whether a change is useful or involves a major modification, please open an issue first.

  • Follow the eslint config
  • Comment your code

šŸ› ļø Build the example locally

Requires Node.js >= 18.18

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

Then open localhost:8001 in a browser.


šŸ“„ License

MIT Ā© Xiao Lin