The Wayback Machine - https://web.archive.org/web/20241127043257/https://www.geeksforgeeks.org/bootstrap-5-carousel/
Open In App

Bootstrap 5 Carousel

Last Updated : 29 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Bootstrap 5 Carousel is a slideshow component for cycling through images or slides, allowing users to showcase multiple pieces of content in a visually appealing and interactive way. It offers various options for customization and responsive design.

Bootstrap Carousel Classes:

ClassDescription
carouselApplied to the main container div to initialize the carousel.
carousel-slideApplied to individual slides within the carousel.
carousel-innerApplied to a container div to hold all the slides.
carousel-itemApplied to each slide within the carousel inner container.
carousel-control-prevApplied to the left navigation control button.
carousel-control-nextApplied to the right navigation control button.
carousel-control-prev-iconApplied to the icon inside the left navigation control button.
carousel-control-next-iconApplied to the icon inside the right navigation control button.
carousel-indicatorsApplied to a container ul to hold the slide indicators.
activeApplied to the active slide and indicator to indicate the currently displayed slide.

.carousel-caption

to add a caption to the slide.

Examples of Bootstrap 5 Carousel

Example: This is a Bootstrap 5 carousel with previous and next arrows styled black. It displays images with slide indicators and navigation controls, allowing users to navigate through the carousel slides.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>Bootstrap 5 Carousel</title>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
        crossorigin="anonymous"></script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
        crossorigin="anonymous"></script>
    <style>
        .carousel-control-prev-icon,
        .carousel-control-next-icon {
            background-color: black;
        }
    </style>
</head>

<body style="text-align: center;">
    <div class="container mt-3">
        <div id="GFG" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->
            <ul class="carousel-indicators">
                <li data-target="#GFG" data-slide-to="0" class="active"></li>
                <li data-target="#GFG" data-slide-to="1"></li>
                <li data-target="#GFG" data-slide-to="2"></li>
            </ul>
            <!-- The slideshow -->
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png" 
                         alt="GFG">
                </div>
                <div class="carousel-item">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190918234528/colorize1.png"
                        alt="GFG">
                </div>
                <div class="carousel-item">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190918234815/colorize2.png"
                         alt="GFG">
                </div>
            </div>
            <a class="carousel-control-prev" 
               href="#GFG" 
               data-slide="prev">
                <span class="carousel-control-prev-icon"></span>
            </a>
            <a class="carousel-control-next" 
               href="#GFG" 
               data-slide="next">
                <span class="carousel-control-next-icon"></span>
            </a>
        </div>
    </div>
</body>

</html>

Output:

Add Captions to Slides:

Use .carousel-caption class inside the .carousel-item class to add a caption to the slide.

Example: Bootstrap Carousel with indicators, captions, and navigation controls. Customized indicators and captions with Bootstrap classes. Slide transition and navigation controlled by Bootstrap JavaScript.

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        Bootstrap Carousel
    </title>
    <!-- Load Bootstrap -->
    <link rel="stylesheet" 
          href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
        integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" 
        crossorigin="anonymous">
    <script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
        integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" 
        crossorigin="anonymous">

        </script>
    <script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
        integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/" 
        crossorigin="anonymous">
        </script>
</head>
<style>
    /* Customizing the carousel for white background */
    .carousel-indicators .active {
        background-color: green;
    }

    .carousel-indicators li {
        background-color: burlywood;
    }
</style>

<body style="text-align: center;">
    <div class="container mt-3">
        <div id="GFG" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->
            <ul class="carousel-indicators">
                <li data-target="#GFG" data-slide-to="0" class="active">
                </li>
                <li data-target="#GFG" data-slide-to="1"></li>
                <li data-target="#GFG" data-slide-to="2"></li>
            </ul>
            <!-- The slideshow -->
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png" 
                         alt="GFG">
                    <div class="carousel-caption">
                        <h3 class="text-warning">
                            Image 1
                        </h3>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src=

                       "https://media.geeksforgeeks.org/wp-content/uploads/20190918234528/colorize1.png"
                        alt="GFG">
                    <div class="carousel-caption">
                        <h3 class="text-warning">
                            Image 2
                        </h3>
                    </div>
                </div>
                <div class="carousel-item">
                    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190918234815/colorize2.png"
                        alt="GFG" />
                    <div class="carousel-caption">
                        <h3 class="text-warning">
                            Image 3
                        </h3>
                    </div>
                </div>
            </div>
            <a class="carousel-control-prev" 
               href="#GFG" 
               data-slide="prev">
                <span class="carousel-control-prev-icon">
                </span>
            </a>
            <a class="carousel-control-next"
               href="#GFG" 
               data-slide="next">
                <span class="carousel-control-next-icon">
                </span>
            </a>
        </div>
    </div>
</body>

</html>

Output:



Previous Article
Next Article

Similar Reads

Bootstrap 5 Carousel Individual .carousel-item interval
Bootstrap 5 Carousel Individual .carousel-item interval is used to give time intervals to individual carousel items by which the carousel items will be automatically cycled at the given intervals of time. Bootstrap 5 Carousel Classes: carousel-item: This class specifies each item of the carousel.Bootstrap 5 Carousel Attributes: data-bs-interval="":
3 min read
Image Carousel using react-native-snap-carousel package
A React-Native Image Carousel offers seamless navigation through a series of images in a horizontal format. Using React-Native's framework, developers create dynamic carousels with swipe gestures, pagination indicators, and smooth transitions. This component is ideal for product galleries, sliders, or multimedia presentations in mobile apps, enhanc
3 min read
How to display bootstrap carousel with three post in each slide?
A Bootstrap Carousel is a slideshow for rotating through a series of contents. It is built with CSS and Javascript. It works with a series of photos, images, texts, etc. It can be used as an image slider for showcasing a huge amount of content within a small space on the web page, as it works on the principle of dynamic presentations. Syntax: <d
5 min read
How to wrap text around circular carousel in Bootstrap 4 ?
Wrapping up a circular carousel is quite hectic compare to wrapping up a circular image or any shape of the image. In this article first, we have to create a carousel to make that circular, then we can use the text to wrap the carousel. First, you have to create Bootstrap Carousel. To make that carousel circular you can use CSS border-radius proper
2 min read
How to fade in and fade out background with bootstrap text carousel ?
In this article, we will show you how to fade in and fade out the background with a bootstrap text carousel. Carousel is a slideshow, and it is used for cycling components like images or text. Approach: To create a fade-in and fade-out background with a bootstrap text carousel we have followed some basic steps. Step 1: Add bootstrap CDN to your HTM
2 min read
What is use of the carousel-item Class in Bootstrap?
The .carousel-item class is utilized to structure the content of each slide within a Bootstrap carousel. It ensures consistent styling and behavior for each slide, including positioning, transitions, and responsiveness. By applying this class to elements containing slide content, developers can easily create a carousel with multiple slides that tra
1 min read
What are Different Types of Carousel Indicators in Bootstrap ?
In Bootstrap, carousel indicators are used to indicate the currently active slide within a carousel component. There are two types of carousel indicators provided by Bootstrap: Dot IndicatorsDot indicators are the default type of indicators used in Bootstrap carousels. They are represented by small circular dots located below the carousel slides. E
2 min read
How to Add a Responsive Carousel with Captions in Bootstrap ?
Carousels are interactive components in web design, often used to display multiple images or content sequentially. They're useful for showcasing images one after another, with captions providing additional context or information. We will see how to create a responsive carousel with captions in Bootstrap. ApproachFirst, create a basic HTML structure
2 min read
How to Create Carousel with Progress Indicators in Bootstrap ?
Bootstrap, the popular front-end framework, provides components to enhance the user experience on websites. One such essential component is the Carousel, which allows you to showcase a series of images or content in an interactive and visually appealing manner. We will look into creating a Bootstrap Carousel with Progress Indicators, adding a dynam
3 min read
How to Create a Carousel in Bootstrap ?
Carousels are commonly used to showcase multiple images or content dynamically and interactively. It provides a convenient way to implement carousels with built-in functionality and styles. Approach:Create an HTML document with Bootstrap 5 library classes for styling.Create a container with a centered heading, followed by a responsive carousel cont
2 min read
How to make multi item carousel using Bootstrap 5
We will learn how to implement a multi-item carousel using Bootstrap 5. The carousel component in Bootstrap 5 provides a user-friendly way to display a rotating set of content, such as images or text, in a sliding manner. This feature is commonly used for showcasing products, portfolios, or any content that you want to highlight in a visually appea
3 min read
How to Create Carousel with Multiple Items & Rounded Image in Bootstrap ?
In Bootstrap, a carousel presents dynamic image slideshows or content showcases. Crafting a carousel with multiple items and rounded images in Bootstrap 5 involves tailoring the carousel layout and styling images with rounded edges for a visually appealing presentation. ApproachCreate an HTML file and include the necessary Bootstrap CSS and JavaScr
2 min read
How to make Responsive Carousel in Bootstrap ?
Bootstrap Responsive Carousel simplifies the creation of responsive carousels for dynamic content display. Utilize the Carousel component with a suitable HTML structure, ensuring proper sizing and responsive breakpoints for optimal display across devices. ApproachCreate an HTML document with Bootstrap for styling. Create a container with a centered
2 min read
Bootstrap Carousel
Bootstrap Carousel enables slideshow functionality for images or content. Easily customizable with CSS and JavaScript. Supports responsive design and touch gestures, enhancing user experience in web development projects. It can be included in your webpage using "bootstrap.js" or "bootstrap.min.js". Carousels are not supported properly in Internet E
4 min read
How to Create Different Carousel Types in Bootstrap ?
Bootstrap 5 Carousel is a responsive component ideal for dynamic image slideshows or content presentations. It utilizes CSS 3D transforms and JavaScript for cycling through images or custom markup, offering previous/next controls and indicators for an engaging user experience across devices. These are the following approaches for adding a Carousel:
3 min read
Design a Responsive Card with a Carousel inside it in Bootstrap
A responsive carousel displays images or content in a rotating manner, adjusting seamlessly to different screen sizes for optimal viewing experience. In this article, we will create a responsive card with a carousel inside it with the help of Bootstrap5. Preview:[video loading="lazy" mp4="https://media.geeksforgeeks.org/wp-content/uploads/202407212
2 min read
Ng Bootstrap Carousel Arrows and Indicators
Ng Bootstrap is a popular tool for the betterment of the UI of a web application. As it's powered by Angular, knowing Angular means one also knows Ng Bootstrap. Ng Bootstrap exists on the latest version of Bootstrap - the Bootstrap 5 version and offers a list of meticulously quality-tested widgets, one of which is the Carousel widget. Installing Ng
4 min read
React-Bootstrap Carousel Dark variant
React-Bootstrap is a front-end framework that was designed keeping React in mind. Carousel Component provides a way to create a slideshow for our images or text slides in a present full manner in a cyclic way. In this article, we will learn about React-Bootstrap Carousel Dark variant. Technologies UsedNPM or NPXReact JSThere are two approaches to a
3 min read
React-Bootstrap Carousel API
React carousels, or sliders, are a popular UI (User Interface) component used in web development to showcase multiple items or images in a single, interactive, and space-efficient container. Carousels are commonly used for displaying product images, testimonials, news articles, or any other content that can be cycled through. Syntax: <Carousel
4 min read
Bootstrap 5 Carousel Dark variant
Bootstrap 5 Carousel Dark variant is by default, controls, indicators, and captions have white colors. But, for Darker controls, indicators, and captions, we can add a class carousel-dark to the carousel. Used class: carousel-dark: This class is used to include the dark variant for the carousel container.Syntax: <div id="GFG" class="carousel car
2 min read
Explain the uses of carousel plugin in Bootstrap
Bootstrap is a free and open-source tool collection for creating responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. It solves many problems which we had once, including the cross-browser compatibility issue. Carousel is the slideshow component of Boo
3 min read
What are the components of a Bootstrap carousel ?
Bootstrap carousel components include a container ("carousel" class), slides ("carousel-item" class), navigation indicators, and controls. Indicators help users track the current slide, while controls enable easy navigation. Optional captions ("carousel-caption" class) provide additional context. This modular setup allows for the simple creation of
2 min read
React-Bootstrap Carousel Individual Item Intervals
React-Bootstrap Carousel Individual Item Intervals is an attribute of the React Bootstrap component used to set a duration for individual images present in the corousel. By using this, we can set a different duration for all images present in the carousel component. Props Interval: It is used to specify duration for each Carousel Component. Time sh
2 min read
How to disable auto height for sliders by using React Bootstrap carousel?
In ReactJS applications, we use Carousel to represent the images in a loop and in an attractive way. In many cases, the images that are added are not of the same height, so the height is been adjusted automatically. As there is no inbuilt functionality to disable the auto height for sliders in React Bootstrap Carousel, we can use different approach
4 min read
Bootstrap 5 Carousel Methods
Bootstrap 5 Carousel Methods are used with JavaScript to implement different settings and variations to the carousel. Bootstrap 5 Carousel Methods: cycle: Using this method, a carousel will rotate through the slides from left to right.pause: Using this method, a carousel will stop rotating through the slides.prev: Using this method, a carousel will
4 min read
React-Bootstrap Carousel Component
React-Bootstrap is a front-end framework that was designed keeping react in mind. Carousel Component provides a way to create a slideshow for our images or text slides with a present full manner in a cyclic way. We can use the following approach in ReactJS to use the react-bootstrap Carousel Component. Carousel Props: activeIndex: It is used to con
3 min read
Bootstrap 5 Carousel Options
Bootstrap 5 Carousel options which can be used to customize the carousel and use it more efficiently. These options can be passed to the carousel through data attributes or using JavaScript. To add the options using data attributes we just need to add the name of the option data-bs-* by replacing the star in it. Bootstrap 5 Carousel Options Attribu
4 min read
Bootstrap 5 Carousel Slides only
Bootstrap 5 Carousel Slides only is a type of carousel where there is nothing in the slides of the carousel like the previous, next buttons, captions, and indicators. This carousel is the easiest one to implement as it has the least amount of components but this has the least user accessibility. Bootstrap 5 Carousel Slides only classes: carousel: T
3 min read
How to fix sliding Carousel in Bootstrap 5 ?
In Bootstrap 5, a Sliding Carousel is a dynamic component that displays a series of images or content sequentially. It enables a visually appealing, automatic, or user-triggered transition between slides. Users can navigate through the slides using controls, creating an interactive and engaging content display. Table of Content Using Bootstrap and
3 min read
Bootstrap 5 Carousel Crossfade
Bootstrap 5 Carousel Crossfade is used to create a carousel animate slide show effect in Crossfade style. To make this effect, the .carousel-fade class is used. Carousel Crossfade used Class: .carousel-fade: This class is used to add the fade effect in the carousel slide animation.Syntax: <div id="GFG" class="carousel slide carousel-fade" data-b
2 min read
three90RightbarBannerImg