# react-images

> A mobile-friendly, highly customizable, carousel component for displaying media in ReactJS

Latest version **1.2.0-beta.7** (published 2021-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-images
pnpm add react-images
yarn add react-images
bun add react-images
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0-beta.7 |
| Published | 2021-04-29 |
| First published | 2015-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 251.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2334 |
| Author | Joss Mackison |
| Maintainers | jedwatson, jossmac, neptunian, davwheat |
| Keywords | react, images, carousel, lightbox, gallery, modal |

## Links

- npm: https://www.npmjs.com/package/react-images
- Repository: https://github.com/jossmac/react-images
- Homepage: https://jossmac.github.io/react-images/
- Issues: https://github.com/jossmac/react-images/issues
- npm.io page: https://npm.io/package/react-images

## Dependencies (9)

- [glam](https://npm.io/package/glam.md) ^5.0.1
- [raf-schd](https://npm.io/package/raf-schd.md) ^4.0.2
- [cross-env](https://npm.io/package/cross-env.md) ^7.0.3
- [react-focus-on](https://npm.io/package/react-focus-on.md) ^3.5.1
- [a11y-focus-store](https://npm.io/package/a11y-focus-store.md) ^1.0.0
- [react-view-pager](https://npm.io/package/react-view-pager.md) ^0.6.0
- [html-react-parser](https://npm.io/package/html-react-parser.md) ^1.2.4
- [react-full-screen](https://npm.io/package/react-full-screen.md) ^1.0.1
- [react-transition-group](https://npm.io/package/react-transition-group.md) ^4.4.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.0-beta.7 (latest) — 2021-04-29
- 1.1.0-beta.5 (beta) — 2020-03-17
- 1.0.0-alpha.5 (next) — 2019-03-23
- 1.2.0-beta.6 — 2021-02-23
- 1.2.0-beta.5 — 2021-02-13
- 1.2.0-beta.4 — 2021-02-13
- 1.2.0-beta.3 — 2021-02-13
- 1.2.0-beta.2 — 2021-02-13
- 1.2.0-beta.1 — 2021-02-09
- 1.2.0-beta.0 — 2021-02-09
- 1.1.7 — 2020-05-02
- 1.1.6 — 2020-05-02
- 1.1.5 — 2020-05-02
- 1.1.4 — 2020-05-02
- 1.1.3 — 2020-04-18
- … 62 more at https://npm.io/package/react-images/versions

## README

# React Images

### ⚠️ Warning!

**Don't use this in a new project.** This package hasn't been properly maintained in a long time and there are much better options available.

**Instead, try...**

- [React Responsive Carousel](http://react-responsive-carousel.js.org/)

---

A mobile-friendly, highly customizable, carousel component for displaying media in ReactJS.

### Browser support

Should work in every major browser... maybe even IE10 and IE11?

### Getting Started

Start by installing `react-images`

```bash
npm install react-images
```

or

```bash
yarn add react-images
```

**If you were using `0.x` versions:** library was significantly rewritten for `1.x` version and contains several breaking changes.
The best way to upgrade is to read the docs and follow the examples.

Please note that the default footer parses HTML automatically (such as `<b>I'm bold!</b>`) but it **does not implement any form of XSS or sanitisation**. You should do that yourself before passing it into the caption field of react-images.

### Using the Carousel

Import the carousel from `react-images` at the top of a
component and then use it in the render function.

```jsx
import React from 'react'
import Carousel from 'react-images'

const images = [{ source: 'path/to/image-1.jpg' }, { source: 'path/to/image-2.jpg' }]

class Component extends React.Component {
  render() {
    return <Carousel views={images} />
  }
}
```

### Using the Modal

Import the modal and optionally the modal gateway from
`react-images` at the top of a component and then use it in
the render function.

The `ModalGateway` will insert the modal just before the
end of your `<body />` tag.

```jsx
import React from 'react'
import Carousel, { Modal, ModalGateway } from 'react-images'

const images = [{ source: 'path/to/image-1.jpg' }, { source: 'path/to/image-2.jpg' }]

class Component extends React.Component {
  state = { modalIsOpen: false }
  toggleModal = () => {
    this.setState(state => ({ modalIsOpen: !state.modalIsOpen }))
  }
  render() {
    const { modalIsOpen } = this.state

    return (
      <ModalGateway>
        {modalIsOpen ? (
          <Modal onClose={this.toggleModal}>
            <Carousel views={images} />
          </Modal>
        ) : null}
      </ModalGateway>
    )
  }
}
```

### Advanced Image Lists

The simplest way to define a list of images for the carousel looks like:

```jsx
const images = [{ source: 'path/to/image-1.jpg' }, { source: 'path/to/image-2.jpg' }]
```

However, react-images supports several other properties on each image object than just `source`. For example:

```jsx
const image = {
  caption: "An image caption as a string, React Node, or a rendered HTML string",
  alt: "A plain string to serve as the image's alt tag",
  source: {
    download: "A URL to serve a perfect quality image download from",
    fullscreen: "A URL to load a very high quality image from",
    regular: "A URL to load a high quality image from",
    thumbnail: "A URL to load a low quality image from"
  };
}
```

All these fields are optional except `source`. Additionally, if using an object of URLs (rather than a plain string URL) as your `source`, you must specify the `regular` quality URL.

---
_Source: https://npm.io/package/react-images · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
