Carousel
Bootstrap Carousel
Note: We are transitioning MDB4 to a legacy version and focusing on developing MDB5.
While we'll continue to support for the transition period, we encourage you to migrate to
MDB5. We're offering a huge discount on MDB5 PRO to help with your transition,
enabling you to leverage the full potential of the latest version. You can find more information here.
upgrade with discount
A slideshow component for cycling through elements—images or slides of text—like a carousel.
How it works
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 markups. It also includes support for previous/next controls and indicators.
In browsers where the Page Visibility API 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.
Example
Carousels don’t automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. So you may add and customize them as you see fit.
The .active
class needs to be added to one of the slides otherwise the
.carousel
will not be visible. Also be sure
to set a unique id on the .carousel for optional controls, especially if you’re using multiple carousels on a
single page. Control and indicator elements must have a data-target
attribute (or href
for links) that matches the
id of the carousel
element.
Slides only
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.
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(35).webp">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(33).webp">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(31).webp">
</div>
</div>
</div>
With controls
Adding in the previous and next controls:
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(45).webp"
alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(46).webp"
alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(47).webp"
alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
With indicators
You can also add indicators to the carousel, alongside its controls, too.
<!--Carousel Wrapper-->
<div id="carousel-example-1z" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-example-1z" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-1z" data-slide-to="1"></li>
<li data-target="#carousel-example-1z" data-slide-to="2"></li>
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<!--First slide-->
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(130).webp"
alt="First slide">
</div>
<!--/First slide-->
<!--Second slide-->
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(129).webp"
alt="Second slide">
</div>
<!--/Second slide-->
<!--Third slide-->
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(70).webp"
alt="Third slide">
</div>
<!--/Third slide-->
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#carousel-example-1z" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-example-1z" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>
<!--/.Carousel Wrapper-->
With captions
Add captions to your slides easily with the .carousel-caption
element within any
.carousel-item
. They can be easily hidden on smaller viewports, as shown below, with optional display
utilities. We
hide them initially with .d-none
and bring them back on medium-sized devices with
.d-md-block
.
If your content is not visible enough, you can cover the image with a darker mask.
You can easily change the intensity and color of the mask. To learn more read our MASKS documentation.
<!--Carousel Wrapper-->
<div id="carousel-example-2" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-example-2" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-2" data-slide-to="1"></li>
<li data-target="#carousel-example-2" data-slide-to="2"></li>
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="view">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(68).webp"
alt="First slide">
<div class="mask rgba-black-light"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">Light mask</h3>
<p>First text</p>
</div>
</div>
<div class="carousel-item">
<!--Mask color-->
<div class="view">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(6).webp"
alt="Second slide">
<div class="mask rgba-black-strong"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">Strong mask</h3>
<p>Secondary text</p>
</div>
</div>
<div class="carousel-item">
<!--Mask color-->
<div class="view">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(9).webp"
alt="Third slide">
<div class="mask rgba-black-slight"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">Slight mask</h3>
<p>Third text</p>
</div>
</div>
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#carousel-example-2" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-example-2" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>
<!--/.Carousel Wrapper-->
Crossfade
Add .carousel-fade
to your carousel to animate slides with a fade transition
instead of a slide.
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(15).webp"
alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(16).webp"
alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(17).webp"
alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleFade" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleFade" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Multi-item carousel MDB Pro component
Multi-item carousel component consists of two template tags - one with for a mobile view layout, and the second for a desktop view.
<!--Carousel Wrapper-->
<div id="multi-item-example" class="carousel slide carousel-multi-item" data-ride="carousel">
<!--Controls-->
<div class="controls-top">
<a class="btn-floating" href="#multi-item-example" data-slide="prev"><i class="fas fa-chevron-left"></i></a>
<a class="btn-floating" href="#multi-item-example" data-slide="next"><i
class="fas fa-chevron-right"></i></a>
</div>
<!--/.Controls-->
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#multi-item-example" data-slide-to="0" class="active"></li>
<li data-target="#multi-item-example" data-slide-to="1"></li>
<li data-target="#multi-item-example" data-slide-to="2"></li>
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<!--First slide-->
<div class="carousel-item active">
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(34).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(18).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(35).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
</div>
<!--/.First slide-->
<!--Second slide-->
<div class="carousel-item">
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/City/4-col/img%20(60).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/City/4-col/img%20(47).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/City/4-col/img%20(48).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
</div>
<!--/.Second slide-->
<!--Third slide-->
<div class="carousel-item">
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Food/4-col/img%20(53).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Food/4-col/img%20(45).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top"
src="https://mdbootstrap.com/img/Photos/Horizontal/Food/4-col/img%20(51).webp" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary">Button</a>
</div>
</div>
</div>
</div>
<!--/.Third slide-->
</div>
<!--/.Slides-->
</div>
<!--/.Carousel Wrapper-->
Multi Item Carousel Advance - 1 item per time MDB Pro component
<div id="carousel-example-multi" class="carousel slide carousel-multi-item v-2" data-ride="carousel">
<!--Controls-->
<div class="controls-top">
<a class="btn-floating" href="#carousel-example-multi" data-slide="prev"><i
class="fas fa-chevron-left"></i></a>
<a class="btn-floating" href="#carousel-example-multi" data-slide="next"><i
class="fas fa-chevron-right"></i></a>
</div>
<!--/.Controls-->
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-multi" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-multi" data-slide-to="1"></li>
<li data-target="#carousel-example-multi" data-slide-to="2"></li>
<li data-target="#carousel-example-multi" data-slide-to="3"></li>
<li data-target="#carousel-example-multi" data-slide-to="4"></li>
<li data-target="#carousel-example-multi" data-slide-to="5"></li>
</ol>
<!--/.Indicators-->
<div class="carousel-inner v-2" role="listbox">
<div class="carousel-item active">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (36).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (34).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (38).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (29).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (30).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-12 col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="https://mdbootstrap.com/img/Photos/Others/img (27).webp"
alt="Card image cap">
<div class="card-body">
<h4 class="card-title font-weight-bold">Card title</h4>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
<a class="btn btn-primary btn-md btn-rounded">Button</a>
</div>
</div>
</div>
</div>
</div>
</div>
$('.carousel.carousel-multi-item.v-2 .carousel-item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i=0;i<4;i++) {
next=next.next();
if (!next.length) {
next=$(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
Carousel with lightbox MDB Pro component
This is an easy combination carousel with a lightbox gallery!
If you want to use our carousel with lightbox, then check out our documentation about Lightbox.
<!--Carousel Wrapper-->
<div id="carousel-with-lb" class="carousel slide carousel-multi-item" data-ride="carousel">
<!--Controls-->
<div class="controls-top">
<a class="btn-floating btn-secondary" href="#carousel-with-lb" data-slide="prev"><i
class="fas fa-chevron-left"></i></a>
<a class="btn-floating btn-secondary" href="#carousel-with-lb" data-slide="next"><i
class="fas fa-chevron-right"></i></a>
</div>
<!--/.Controls-->
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-with-lb" data-slide-to="0" class="active secondary-color"></li>
<li data-target="#carousel-with-lb" data-slide-to="1" class="secondary-color"></li>
<li data-target="#carousel-with-lb" data-slide-to="2" class="secondary-color"></li>
</ol>
<!--/.Indicators-->
<!--Slides and lightbox-->
<div class="carousel-inner mdb-lightbox" role="listbox">
<div id="mdb-lightbox-ui"></div>
<!--First slide-->
<div class=" carousel-item active text-center">
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(2).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(2).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(4).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(4).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(6).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(6).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(10).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(10).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(12).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(12).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(14).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(14).webp"
class="img-fluid">
</a>
</figure>
</div>
<!--/.First slide-->
<!--Second slide-->
<div class="carousel-item text-center">
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(22).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(22).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(25).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(25).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(29).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(29).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(31).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(31).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(32).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(32).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(33).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(33).webp"
class="img-fluid">
</a>
</figure>
</div>
<!--/.Second slide-->
<!--Third slide-->
<div class="carousel-item text-center">
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(44).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(44).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(45).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(45).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(66).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(66).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(53).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(53).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(56).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(56).webp"
class="img-fluid">
</a>
</figure>
<figure class="col-md-4 d-md-inline-block">
<a href="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(77).webp"
data-size="1600x1067">
<img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/4-col/img%20(77).webp"
class="img-fluid">
</a>
</figure>
</div>
<!--/.Third slide-->
</div>
<!--/.Slides-->
</div>
<!--/.Carousel Wrapper-->
Thumbnails carousel MDB Pro component
A simple bootstrap slider with arrows and thumbnails as controls.
<!--Carousel Wrapper-->
<div id="carousel-thumb" class="carousel slide carousel-fade carousel-thumbnails" data-ride="carousel">
<!--Slides-->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(88).webp"
alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(121).webp"
alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(31).webp"
alt="Third slide">
</div>
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#carousel-thumb" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-thumb" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
<ol class="carousel-indicators">
<li data-target="#carousel-thumb" data-slide-to="0" class="active">
<img src="https://mdbootstrap.com/img/Photos/Others/Carousel-thumbs/img%20(88).webp" width="100">
</li>
<li data-target="#carousel-thumb" data-slide-to="1">
<img src="https://mdbootstrap.com/img/Photos/Others/Carousel-thumbs/img%20(121).webp" width="100">
</li>
<li data-target="#carousel-thumb" data-slide-to="2">
<img src="https://mdbootstrap.com/img/Photos/Others/Carousel-thumbs/img%20(31).webp" width="100">
</li>
</ol>
</div>
<!--/.Carousel Wrapper-->
Video carousel
Replace img
elements with video elements to create a video carousel.
<!--Carousel Wrapper-->
<div id="video-carousel-example" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#video-carousel-example" data-slide-to="0" class="active"></li>
<li data-target="#video-carousel-example" data-slide-to="1"></li>
<li data-target="#video-carousel-example" data-slide-to="2"></li>
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<video class="video-fluid" autoplay loop muted>
<source src="https://mdbootstrap.com/img/video/Tropical.mp4" type="video/mp4" />
</video>
</div>
<div class="carousel-item">
<video class="video-fluid" autoplay loop muted>
<source src="https://mdbootstrap.com/img/video/forest.mp4" type="video/mp4" />
</video>
</div>
<div class="carousel-item">
<video class="video-fluid" autoplay loop muted>
<source src="https://mdbootstrap.com/img/video/Agua-natural.mp4" type="video/mp4" />
</video>
</div>
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#video-carousel-example" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#video-carousel-example" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>
<!--Carousel Wrapper-->
Full page carousels
Click the buttons below to see a live preview.
Usage
Via data attributes
You can use data attributes to easily control the position of the carousel. data-slide
accepts the keywords
prev
or next
, these keyworks alter the slide position relative to its current position.
Alternatively, use data-slide-to
to pass a raw slide index to the carousel, e.g.
data-slide-to="2"
,
that shifts the slide position to a particular index beginning with 0
.
The data-ride="carousel"
attribute is used to mark a carousel as animating at page load.
It cannot be used in combination with a (redundant and unnecessary) explicit JavaScript initialization of
the
same carousel.
Via JavaScript
Callstarting the carousel manually with the code below.
$('.carousel').carousel()
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the
option name to data-
,
as in data-interval=""
.
Name | Type | Default | Description |
---|---|---|---|
interval | number | 5000 | The amount of time to delay between automatically cycling an item. If false, the carousel will not automatically cycle. |
pause | string | boolean | "hover" |
If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won't pause it. On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) for two intervals, before automatically resuming. Note that this is in addition to the above mouse behavior. |
wrap | boolean | true | Whether the carousel should cycle continuously or have hard stops. |
ride | string | false | Autoplays the carousel after the user manually cycles the first item. If "carousel", it autoplays the carousel on load. |
keyboard | boolean | true | Whether the carousel should react to keyboard events. |
touch | boolean | true | Whether the carousel should support left/right swipe interactions on touchscreen devices. |
Methods
Asynchronous methods and transitions
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
.carousel(options)
Initializes the carousel with an optional options object
and starts cycling through items.
$('.carousel').carousel({
interval: 2000
})
.carousel('cycle')
Cycles through the carousel items from left to right.
.carousel('pause')
Stops the carousel from cycling through items.
.carousel(number)
Cycles the carousel to a particular frame (0 based, similar to an array).
.carousel('prev')
Cycles to the previous item.
.carousel('next')
Cycles to the next item.
.carousel('dispose')
Destroys an element’s carousel.
Events
Bootstrap’s carousel class exposes two events for hooking into carousel functionality. Both of these events have the following additional properties:
direction
: The direction in which the carousel is sliding (either"left"
or"right"
).relatedTarget
: The DOM element that is being slid into place as the active item.from
: The index of the current item.to
: The index of the next item.
All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">
).
Event Type | Description |
---|---|
slide.bs.carousel | This event fires immediately when the slide instance method is invoked. |
slid.bs.carousel | This event is fired when the carousel has completed its slide transition. |
$('#myCarousel').on('slide.bs.carousel', function () {
// do something…
})
Change transition duration
The transition duration of .carousel-item
can be changed with the $carousel-transition
Sass variable before
compiling (or custom styles if you’re using compiled CSS). If multiple transitions are applied, make sure the
transform transition is defined first (eg. transition: transform 2s ease, opacity .5s ease-out
).
Carousel with gestures support
The Bootstrap allows to use touch support. It is setting to true
by default.
More about gestures you can read in our mobile gestures documentation.
Click on the button below to launch a live example and see the Carousel with a gestures support in action.
Live preview
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="w-100 d-block" src="https://mdbootstrap.com/img/Photos/Slides/img%20(35).webp">
</div>
<div class="carousel-item">
<img class="w-100 d-block" src="https://mdbootstrap.com/img/Photos/Slides/img%20(33).webp">
</div>
<div class="carousel-item">
<img class="w-100 d-block" src="https://mdbootstrap.com/img/Photos/Slides/img%20(31).webp">
</div>
</div>
</div>
$('.carousel').carousel({
touch: true // default
})