1.0.6 • Published 1 year ago

pure-react-carousel-thumbs v1.0.6

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

pure-react-carousel-thumbs

A simple carousel with no other dependencies with thumbnails. A simple, customizable carousel component for React applications. A customizable React carousel component with support for thumbnails, autoplay, swiping, and more.

Installation

npm install pure-react-carousel-thumbs

Usage

First, import the Carousel and CarouselThumbs components:

import { Carousel, CarouselThumbs } from 'pure-react-carousel-thumbs';

function App() {
  const images = [
    'https://your-image-url-1.jpg',
    'https://your-image-url-2.jpg',
    'https://your-image-url-3.jpg',
  ];

  const [currentIndex, setCurrentIndex] = useState(0);

  return (
    <>
      <Carousel images={images} onChange={setCurrentIndex} />
      <CarouselThumbs
        images={images}
        currentIndex={currentIndex}
        changeIndex={setCurrentIndex}
      />
    </>
  );
}

Carousel Component

The Carousel component displays a carousel of images with customizable options.

Props

PropTypeDefaultDescription
imagesstring[]undefinedundefined An array of image URLs to display in the carousel.
classNamestringundefinedundefined Optional CSS class for the carousel container.
changeOnClickbooleantrueWhether to change the slide when clicking on it.
coverbooleanfalseWhether to cover the entire carousel container otherwise background should scale with height set to auto.
indexnumber0The initial index of the carousel.
heightnumberstring'auto'The height of the carousel container.
widthnumberstring'100%'The width of the carousel container.
intervalnumber0The interval for autoplay (in milliseconds). Set to 0 to disable autoplay.
animationDurationnumber500The duration of the slide change animation (in milliseconds).
autoPlaybooleanfalseWhether to enable autoplay.
stopAutoPlayOnHoverbooleanfalseWhether to stop autoplay when hovering over the carousel.
swipebooleantrueWhether to enable swipe gestures.
navButtonsAlwaysVisiblebooleanfalseWhether to always show navigation buttons.
navButtonsAlwaysInvisiblebooleanfalseWhether to never show navigation buttons.

CarouselThumbs Component

The CarouselThumbs component displays a row of thumbnail images that can be clicked to change the current slide in the main carousel.

Props

PropTypeDefaultDescription
imagesstring[] | undefinedundefinedAn array of image URLs to display as thumbnails.
currentIndexnumber0The index of the currently displayed image in the main carousel.
changeIndex(newIndex: number) => voidundefinedA function that changes the index of the currently displayed image in the main carousel.
heightnumber | string'250px'The height of the thumbnail images.
widthnumber | string'250px'The width of the thumbnail images.
thumbsClassNamestringundefinedOptional CSS class for the thumbnail images.
containerClassNamestringundefinedOptional CSS class for the thumbnails container.
thumbStyleReact.CSSPropertiesundefinedOptional style object for the thumbnail images.
containerStyleReact.CSSPropertiesundefinedOptional style object for the thumbnails container.