React Alice Carousel is a React component for building content galleries, content rotators and any React carousels.
👉 Live demo: v2.x.x
👉 Previous version: v1.x.x
- Auto Height
- Auto Play
- Auto Width
- Custom animation modes
- Custom rendered slides
- Infinite loop
- Mobile friendly
- Multiple items in the slide
- Responsive design
- Stage padding
- Show / hide anything (indicators, arrows, slides indexes)
- Swipe to slide
- Touch and Drag support
- TypeScript
npm i react-alice-carousel
# CSS
@import "react-alice-carousel/lib/alice-carousel.css";
# SCSS
@import "react-alice-carousel/lib/scss/alice-carousel.scss";
import React from 'react';
import AliceCarousel from 'react-alice-carousel';
import 'react-alice-carousel/lib/alice-carousel.css';
const handleDragStart = (e) => e.preventDefault();
const items = [
<img src="path-to-img" onDragStart={handleDragStart} className="yours-custom-class" />,
<img src="path-to-img" onDragStart={handleDragStart} className="yours-custom-class" />,
<img src="path-to-img" onDragStart={handleDragStart} className="yours-custom-class" />,
];
const Gallery = () => {
return (
<AliceCarousel mouseTracking items={items} />
);
}
activeIndex
: Number, default0
- Set carousel at the specified position.animationDuration
: Number, default400
- Set duration of animation.animationEasingFunction
: String or Function, defaultease
- Property sets how an animation progresses through the duration of each cycle.animationType
: String(slide
,fadeout
), defaultslide
- Set type of animation.autoHeight
: Boolean, defaultfalse
- Set auto height mode.autoWidth
: Boolean, defaultfalse
- Set auto width mode.autoPlay
: Boolean, defaultfalse
- Set autoplay mode.autoPlayControls
: Boolean, defaultfalse
- Show/hideplay/pause
buttons.autoPlayDirection
: String(ltr
,rtl
), defaultltr
- Set autoplay direction value.autoPlayInterval
: Number, default400
- Set autoplay interval value.autoPlayStrategy
: String(default
,action
,all
,none
) - Set a strategy for autoplay modedefault
- pause automatic playback on the hoveraction
- stop automatic playback if user action was detectedall
- mergedefault
&&action
strategiesnone
- ignore any user actions when theautoPlay
property was specified
controlsStrategy
: String (default
,responsive
) - Set a strategy for gallery controls. Dots navigation will be hidden if responsive property is set and the number of gallery elements is equal to the number of items in the slide.disableButtonsControls
: Boolean, defaultfalse
- Disable buttons controls.disableDotsControls
: Boolean, defaultfalse
- Disable dots controls.disableSlideInfo
: Boolean, defaulttrue
- Disable information about current slide.infinite
: Boolean, defaultfalse
- Set infinite mode.items
: Array, defaultundefined
- Set gallery items, preferable to use this property instead of children.mouseTracking
: Boolean, defaultfalse
- Enable mouse drag animation.paddingLeft
: Number, default0
- Set the gallery offset from the left.paddingRight
: Number, default0
- Set the gallery offset from the right.responsive
: Object, defaultundefined
- Set number of items in the slide. The key is the breakpoint (default is the result of: () => window.innerWidth).swipeDelta
: Number, default20
- Set minimum distance to the start of the swiping (px).swipeExtraPadding
: Number, default200
- Set maximum distance from initial place before swipe action will be stopped (px).touchTracking
: Boolean, defaulttrue
- Enable touch move animation.touchMoveDefaultEvents
: Boolean, defaulttrue
- Enable touch move default events on swiping.onInitialized
: Function - Fired as callback after the gallery was created.onResizeEvent
: Function - Fired duringresize
event to determine whether the event handler should be called.onResized
: Function - Fired as callback after the gallery was resized.onSlideChange
: Function - Fired while the event object is changing.onSlideChanged
: Function - Fired after the event object was changed.
slidePrev(e: any) => void
: Go to the prev slide.slideNext(e: any) => void
: Go to the next slide.slideTo(activeIndex?: number) => void
: Go to the specified slide.
git clone https://github.com/maxmarinich/react-alice-carousel
cd react-alice-carousel
npm i
npm start
npm test
MIT