Boostrap 5 Lightbox Gallery Examples

In the realm of web development, Bootstrap has long been a go-to library for creating responsive and mobile-first websites. With the release of Bootstrap 5, the popular framework has introduced a plethora of new features and improvements, including a revamped lightbox gallery component. Let's delve into the world of Bootstrap 5 lightbox gallery examples, exploring its functionalities and showcasing practical implementations.

Lightgallery.js: Full-featured JS plugin for lightbox galleries - Freebiesbug
Lightgallery.js: Full-featured JS plugin for lightbox galleries - Freebiesbug

Bootstrap 5's lightbox gallery, powered by the popular Modal plugin, offers a seamless and intuitive user experience. It allows users to view images, videos, and other content in a lightbox overlay, providing an immersive and distraction-free environment. In this article, we will explore the basics of the Bootstrap 5 lightbox gallery, its customization options, and provide you with several examples to inspire your next project.

Bootstrap 4 Lightbox Gallery
Bootstrap 4 Lightbox Gallery

Getting Started with Bootstrap 5 Lightbox Gallery

Before we dive into the examples, let's ensure you have the necessary setup to use the Bootstrap 5 lightbox gallery. First, include the Bootstrap CSS and JavaScript files in your project. You can either download them or use a CDN:

Gallery lightbox view example
Gallery lightbox view example

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>

Basic Lightbox Gallery Example

12+ Awesome React Photo Gallery Components - OnAirCode
12+ Awesome React Photo Gallery Components - OnAirCode

To create a simple lightbox gallery, wrap your images within a Bootstrap carousel. Then, add data-bs-toggle="modal" and data-bs-target="#lightbox" attributes to each image. This will trigger the lightbox when an image is clicked:

<div class="carousel-item"> <img src="image1.jpg" alt="Image 1" class="d-block w-100" data-bs-toggle="modal" data-bs-target="#lightbox"> </div>

Customizing the Lightbox Gallery

a light bulb is surrounded by multiple frames
a light bulb is surrounded by multiple frames

Bootstrap 5 allows you to customize the lightbox gallery by modifying the Modal component. You can change the size, background color, and more. Here's an example of a full-screen lightbox with a dark background:

<div class="modal fade" id="lightbox" tabindex="-1" aria-labelledby="lightboxLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered modal-fullscreen"> <div class="modal-content bg-dark"> <div class="modal-header"> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body p-0"> <img src="" alt="" id="lightbox-image"> </div> </div> </div> </div>

Advanced Lightbox Gallery Examples

CSS Grid Image Gallery With Lightbox | Tiled Layout Image Gallery
CSS Grid Image Gallery With Lightbox | Tiled Layout Image Gallery

Now that we've covered the basics, let's explore some advanced examples to inspire your projects.

Lightbox Gallery with Thumbnails

an open photo frame sitting on top of a wooden table next to chairs and a potted plant
an open photo frame sitting on top of a wooden table next to chairs and a potted plant
three pictures are hanging on the wall next to each other
three pictures are hanging on the wall next to each other
25 Bootstrap Themes for Web Designers & Creative Professionals - Designbeep
25 Bootstrap Themes for Web Designers & Creative Professionals - Designbeep
a wall that has pictures on it and some lights in the dark behind it,
a wall that has pictures on it and some lights in the dark behind it,
JB Blog - Paul Sova
JB Blog - Paul Sova
"Illuminating Emotions: A Journey Through Light and Shadow"
"Illuminating Emotions: A Journey Through Light and Shadow"
3D Shadow Box - Decorative Led Lightbox
3D Shadow Box - Decorative Led Lightbox
architecture light box model
architecture light box model
there are many frames on the wall with different things in them that are hanging up
there are many frames on the wall with different things in them that are hanging up
some lights are hanging on the wall in front of a white wall and two brown lamps
some lights are hanging on the wall in front of a white wall and two brown lamps
Most Popular Gallery Section
Most Popular Gallery Section
lightbox for slides
lightbox for slides
52 Best Photo Gallery Website Templates 2026 - Colorlib
52 Best Photo Gallery Website Templates 2026 - Colorlib
Dark Wall Lightboxes Mockup by Design Squad | Creative Market
Dark Wall Lightboxes Mockup by Design Squad | Creative Market
Bootstrap 5.3 Development Kit | Layouts and code to help you develop custom websites powered by Bootstrap
Bootstrap 5.3 Development Kit | Layouts and code to help you develop custom websites powered by Bootstrap
there are many frames on the wall with pictures hanging above them and a lamp next to it
there are many frames on the wall with pictures hanging above them and a lamp next to it
Lighting box and sign box
Lighting box and sign box
Automated Slider In Elementor Pre
Automated Slider In Elementor Pre
an image of a table with candles on it in the middle of a room filled with people
an image of a table with candles on it in the middle of a room filled with people
Using Your Camera's Pointless Features To Get The Most Out Of Your Shots | Fstoppers
Using Your Camera's Pointless Features To Get The Most Out Of Your Shots | Fstoppers

For larger galleries, consider adding thumbnails to help users navigate through the images. You can achieve this by combining the lightbox with Bootstrap's carousel component:

<div id="lightbox-thumbnails" class="carousel slide" data-bs-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img src="thumbnail1.jpg" alt="Thumbnail 1" data-bs-toggle="modal" data-bs-target="#lightbox"> </div> <div class="carousel-item"> <img src="thumbnail2.jpg" alt="Thumbnail 2" data-bs-toggle="modal" data-bs-target="#lightbox"> </div> </div> <button class="carousel-control-prev" type="button" data-bs-target="#lightbox-thumbnails" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="visually-hidden">Previous</span> </button> <button class="carousel-control-next" type="button" data-bs-target="#lightbox-thumbnails" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="visually-hidden">Next</span> </button> </div>

Lightbox Gallery with Videos

Bootstrap 5's lightbox gallery isn't limited to images; you can also display videos. To do this, wrap your video element within a Bootstrap Modal:

<div class="modal fade" id="lightbox" tabindex="-1" aria-labelledby="lightboxLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-body"> <video controls> <source src="video.mp4" type="video/mp4"> </video> </div> </div> </div> </div>

As you've seen, Bootstrap 5's lightbox gallery offers a wealth of customization options and can be integrated into various project types. Whether you're creating a simple image gallery or a complex multimedia experience, the lightbox gallery component has you covered. Now, go ahead and incorporate these examples into your projects, and don't forget to experiment with the countless possibilities that Bootstrap 5 offers. Happy coding!