A slideshow component for cycling through elements—images or slides of text—like a carousel.
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.
In browsers where the Page Visibility is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
Please be aware that nested carousels are not supported, and carousels are generally not compliant with accessibility standards.
Adding in the previous and next controls. We recommend using control
attribute.
You can add indicators to the carousel, alongside the previous/next controls. The indicators let users jump directly to a particular slide.
Add captions to your slides easily with the CarouselCaption
element within any CarouselItem
.
They can be easily hidden on smaller viewports, as shown below, with optional display utilities .
We hide them initially with display="none
and bring them back on medium-sized devices with display="none
.
Add fade
attribute to your carousel to animate slides with a fade transition instead of a slide.
Here's a carousel with slides only.
Note the presence of the d-block
and w-100
on carousel images to prevent browser default image alignment.
CarouselItem
interval Add interval
attribute to a CarouselItem
component to change the amount of time to delay between automatically cycling to the next item.
Carousels support swiping left/right on touchscreen devices to move between slides.
This can be disabled using the touch
attribute.
The example below also does not include the ride
attribute and has touch="false"
so it doesn't autoplay.
Add dark
attribute to the Carousel
component for darker controls, indicators, and captions.
Method | Description |
---|---|
cycle | Circulate items from left to right |
pause | Stop circulating items |
prev | Circulate to previous item |
next | Circulate to next item |
to | Circulate to specific items |