# react-items-carousel

> React Items Carousel

Latest version **2.8.0** (published 2019-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-items-carousel
pnpm add react-items-carousel
yarn add react-items-carousel
bun add react-items-carousel
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.8.0 |
| Published | 2019-10-11 |
| First published | 2017-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 56.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 205 |
| Author | Kareem Elbahrawy |
| Maintainers | bitriddler |
| Keywords | react-items-carousel, react-component, carousel, slider |

## Links

- npm: https://www.npmjs.com/package/react-items-carousel
- Repository: https://github.com/bitriddler/react-items-carousel
- Homepage: https://bitriddler.github.io/react-items-carousel
- npm.io page: https://npm.io/package/react-items-carousel

## Dependencies (7)

- [react](https://npm.io/package/react.md) 16.8.1
- [lodash.max](https://npm.io/package/lodash.max.md) ^4.0.1
- [lodash.min](https://npm.io/package/lodash.min.md) ^4.0.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.5.8
- [react-motion](https://npm.io/package/react-motion.md) ^0.5.2
- [react-measure](https://npm.io/package/react-measure.md) ^2.2.4
- [styled-components](https://npm.io/package/styled-components.md) ^4.1.3

## Alternatives

- [adhdev](https://npm.io/package/adhdev.md) — 11.1K weekly downloads
- [react-slide-button](https://npm.io/package/react-slide-button.md) — 310 weekly downloads
- [better](https://npm.io/package/better.md) — 42 weekly downloads
- [react-native-swipe-image](https://npm.io/package/react-native-swipe-image.md) — 22 weekly downloads
- [nl.fokkezb.pulltorefresh](https://npm.io/package/nl.fokkezb.pulltorefresh.md) — 11 weekly downloads

## Recent versions

- 2.8.0 (latest) — 2019-10-11
- 2.7.0 — 2019-09-20
- 2.6.1 — 2019-09-13
- 2.6.0 — 2019-09-13
- 2.5.0 — 2019-09-13
- 2.4.2 — 2019-09-13
- 2.4.1 — 2019-09-13
- 2.4.0 — 2019-09-13
- 2.3.7 — 2019-07-15
- 2.3.6 — 2019-05-02
- 2.3.5 — 2019-04-23
- 2.3.4 — 2019-04-22
- 2.3.3 — 2019-04-22
- 2.3.2 — 2019-03-28
- 2.3.1 — 2019-03-28
- … 23 more at https://npm.io/package/react-items-carousel/versions

## README

react-items-carousel
---------------

# Installation
```
$ npm install react-items-carousel --save
```

# [Demos](https://bitriddler.github.io/react-items-carousel/)

# Example

```javascript
import React, { useState } from 'react';
import ItemsCarousel from 'react-items-carousel';

export default () => {
  const [activeItemIndex, setActiveItemIndex] = useState(0);
  const chevronWidth = 40;
  return (
    <div style={{ padding: `0 ${chevronWidth}px` }}>
      <ItemsCarousel
        requestToChangeActive={setActiveItemIndex}
        activeItemIndex={activeItemIndex}
        numberOfCards={2}
        gutter={20}
        leftChevron={<button>{'<'}</button>}
        rightChevron={<button>{'>'}</button>}
        outsideChevron
        chevronWidth={chevronWidth}
      >
        <div style={{ height: 200, background: '#EEE' }}>First card</div>
        <div style={{ height: 200, background: '#EEE' }}>Second card</div>
        <div style={{ height: 200, background: '#EEE' }}>Third card</div>
        <div style={{ height: 200, background: '#EEE' }}>Fourth card</div>
      </ItemsCarousel>
    </div>
  );
};
```

# Component Props

| Property                 | Type                             | Default | Description                                                                           |
|--------------------------|----------------------------------|---------|---------------------------------------------------------------------------------------|
| children *               | node[]                           |         | The cards to render in the carousel. You must specify a height for each card.         |
| requestToChangeActive *  | function                         |         | This function accepts the new activeItemIndex and should update your component state. |
| activeItemIndex *        | int                              |         | This defines which item should be active.                                             |
| numberOfCards            | number                           | 3       | Number of cards to show per slide.                                                    |
| infiniteLoop             | boolean                          | false   | Enable infinite loop. see [Infinite loop limitations](#inifinite-loop-limitations)                                                                  |
| gutter                   | number                           | 0       | Space between cards.                                                                  |
| showSlither              | boolean                          | false   | If true a slither of next card will be shown.                                         |
| firstAndLastGutter       | boolean                          | false   | If true first and last cards will have twice the space.                               |
| enablePlaceholder        | boolean                          | false   | If true, component will render `placeholderItem` until children are passed.           |
| placeholderItem          | node                             | null    | If `enablePlaceholder` is true, this will be rendered until children are passed.      |
| numberOfPlaceholderItems | number                           | 0       | This controls how many `placeholderItem` to render if `enablePlaceholder` is true.    |
| activePosition           | enum ('left', 'center', 'right') | left    | The position of the active item.                                                      |
| rightChevron             | node                             | null    | Right chevron node.                                                                   |
| leftChevron              | node                             | null    | Left chevron node.                                                                    |
| chevronWidth             | number                           | 0       | This value should be the width of left and right chevron.                             |
| outsideChevron           | boolean                          | false   | If true the chevron will be rendered outside the carousel.                            |
| alwaysShowChevrons       | boolean                          | false   | If true the chevrons will always be visible even if there were no cards to scroll.    |
| slidesToScroll           | number                           | 1       | Number of cards to scroll when right and left chevrons are clicked.                   |
| disableSwipe             | boolean                          | false   | Disables left and right swiping on touch devices.                                     |
| onStateChange            | func                             | null    | This function will be called when state change with `{ isFirstScroll: Boolean, isLastScroll: Boolean }`. It can be used to fetch more data for example. |
| classes                  | `{ wrapper: string, itemsWrapper: string, itemsInnerWrapper: string, itemWrapper: string, rightChevronWrapper: string, leftChevronWrapper: string }` | {}      | An object of classes to pass to the carousel inner elements |


# Infinite Loop Limitations
If `infiniteLoop` was set to true, the following props are ignored
- `activePosition`: will always be `left`
- `alwaysShowChevrons`: will always be `true`

# Contributing
To contribute, follow these steps:
- Fork this repo.
- Clone your fork.
- Run `yarn`
- Run `yarn start:gh`
- Goto `localhost:9000`
- Add your patch then push to your fork and submit a pull request

# License
MIT

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