React Responsive Carousel v2
npm install react-responsive-carousel-v2
Powerful, lightweight and fully customizable carousel component for React apps.
- Responsive
- Mobile friendly
- Swipe to slide
- Mouse emulating touch
- Server side rendering
- Keyboard navigation
- Custom animation duration
- Auto play
- Custom auto play interval
- Infinite loop
- Horizontal or Vertical directions
- Supports images, videos, text content or anything you want. Each direct child represents one slide!
- Supports any flux library (use selectedItem prop to set from the app state, and onChange callback to get the new position)
- Show/hide anything (thumbs, indicators, arrows, status)
npm install react-responsive-carousel-v2 --save
``javascript
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import "react-responsive-carousel-v2/dist/carousel.css";
import { Carousel } from 'react-responsive-carousel-v2';
class DemoCarousel extends Component { Legend 1 Legend 2 Legend 3
render() {
return (



);
}
});
ReactDOM.render(
// Don't forget to include the css in your page
// Using webpack
// import styles from 'react-responsive-carousel-v2/dist/carousel.css';
// Using html tag:
//
`
| Attributes | Type | Default | Description |
| :-------------------- | :--------: | :------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| showArrows | boolean | true | show prev and next arrows |boolean
| showStatus | | true | show index of the current item. i.e: (1/8) |boolean
| showIndicators | | true | show little dots at the bottom with links for changing the item |boolean
| showThumbs | | true | show thumbnails of the images |number
| thumbWidth | | undefined | optionally specify pixel width (as an integer) of a thumbnail (including any padding) to avoid calculating values (helps with server-side renders or page cache issues) |boolean
| infiniteLoop | | false | infinite loop sliding |number
| selectedItem | | 0 | selects an item though props / defines the initial selected item |string
| axis | | horizontal | changes orientation - accepts horizontal and vertical |string
| verticalSwipe | | standard | changes vertical swipe scroll direction - accepts standard and natural |function
| onChange | | - | Fired when changing positions |function
| onClickItem | | - | Fired when an item is clicked |function
| onClickThumb | | - | Fired when a thumb it clicked |string
| width | | - | Allows to set a fixed width |boolean
| useKeyboardArrows | | false | Adds support to next and prev through keyboard arrows |boolean
| autoPlay | | false | Auto play |boolean
| stopOnHover | | true | Stop auto play while mouse is over the carousel |number
| interval | | 3000 | Interval of auto play |number
| transitionTime | | 350 | Duration of slide transitions (in miliseconds) |number
| swipeScrollTolerance | | 5 | Allows scroll when the swipe movement occurs in a different direction than the carousel axis and within the tolerance - Increase for loose - Decrease for strict |boolean
| swipeable | | true | Enables swiping gestures |boolean
| dynamicHeight | | false | Adjusts the carousel height if required. -- Do not work with vertical axis -- |boolean
| emulateTouch | | false | Allows mouse to simulate swipe |func
| statusFormatter | | (current, total) => ${current} of ${total} | Allows custom formatting of the status indicator |boolean
| centerMode | | false | Enables centered view with partial prev/next slides. Only works with horizontal axis. |number
| centerSlidePercentage | | 80 | optionally specify percentage width (as an integer) of the slides in centerMode |
- git clone git@github.com:pak11273/react-responsive-carousel-v2.gitnpm install
- npm fserver
- localhost:9000
- Open your favourite browser on either or 0.0.0.0:9000 - livereload will be enabled and tests will run on each change
> The fastest dev environment is on node 6. If you have nvm installed, just run nvm use 6. Tests in travis will run on node 4 and 6
#### Running only tests
- npm test
#### Running storybook
- npm run storybook
=======================
#### Publish to npm
- npm run publish-to-npm
#### Pubish to gh-pages
- npm run publish-to-gh-pages`