0.5.1 • Published 5 years ago

react-styled-carousel v0.5.1

Weekly downloads
1,523
License
MIT
Repository
github
Last release
5 years ago

React Styled Slider

React Styled Slider is a react and styled component slider. It is fully configurable.

Build Status Coverage Status

Live Image

Features

  • Mostly configurable
  • Styled-Components
  • No external CSS required.
  • Server Side Rendering supported

Note: Server Side Rendering works well without the styled-components collectStyles function also. But for better user experience please use collectStyles function from styled-components

Installation

$ npm install --save react-styled-carousel

Running example in local

$ git clone github.com/itsMrAkhil/react-styled-carousel
$ npm start

It'll open localhost:9000 port, where you can see live demo.

Example

import React from 'react';
import ReactDOM from 'react-dom'
import Slider from 'react-styled-carousel';

const ExampleSlider = () => (
  <Slider>
    <h1>1</h1>
    <h1>2</h1>
    <h1>3</h1>
    <h1>4</h1>
  </Slider>
);

ReactDOM.render(<ExampleSlider />, document.getElementById('root'));

Responsive

react-styled-carousel is responsive. Below is the example configuration of responsiveness.

Note: If responsive prop is provided then, it'll override the cardsToShow prop. In other words cardsToShow will not work.

import React from 'react';
import ReactDOM from 'react-dom'
import Slider from 'react-styled-carousel';

const responsive = [
  { breakPoint: 1280, cardsToShow: 4 }, // this will be applied if screen size is greater than 1280px. cardsToShow will become 4.
  { breakPoint: 760, cardsToShow: 2 },
];

const ExampleSlider = () => (
  <Slider reponsive={responsive} >
    <h1>1</h1>
    <h1>2</h1>
    <h1>3</h1>
    <h1>4</h1>
  </Slider>
);

ReactDOM.render(<ExampleSlider />, document.getElementById('root'));

Configurable Props

PropsTypeDefault ValueDescription
showArrowsBooleantrueIf true then only Arrows of navigation will be shown
showDotsBooleantrueShow navigation or pagination dots below the slider
infiniteBooleantrueInfinitely slide cards.
DotReact NodeDefaultCustomized pagination button (Active slide Dot will get active as Boolean prop.)
DotsWrapperStyled ElementDefaultCustomized wrapper for your component to change the view of dots wrapper like position, background, etc. Note: It should be a styled ul, otherwise you may not see any Dot Components.
LeftArrowReact NodeDefaultCustomized left arrow button. It'll get disabled Boolean prop if first Dot is active and infinite is false.
RightArrowReact NodeDefaultCustomized right arrow button. It'll get disabled Boolean prop if last Dot is active and infinite is false.
childrenReact NodenullCards are components which you want to show in the carousel
cardsToShowNumberChildren lengthHow many cards to be shown for a single slide.
afterSlideFunctionnullThis function will be executed after every sliding is completed
beforeSlideFunctionnullThis function will be executed before starting every sliding
responsiveArraynullUse this for responsiveness Documentation
autoSlideNumber or Boolean2000Used to make carousel auto slide for every given time interval. Or for 2000ms if the prop value is true.
pauseOnMouseOverBooleantruePause auto sliding on mouse over the carousel.
hideArrowsOnNoSlidesBooleantrueHide arrows if there is only one slide to show.
marginString0pxAny valid css margin value for giving margin around the slider
paddingString0px 20pxAny valid css padding value for giving padding around the slider

License

MIT (Free Software, Chill Yeah!)

0.5.1

5 years ago

0.5.0

5 years ago

0.4.12

6 years ago

0.4.11

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.5

6 years ago

0.1.0

6 years ago