1.10.2 • Published 2 months ago

@fil1pe/react-slider v1.10.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

React Slider

This is a simple slider implementation in React. Make your own carousels of images, texts or whatever you need easily with this component and some stylesheet.

Installation

npm

$ npm install @fil1pe/react-slider --save

yarn

$ yarn add @fil1pe/react-slider

Usage

In your JSX file, import the slider component as in the example below. You are free to customize it using the prop className and the classes that follow.

Classes

Class nameDescription
.maindiv wrapping the track and arrows
.arrowprev/next button
.disabledif arrow is disabled
.trackwraps the ul containing the slides
.dotsul with the dots
.activeactive slide/dot
.pagespagination info

Component props

PropertyDefault valueRequiredDescription
classNamenonefalseClass name of your slider component wrapper
slidesToShow1falseNumber of slides per page
slidesToScrollslidesToShowfalseNumber of slides to scroll on click on prev/next
finitefalsefalseDefines whether the slider should have finite scrolling or not
renderArrow(props, type) => <button {...props}>{type === ArrowType.Next ? 'Next' : 'Previous'}</button>falseAllows customizing the arrow buttons
renderControllernonefalseFunction that renders additional controllers in the wrapper div .main (e.g. full-screen button). Receives the current slide index as argument
autoplayTimeoutnone (∞)falseAutoplay interval in milliseconds
slidesToAppendnonefalseAdditional number of slides to append before and after
adaptiveHeightfalsefalseVariable height
pagination0falseShows current slide index alongside the total number of slides(1 for no spacing, 2 otherwise)
onSlideChange(int)nonefalseFunction triggered on slide change

Methods

Referencing the slider allows you to manually change the current slide through the methods below.

MethodArgumentsDescription
slickGoToslide indexNavigates to the specified slide
slickNextnoneGoes to the next slide
slickPrevnoneGoes to the previous slide

Provider

The SliderProvider exported by this package is used to adjust the slides positioning during screen resizing, preventing visual bugs.

Example

import React from 'react'
import Slider from '@fil1pe/react-slider'

function App() {
  return (
    <SliderProvider>
      <Slider slidesToShow={2} slidesToScroll={1} className="slider">
        <div class="slide">1</div>
        <div class="slide">2</div>
        <div class="slide">3</div>
        <div class="slide">4</div>
        <div class="slide">5</div>
      </Slider>
    </SliderProvider>
  )
}

export default App
1.10.2

2 months ago

1.10.1

2 months ago

1.10.0

3 months ago

1.9.8

4 months ago

1.9.7

4 months ago

1.9.6

5 months ago

1.9.5

10 months ago

1.9.4

11 months ago

1.9.3

11 months ago

1.9.1

1 year ago

1.9.2

1 year ago

1.9.0

1 year ago

1.7.3

1 year ago

1.7.2

2 years ago

1.8.0

1 year ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.0.0

2 years ago

0.7.1

2 years ago

0.6.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.1.4

2 years ago

0.4.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago