Bootstrap 5 - Carousel

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

Example 1: Bootstrap 5 Basic Carousel

<div id="carouselExample" class="carousel slide">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://www.ankitweblogic.com/images/banner1.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner2.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner3.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>

Bootstrap 5 Carousel Indicators

Example 2: Bootstrap 5 Carousel with Indicators

<div id="carouselExample" class="carousel slide">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://www.ankitweblogic.com/images/banner1.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner2.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner3.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>

Bootstrap 5 Carousel Caption

Example 3: Bootstrap 5 Carousel with caption

<div id="carouselExample" class="carousel slide">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://www.ankitweblogic.com/images/banner1.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>First slide label</h5>
        <p>Some representative placeholder content for the first slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner2.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>Second slide label</h5>
        <p>Some representative placeholder content for the second slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner3.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  div class="carousel-caption d-none d-md-block">
        <h5>Third slide label</h5>
        <p>Some representative placeholder content for the third slide.</p>
      </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>

Bootstrap 5 Carousel Autoplay

Example 4: Bootstrap 5 Carousel autoplay

<div id="carouselExample" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://www.ankitweblogic.com/images/banner1.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>First slide label</h5>
        <p>Some representative placeholder content for the first slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner2.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>Second slide label</h5>
        <p>Some representative placeholder content for the second slide.</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://www.ankitweblogic.com/images/banner3.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  div class="carousel-caption d-none d-md-block">
        <h5>Third slide label</h5>
        <p>Some representative placeholder content for the third slide.</p>
      </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>

Bootstrap 5 Carousel Interval

Add carousel-dark class with carousel and slide class to dark the caption, add attribute data-bs-interval in carousel-item div.

Example 5: Bootstrap 5 Carousel with dark caption and with time interval

<div id="carouselExample" class="carousel slide carousel-dark" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="0" class="active"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="1"></button>
    <button type="button" data-bs-target="#carouselExample" data-bs-slide-to="2"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active" data-bs-interval="1000">
      <img src="https://www.ankitweblogic.com/images/banner1.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>First slide label</h5>
        <p>Some representative placeholder content for the first slide.</p>
      </div>
    </div>
    <div class="carousel-item" data-bs-interval="1000">
      <img src="https://www.ankitweblogic.com/images/banner2.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  <div class="carousel-caption d-none d-md-block">
        <h5>Second slide label</h5>
        <p>Some representative placeholder content for the second slide.</p>
      </div>
    </div>
    <div class="carousel-item" data-bs-interval="3000">
      <img src="https://www.ankitweblogic.com/images/banner3.jpg" class="d-block w-100" alt="Bootstrap 5 Carousel">
	  div class="carousel-caption d-none d-md-block">
        <h5>Third slide label</h5>
        <p>Some representative placeholder content for the third slide.</p>
      </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
    <span class="carousel-control-next-icon"></span>
  </button>
</div>