0.1.1 • Published 4 years ago
@khan-asfi-reza/react-slider v0.1.1
Features 🎆
- Responsive carousel slider
- Multiple slides in slide window
- Autoplay with interval control
- No need to add any stylesheet
- Lightweight
Docs 📕
Props & Options
| Props | Description | Type |
|---|---|---|
| children | Carousel slides | ReactChild[] |
| slidesInViewport | Number of slides in the viewport | number / SlideNumberOption |
| gap | Gap between slides | boolean |
| onSlideChange | Function to execute on each slide change | Function / method |
| autoplay | If the carousel needs to play automatically | boolean |
| interval | Interval of slide change for autoplay | number |
| buttonClassName | slide change button classname | string |
gapIf gap is true there will be gap between slides
onSlideChangeOn slide change event will be executed when one slide will be changedautoplayCarousel to move to next slide automatically
childrenReact Child Nodes, basically list of components, that will act as slideintervalInterval between autoplay, to interval work,autoplaymust betruebuttonClassNameSlide change button classname
slidesInViewportHow many slides will be shown in the viewport, it can be a number or an object of breakpoints
<Carousel
slidesInViewport={{
xxl: 6,
xl: 5,
lg: 4,
md: 3,
sm: 2,
xs: 1,
base: 1
}}>
...
</Carousel>the breakpoint option, not each one is required
| Keys | Description |
|---|---|
| xxl | min-width(1400px) |
| xl | min-width(1200px) |
| lg | min-width(992px) |
| md | min-width(768px) |
| sm | min-width(576px) |
| sm | min-width(320px) |
| base | Any Orientation |
it can be a number as well, which will work for every screen orientation
<Carousel slidesInViewport={4}>
...
</Carousel>Example
import Carousel from "react-slider";
<Carousel gap slidesInViewport={2}>
<div>
<h1>
Flex box 1
</h1>
</div>
<div>
<h1>
Flex box 2
</h1>
</div>
<div>
<h1>
Flex box 3
</h1>
</div>
</Carousel>