Carousel

A slideshow component for cycling through elements—images or slides of text—like a carousel.

Bootstrap 4 documentation
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 markup. 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.).

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.

                                                        
<!-- Carousel -->
<div id="Carousel1" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img src="../../assets/img/carousel/image-1.jpg" class="d-block w-100" alt="slide1">
        </div>
        <div class="carousel-item">
            <img src="../../assets/img/carousel/image-2.jpg" class="d-block w-100" alt="slide2">
        </div>
        <div class="carousel-item">
            <img src="../../assets/img/carousel/image-3.jpg" class="d-block w-100" alt="slide3">
        </div>
    </div>
</div>
<!-- End of Carousel -->
                                                        
                                                    
With controls

Adding in the previous and next controls:

                                                        
<!-- Carousel -->
<div id="Carousel2" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img class="d-block w-100" src="../../assets/img/carousel/image-1.jpg" alt="First slide">
        </div>
        <div class="carousel-item">
            <img class="d-block w-100" src="../../assets/img/carousel/image-2.jpg" alt="Second slide">
        </div>
        <div class="carousel-item">
            <img class="d-block w-100" src="../../assets/img/carousel/image-3.jpg" alt="Third slide">
        </div>
    </div>
    <a class="carousel-control-prev" href="#Carousel2" 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="#Carousel2" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
<!-- End of Carousel -->
                                                        
                                                    
With indicators

You can also add the indicators to the carousel, alongside the controls, too.

                                                        
<!-- Carousel -->
<div id="Carousel3" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#Carousel3" data-slide-to="0" class="active"></li>
        <li data-target="#Carousel3" data-slide-to="1"></li>
        <li data-target="#Carousel3" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner">
        <div class="carousel-item active">
        <img class="d-block w-100" src="../../assets/img/carousel/image-1.jpg" alt="First slide">
        </div>
        <div class="carousel-item">
        <img class="d-block w-100" src="../../assets/img/carousel/image-2.jpg" alt="Second slide">
        </div>
        <div class="carousel-item">
        <img class="d-block w-100" src="../../assets/img/carousel/image-3.jpg" alt="Third slide">
        </div>
    </div>
    <a class="carousel-control-prev" href="#Carousel3" 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="#Carousel3" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
<!-- End of Carousel -->
                                                        
                                                    
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.

                                                        
<!-- Carousel -->
<div id="Carousel4" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#Carousel4" data-slide-to="0" class="active"></li>
        <li data-target="#Carousel4" data-slide-to="1"></li>
        <li data-target="#Carousel4" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner">
        <div class="carousel-item overlay-dark active">
            <img class="d-block w-100" src="../../assets/img/carousel/image-1.jpg" alt="First slide">
            <div class="carousel-caption d-none d-md-block">
                <h5>First Title</h5>
                <p class="lead">Start your development with a Pixel Design System for Bootstrap 4. It is creative and it features many components that can help you create amazing websites.</p>
            </div>
        </div>
        <div class="carousel-item overlay-dark">
            <img class="d-block w-100" src="../../assets/img/carousel/image-2.jpg" alt="Second slide">
            <div class="carousel-caption d-none d-md-block">
                <h5>Second Title</h5>
                <p class="lead">Start your development with a Pixel Design System for Bootstrap 4. It is creative and it features many components that can help you create amazing websites.</p>
            </div>
        </div>
        <div class="carousel-item overlay-dark">
            <img class="d-block w-100" src="../../assets/img/carousel/image-3.jpg" alt="Third slide">
            <div class="carousel-caption d-none d-md-block">
                <h5>Third Title</h5>
                <p class="lead">Start your development with a Pixel Design System for Bootstrap 4. It is creative and it features many components that can help you create amazing websites.</p>
            </div>
        </div>
    </div>
    <a class="carousel-control-prev" href="#Carousel4" 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="#Carousel4" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
<!-- End of Carousel -->