1.3.2 • Published 1 year ago

react-configurable-carousel v1.3.2

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

react-configurable-carousel

A simple and responsive configurable 2D/3D carousel React component to display anything you like!

Latest Update:

Now you can use custom buttons to navigate the carousel! Jump to Section - Custom Buttons

Online Storybook Demo

3D-Style

2D-Style

Installation

npm install react-configurable-carousel

Code Examples

import { Carousel } from "react-configurable-carousel";

<Carousel
  arrows={true}
  dotsNavigation={true}
  dotsNavigationInside={true}
  width={"1200px"}
  height={"400px"}
  carouselStyle={"3d"}
>  
  <img src={imageSrc}/>  
  <MyComponent/>
  <span>
    <h2>Hello, world!</h2>
  </span>
</Carousel>;

Using custom elements as buttons

Carousel's navigation functionality can be exposed with useRef hook

JavaScript

const controllerRef = useRef();

<Carousel
  {...args}
  ref={controllRef}
>  
  <Child/>
</Carousel>;

<button onClick={() => controllerRef.current.shiftLeft()}>Shift Left</button>

TypeScript

import { CarouselControllerHandle } from "react-configurable-carousel"

const controllerRef = useRef<CarouselControllerHandle>(null);

<Carousel
  {...args}
  ref={controllRef}
>  
  <Child/>
</Carousel>;

<button onClick={() => controllerRef.current.shiftLeft()}>Shift Left</button>

Options

<Carousel /> displays the components passed in as children

It takes the following props:

PropertyTypeDescription
arrowsbooleanShows/hides navigation arrows
dotsNavigationbooleanShows/hides navigation dots
widthstringCSS Property for carousel width
heightstringCSS Property for carousel height
children?ReactNodeComponents that will be displayed in the Carousel
carouselStyle?"flat" \| "3d"Carousel style
dotsNavigationInside?booleanPlaces navigation dots inside of carousel (Defaults to false)
dotNavigationOutlineColor?stringNavigation dots border color
dotNavigationFillColor?numberNavigation dots active fill color
autoScrollInterval?numberTime interval for auto-scro ll. Auto-scroll will be disabled if not specified
autoScrollClickDelay?numberTime delay for auto-scroll after user interacts with the carousel
outOfFocusDarken?booleanWhether the elements that are not currently selected will be darkened (Defaults to false)
ref?React.RefObject<CarouselControllerHandle>CarouselControllerHandle that exposes the Carousel navigation functionality

Exposed navigation functionality

Type CarouselControllerHandle has the following methods:

PropertyTypeDescription
ShiftLeft() => voidShifts the carousel left from current position
ShiftRight() => voidShifts the carousel right from current position
JumpToIndex(index: number) => voidShifts the carousel to certain index
1.3.2

1 year ago

1.2.0

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.9

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.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