Skip to content

Carousel with Captions

Bootstrap 5 hero carousel with glass captions, pill indicators, previous and next buttons, a pause control and gradient SVG slides.

Also known as: image slider with captions, hero slider, fullscreen carousel, slideshow with indicators

Carousel with Captions live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A Bootstrap 5 hero carousel with glass-style captions, pill indicators, round previous and next buttons and a pause/play control. The slides use CSS gradients and inline SVG landscapes instead of photos, so it loads instantly and works as a travel, product or campaign slider on landing pages.

How it works

The root section.ccx wraps a .carousel.slide.carousel-fade.ccx-carousel. Each carousel-item contains a .ccx-slide whose height comes from aspect-ratio: var(--ccx-ratio), a modifier class (.ccx-slide--sea, .ccx-slide--peak or .ccx-slide--dune) for its gradient, and an svg.ccx-art with simple shapes that scales with preserveAspectRatio="xMaxYMid slice". The .ccx-caption overrides Bootstrap's centered caption: it sits in the bottom-left corner, is left aligned and uses a translucent, blurred panel with a kicker, heading, short text and a .ccx-btn call to action. The .ccx-indicators become pills in the top-left corner, while the .ccx-control buttons and the .ccx-toggle pause button line up in the top-right corner so they never cover the caption.

Slide changes, indicators and swipe support come from Bootstrap's carousel plugin via data-bs-ride="carousel" and data-bs-interval="8000". The script runs on DOMContentLoaded, creates a bootstrap.Carousel instance for every .ccx-carousel and starts it paused when the visitor prefers reduced motion. Clicking .ccx-toggle recreates the instance with ride on or off, swaps the bi-pause-fill and bi-play-fill icons, updates the button label and sets aria-live to polite while paused.

Customization

  • --ccx-sea, --ccx-peak and --ccx-dune on .ccx in style.css: change the gradient behind each slide.
  • --ccx-ratio: controls the slide shape; it is 4 / 5 on phones, 4 / 3 from 576px and 16 / 7 from 992px.
  • --ccx-accent: recolors the kicker text and the .ccx-btn button.
  • --ccx-glass: makes the caption panel darker, lighter or tinted.
  • data-bs-interval="8000" on .ccx-carousel: sets the time per slide in milliseconds; the script reads the same value.
  • Replace an svg.ccx-art with an img from https://placehold.co/1200x600 or your own photo using object-fit: cover to show real images.
  • Remove carousel-fade from .ccx-carousel to slide horizontally instead of cross-fading.

Use cases

  • Travel sites: glass-style captions over landscape slides present destinations and offers
  • Product pages: pill indicators and round arrow buttons let visitors browse featured items
  • Campaign landing pages: a pause and play control lets visitors stop the slideshow when needed
  • Fast-loading pages: slides built from gradients and inline SVG load instantly without photos

Accessibility

The carousel has aria-roledescription="carousel" and a label, and each item is a role="group" with aria-roledescription="slide" and a position such as "1 of 3". Indicator buttons have descriptive labels and aria-current on the active slide. The previous and next buttons include visually hidden text, and the pause button meets WCAG 2.2.2 by letting users stop the auto-rotation. Autoplay is off under prefers-reduced-motion: reduce, and all buttons show a white focus outline on :focus-visible.

Usage notes

Requires Bootstrap 5 with its JS bundle (added automatically) and Bootstrap Icons. When adding a second carousel, give it a new id and update every data-bs-target.

Carousel with Captions at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Carousels
License
Free for personal and commercial use

Questions about this template

Can I use the Carousel with Captions code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Carousel with Captions – free Bootstrap 5 carousel template
Carousel with Captions · free Bootstrap 5 carousel template

More Carousels

3D Coverflow Image Carousel – free Pure CSS carousel template

3D Coverflow Image Carousel

Coverflow-style image carousel with rotated 3D side photos, reflections, captions, dots, swipe and keyboard navigation in pure CSS and vanilla JS.

Scroll-Snap Carousel – free Pure CSS carousel template

Scroll-Snap Carousel

Native CSS scroll-snap carousel with arrow buttons, synced pill dots and keyboard support, enhanced by a few lines of vanilla JavaScript.

Infinite Auto-Scrolling Image Strip – free Pure CSS carousel template

Infinite Auto-Scrolling Image Strip

Seamless pure CSS marquee of landscape photos that loops forever, pauses on hover or focus and has a Pause/Play button.

Image Carousel with Thumbnails – free Tailwind CSS carousel template

Image Carousel with Thumbnails

Tailwind CSS image carousel with a clickable thumbnail strip, captions, swipe support, arrow-key navigation and optional looping.

Card Carousel with Peek of Next Slide – free Tailwind CSS carousel template

Card Carousel with Peek of Next Slide

Swipeable Tailwind CSS photo card carousel with scroll snap, a peeking next card, arrow buttons, dots and keyboard support.