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><CDBCarouselactiveItem={1}length={3}showControls={true}showIndicators={true}className="z-depth-1"slide><CDBCarouselInner><CDBCarouselItem itemId="1"><CDBView><imgclassName="d-block w-100"src="https://imgur.com/oPU7JbX"alt="First slide"/></CDBView></CDBCarouselItem><CDBCarouselItem itemId="2"><CDBView><imgclassName="d-block w-100"src="https://imgur.com/EgVSItY"alt="Second slide"/></CDBView></CDBCarouselItem><CDBCarouselItem itemId="3"><CDBView><imgclassName="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.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarousel className="myClass" ... /> | |
| activeItem | Number | The index of default active item | <CDBCarousel activeItem={1} ... /> | |
| interval | Number or Boolean | 6000 | Time in milliseconds between slides changes | <CDBCarousel interval={10000} ... /> |
| length | Number | Indicates amount of slides in the carousel | <CDBCarousel length={3} ... /> | |
| tag | function or String | div | Changes default html tag | <CDBCarousel tag="div" ... /> |
| mobileGesture | Boolean | true | Switches on/off carousel mobile gesture. | <CDBCarousel mobileGesture={false} .../> |
| multiItem | Boolean | false | Switches multiItem mode - more items in one view, changed controls | <CDBCarousel multiItem={true} .../> |
| onHoverStop | Boolean | true | Stops the changing slide when mouse is on the element of the carousel | <CDBCarousel onHoverStop={false} .../> |
| showControls | Boolean | true | Switches on/off carousel controls | <CDBCarousel showControls={false} .../> |
| showIndicators | Boolean | true | Switches on/off carousel indicators | <CDBCarousel showIndicators={false} .../> |
| slide | Boolean | false | Switches slide styles of carousel | <CDBCarousel slide .../> |
| testimonial | Boolean | false | Sets black, bigger control arrows for testimonial carousels | <CDBCarousel testimonial .../> |
| thumbnails | Boolean | false | Replaces 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.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarouselCaption className="myClass" ... /> | |
| tag | function or String | div | Changes default html tag | <CDBCarouselCaption tag="div" ... /> |
API Reference: Contrast Carousel Controls Properties
The table below shows the configuration options of the CDBControl component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBControl className="myClass" ... /> | |
| direction | String | Specifies the slide direction. Can either be prev or next. | <CDBControl direction="prev" ... /> | |
| iconLeft | Boolean | Toggles left Icon's visibility | <CDBControl IconLeft ... /> | |
| iconRight | Boolean | Toggles right Icon's visibility | <CDBControl IconRight ... /> | |
| onClick | Any | performs an action when clicked | <CDBControl onClick={handleClick} ... /> | |
| tag | function or String | div | Changes default html tag | <CDBControl tag="div" ... /> |
| multiItem | Boolean | false | Switches multiItem mode - more items in one view, changed controls | <CDBCarousel multiItem={true} .../> |
| testimonial | Boolean | false | Sets 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.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarouselIndicator className="myClass" ... /> | |
| active | Boolean | Set as active item indicator | <CDBCarouselIndicator active ... /> | |
| alt | String | "Carousel thumbnail" | Sets the alternate when image is yet to load | <CDBCarouselIndicator alt="Carousel thumbnail" ... /> |
| img | String | Provides the Carousel thumbnail | <CDBCarouselIndicator img="img_url" ... /> |
API Reference: Contrast Carousel Indicators Properties
The table below shows the configuration options of the CDBCarouselIndicators component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarouselIndicators className="myClass" ... /> |
API Reference: Contrast Carousel Inner Properties
The table below shows the configuration options of the CDBCarouselInner component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarouselInner className="myClass" ... /> | |
| active | Boolean | Set as active item | <CDBCarouselInner active ... /> | |
| tag | function or String | div | Changes default html tag | <CDBCarouselInner tag="div" ... /> |
API Reference: Contrast Carousel Item Properties
The table below shows the configuration options of the CDBCarouselItem component.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBCarouselItem className="myClass" ... /> | |
| active | Boolean | Set as active item | <CDBCarouselItem active ... /> | |
| tag | function or String | div | Changes default html tag | <CDBCarouselItem tag="div" ... /> |
| itemId | Number | The index of item in carousel | <CDBCarouselItem itemId={1} ... /> |