1.0.16 • Published 1 year ago

react-rwd-slideshow v1.0.16

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

React RWD Slideshow

A simple Slideshow, very customizable, works with arrows for changing slides and also with touch, so is ready for desktop, tablet and mobile. No dependencies!!

Features

  • Custom Controls
  • Toggle Dots
  • Toggle Arrows
  • Any react component can be used as an Slide
  • Custom classNames (tailwindCSS can be used)
  • Gap support for spacing between slides
  • SSR

Install

$ npm install react-rwd-slideshow --save

Use it

Import the Slideshow component from react-rwd-slideshow and put your component/image/html/etc inside Slideshow.Item

import React from 'react';
import Slideshow from 'react-rwd-slideshow';

const Gallery = () => {
  const randomImageUrl = 'https://picsum.photos/800/600?random=';
  const imgStyle = {
    height: '300px',
    width: '100%',
    borderRadius: '8px',
  };
  const wrapperStyle = {
    width: '425px',
    margin: '25px auto 50px',
  };
  return (
    <div style={wrapperStyle}>
      <Slideshow gap={100} scrollSnap showDots>
        <Slideshow.Item>
          <img width='100%' src='https://picsum.photos/800/600?random=1' />
        </Slideshow.Item>

        {[...Array(5)].map((_, index) => (
          <Slideshow.Item key={index}>
            <img src={`${randomImageUrl}${index}`} style={imgStyle} />
          </Slideshow.Item>
        ))}
      </Slideshow>
    </div>
  );
};

Props

PropTypeDefaultDescription
gapNumber0Space (grid-gap) for each slide in the slideshow in px
scrollSnapBooleantruetrue for applying scroll-snap to slides
hideArrowBooleanfalseShow/hide the arrow prev/next arrows
showDotsBooleanfalseShow dots indicate the current slide
dotColorActiveStringrgb(255 255 255 / 100%)Valid css color value for active dot
dotColorInactiveStringrgb(255 255 255 / 44%)Valid css color value for inactive dot
arrowLeftElementCustom left arrow
arrowRightElementCustom right arrow
dotElementCustom dot component with prop isActive
customContainerStyleObjectStyle object for slideshow container
slideViewerClassNameStringClassname for the slide viewer
slideTrayClassNameStringClassname for the slide tray
slideWrapperClassNameStringClassname for the slide wrapper
slideClassNameStringClassname for the slide
arrowContainerClassNameStringClassname for the arrow container
arrowWrapperClassNameStringClassname for the arrow wrapper
arrowClassNameStringClassname for the arrow
dotWrapperClassNameStringClassname for the dot wrapper
dotClassNameStringClassname for the dot selector
onCurrentSlideChangedFunctionFunction to get the current Slide

Custom dot

const customDot = ({ isActive }) => (
  <div
    style={{
      height: isActive ? '10px' : '5px',
      width: isActive ? '10px' : '5px',
      background: '#000'
    }}
  />
)

<Slideshow dot={customDot} />
1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago