{"id":28089087,"url":"https://github.com/specter256/react-simple-image-viewer","last_synced_at":"2025-05-13T12:53:40.218Z","repository":{"id":38360349,"uuid":"206950775","full_name":"specter256/react-simple-image-viewer","owner":"specter256","description":"Simple image viewer component for React","archived":false,"fork":false,"pushed_at":"2024-08-26T06:27:16.000Z","size":164,"stargazers_count":70,"open_issues_count":9,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T02:40:30.631Z","etag":null,"topics":["gallery","image","image-viewer","images","lightbox","react","reactjs"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/specter256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-07T10:13:59.000Z","updated_at":"2025-05-03T08:35:35.000Z","dependencies_parsed_at":"2024-06-18T14:04:30.316Z","dependency_job_id":"28c038d9-a7ae-49fe-9abf-fe15524a8b7f","html_url":"https://github.com/specter256/react-simple-image-viewer","commit_stats":{"total_commits":32,"total_committers":6,"mean_commits":5.333333333333333,"dds":0.25,"last_synced_commit":"8b78957037cc5af9651af424aa82f4c9800e0684"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specter256%2Freact-simple-image-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specter256%2Freact-simple-image-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specter256%2Freact-simple-image-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/specter256%2Freact-simple-image-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/specter256","download_url":"https://codeload.github.com/specter256/react-simple-image-viewer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948111,"owners_count":21988951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gallery","image","image-viewer","images","lightbox","react","reactjs"],"created_at":"2025-05-13T12:53:39.672Z","updated_at":"2025-05-13T12:53:40.192Z","avatar_url":"https://github.com/specter256.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Simple Image Viewer\n\n[![npm version](https://badge.fury.io/js/react-simple-image-viewer.svg)](https://badge.fury.io/js/react-simple-image-viewer)\n[![Build Status](https://travis-ci.org/specter256/react-simple-image-viewer.svg?branch=master)](https://travis-ci.org/specter256/react-simple-image-viewer)\n\nSimple image viewer component for React.\n\n# Installation\n\n```shell\n$ npm install react-simple-image-viewer\n```\nor\n```shell\n$ yarn add react-simple-image-viewer\n```\n\n# Example\n\n```jsx\nimport React, { useState, useCallback } from 'react';\nimport { render } from 'react-dom';\nimport ImageViewer from 'react-simple-image-viewer';\n\nfunction App() {\n  const [currentImage, setCurrentImage] = useState(0);\n  const [isViewerOpen, setIsViewerOpen] = useState(false);\n  const images = [\n    'http://placeimg.com/1200/800/nature',\n    'http://placeimg.com/800/1200/nature',\n    'http://placeimg.com/1920/1080/nature',\n    'http://placeimg.com/1500/500/nature',\n  ];\n\n  const openImageViewer = useCallback((index) =\u003e {\n    setCurrentImage(index);\n    setIsViewerOpen(true);\n  }, []);\n\n  const closeImageViewer = () =\u003e {\n    setCurrentImage(0);\n    setIsViewerOpen(false);\n  };\n\n  return (\n    \u003cdiv\u003e\n      {images.map((src, index) =\u003e (\n        \u003cimg\n          src={ src }\n          onClick={ () =\u003e openImageViewer(index) }\n          width=\"300\"\n          key={ index }\n          style={{ margin: '2px' }}\n          alt=\"\"\n        /\u003e\n      ))}\n\n      {isViewerOpen \u0026\u0026 (\n        \u003cImageViewer\n          src={ images }\n          currentIndex={ currentImage }\n          disableScroll={ false }\n          closeOnClickOutside={ true }\n          onClose={ closeImageViewer }\n        /\u003e\n      )}\n    \u003c/div\u003e\n  );\n}\n\nrender(\u003cApp /\u003e, document.getElementById('app'));\n```\n\n# Demo\n\n[Try out demo on CodeSandbox](https://codesandbox.io/s/react-simple-image-viewer-demo-4itlr)\n\n# API\n\n| Property        |  Type     | Description                                                                       |\n| :-------------- | :-------- | :-------------------------------------------------------------------------------- |\n| src             | string[]  | Array of image URLs                                                               |\n| currentIndex    | number    | Index of image in `src` property which will be shown first when viewer is opened  |\n| onClose         | function  | Callback which will be called when viewer will closed                             |\n| backgroundStyle | object    | Custom styles for background of modal window                                      |\n| disableScroll   | boolean   | Disable scrolling images by mouse wheel                                           |\n| closeOnClickOutside   | boolean   | Whether viewer should be closed when clicking outside of image              |\n| closeComponent | JSX.Element | Custom component for the close button |\n| leftArrowComponent | JSX.Element | Custom component for the left arrow |\n| rightArrowComponent | JSX.Element | Custom component for the right arrow |\n\n# Shortcuts\n\n| Shortcut        | Description                     |\n| :-------------- | :------------------------------ |\n| Escape          | Close the viewer                |\n| Right Arrow / l | Next image                      |\n| Left Arrow / h  | Previous image                  |\n| Mouse wheel     | Scrolling previous / next image |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspecter256%2Freact-simple-image-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspecter256%2Freact-simple-image-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspecter256%2Freact-simple-image-viewer/lists"}