Carousel

Carousel

Carousel is responsive and interactive slideshow which is created for presenting content, especially images and videos.

The carousel is a slideshow for cycling through a series of content. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.

Example

Default Carousel example.

import React from "react";
import { CDBCarousel, CDBCarouselItem, CDBCarouselInner, CDBView, CDBContainer } from "cdbreact";
export const Carousel = () => {
return (
<CDBContainer>
<CDBContainer>
<CDBCarousel
activeItem={1}
length={3}
showControls={true}
showIndicators={true}
className="z-depth-1"
slide
>
<CDBCarouselInner>
<CDBCarouselItem itemId="1">
<CDBView>
<img
className="d-block w-100"
src="https://imgur.com/oPU7JbX"
alt="First slide"
/>
</CDBView>
</CDBCarouselItem>
<CDBCarouselItem itemId="2">
<CDBView>
<img
className="d-block w-100"
src="https://imgur.com/EgVSItY"
alt="Second slide"
/>
</CDBView>
</CDBCarouselItem>
<CDBCarouselItem itemId="3">
<CDBView>
<img
className="d-block w-100"
src="https://imgur.com/c1aFo29"
alt="Third slide"
/>
</CDBView>
</CDBCarouselItem>
</CDBCarouselInner>
</CDBCarousel>
</CDBContainer>
</CDBContainer>
);
};

API

In this section you will find advanced information about the Carousel component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.

Contrast Carousel Import Statement

You need to import the Contrast Carousel component and any other proper modules first before using it.

import { CDBCarousel, CDBCarouselItem, CDBCarouselCaption, CDBCarouselInner, CDBView, CDBCarouselIndicator, CDBCarouselIndicators, CDBControl, CDBContainer } from "cdbreact";

API Reference: Contrast Carousel Properties

The table below shows the configuration options of the CDBCarousel component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarousel className="myClass" ... />
activeItemNumberThe index of default active item<CDBCarousel activeItem={1} ... />
intervalNumber or Boolean6000Time in milliseconds between slides changes<CDBCarousel interval={10000} ... />
lengthNumberIndicates amount of slides in the carousel<CDBCarousel length={3} ... />
tagfunction or StringdivChanges default html tag<CDBCarousel tag="div" ... />
mobileGestureBooleantrueSwitches on/off carousel mobile gesture.<CDBCarousel mobileGesture={false} .../>
multiItemBooleanfalseSwitches multiItem mode - more items in one view, changed controls<CDBCarousel multiItem={true} .../>
onHoverStopBooleantrueStops the changing slide when mouse is on the element of the carousel<CDBCarousel onHoverStop={false} .../>
showControlsBooleantrueSwitches on/off carousel controls<CDBCarousel showControls={false} .../>
showIndicatorsBooleantrueSwitches on/off carousel indicators<CDBCarousel showIndicators={false} .../>
slideBooleanfalseSwitches slide styles of carousel<CDBCarousel slide .../>
testimonialBooleanfalseSets black, bigger control arrows for testimonial carousels<CDBCarousel testimonial .../>
thumbnailsBooleanfalseReplaces simple dot indicators with miniature slides pictures<CDBCarousel thumbnails .../>

API Reference: Contrast Carousel Caption Properties

The table below shows the configuration options of the CDBCarouselCaption component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarouselCaption className="myClass" ... />
tagfunction or StringdivChanges default html tag<CDBCarouselCaption tag="div" ... />

API Reference: Contrast Carousel Controls Properties

The table below shows the configuration options of the CDBControl component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBControl className="myClass" ... />
directionStringSpecifies the slide direction. Can either be prev or next.<CDBControl direction="prev" ... />
iconLeftBooleanToggles left Icon's visibility<CDBControl IconLeft ... />
iconRightBooleanToggles right Icon's visibility<CDBControl IconRight ... />
onClickAnyperforms an action when clicked<CDBControl onClick={handleClick} ... />
tagfunction or StringdivChanges default html tag<CDBControl tag="div" ... />
multiItemBooleanfalseSwitches multiItem mode - more items in one view, changed controls<CDBCarousel multiItem={true} .../>
testimonialBooleanfalseSets black, bigger control arrows for testimonial carousels<CDBCarousel testimonial .../>

API Reference: Contrast Carousel Indicator Properties

The table below shows the configuration options of the CDBCarouselIndicator component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarouselIndicator className="myClass" ... />
activeBooleanSet as active item indicator<CDBCarouselIndicator active ... />
altString"Carousel thumbnail"Sets the alternate when image is yet to load<CDBCarouselIndicator alt="Carousel thumbnail" ... />
imgStringProvides the Carousel thumbnail<CDBCarouselIndicator img="img_url" ... />

API Reference: Contrast Carousel Indicators Properties

The table below shows the configuration options of the CDBCarouselIndicators component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarouselIndicators className="myClass" ... />

API Reference: Contrast Carousel Inner Properties

The table below shows the configuration options of the CDBCarouselInner component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarouselInner className="myClass" ... />
activeBooleanSet as active item<CDBCarouselInner active ... />
tagfunction or StringdivChanges default html tag<CDBCarouselInner tag="div" ... />

API Reference: Contrast Carousel Item Properties

The table below shows the configuration options of the CDBCarouselItem component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBCarouselItem className="myClass" ... />
activeBooleanSet as active item<CDBCarouselItem active ... />
tagfunction or StringdivChanges default html tag<CDBCarouselItem tag="div" ... />
itemIdNumberThe index of item in carousel<CDBCarouselItem itemId={1} ... />