sag1v / react-elastic-carousel

A flexible and responsive carousel component for react https://sag1v.github.io/react-elastic-carousel
MIT License
348 stars 149 forks source link
carousel flexible javascript react responsive styled-components

react-elastic-carousel

A flexible and responsive carousel component for react

NPM npm npm bundle size

Why do we need yet another carousel component

Live Demos & Docs

Install

npm install --save react-elastic-carousel

or

yarn add react-elastic-carousel

Note

react-elastic-carousel is using styled-components for styling, this means that you should install it as well:

npm install --save styled-components

Usage

import React, { Component } from 'react';
import Carousel from 'react-elastic-carousel';

class App extends Component {
  state = {
    items: [
      {id: 1, title: 'item #1'},
      {id: 2, title: 'item #2'},
      {id: 3, title: 'item #3'},
      {id: 4, title: 'item #4'},
      {id: 5, title: 'item #5'}
    ]
  }

  render () {
    const { items } = this.state;
    return (
      <Carousel>
        {items.map(item => <div key={item.id}>{item.title}</div>)}
      </Carousel>
    )
  }
}

Playground

Edit react-elastic-carousel

Development

git clone https://github.com/sag1v/react-elastic-carousel.git
cd react-elastic-carousel
yarn

To run the docs site run

yarn start

to run a demo Application run

yarn demo

The application is running at http://localhost:8888

License

MIT © sag1v