0.1.4 • Published 1 year ago

react-jollof-slider v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-jollof-slider

npm version minified + gzip typescript GitHub license

A lightweight, responsive, SSR supported, well tested, React.js slider component with autoplay support (autoplay pauses when an item is hovered). Customizable

Table of contents

Installation

npm

npm install react-jollof-slider

yarn

yarn add react-jollof-slider

Usage

Basic Example:

import { JollofSlider, SliderItem } from 'react-jollof-slider'

const items = [1, 2, 3, 4, 5]

function App() {
  return (
    <div className="App">
      <JollofSlider numberOfItems={items.length} isAutoplay isShowArrowNav={false} isShowDotNav>
        {items.map((text) => (
          <SliderItem key={text}>
            <div
              style={{
                backgroundColor: '#000000',
                color: '#c4c4c4',
                width: '100%',
                height: '18.25rem',
                padding: '1rem',
                display: 'grid',
                placeItems: 'center',
              }}
            >
              <p style={{ fontSize: '2rem' }}>{text}</p>
            </div>
          </SliderItem>
        ))}
      </JollofSlider>
    </div>
  )
}

export default App

Props

NameTypeDefault ValueDescription
*numberOfItemsnumberNumber of items to be displayed in the slider
customWidthobject{xs:240,sm:340,lg:490}The width of individual slider items at different screen sizes. lg: min-width(600px), sm: min-width(370px), xs: screens below 370px width . The width values should be provided in pixels.
isAutoplaybooleanfalseAdd autoplay functionality
isShowDotNavbooleanfalseShow navigation with dots which also indicate current slider position
isShowArrowNavbooleantrueShow buttons for moving slides forward and backward
childrennodenullslider items
forwardIconnodeundefinedIcon for the forward navigation button
backwardIconnodeundefinedIcon for the backward navigation button
autoPlayIntervalnumber3Interval (in seconds) between slide changes during autoplay.
flexgapnumber16Gap (in pixels) between slider items
themeColorstring#000000color of elements like buttons and indicators in the slider

Demo

Edit react-jollof-slider-demo