eCommerce gallery MDB Pro component

eCommerce gallery - Bootstrap 5 & Material Design 2.0 plugin

MDB gallery / lightbox component designed for eCommerce projects.

Note: Read the API tab to find all available options and advanced customization


Basic example

A basic example of a gallery with the most common use case with the bootstrap grid and activation on hover.

To ensure the proper performance of the page, it is recommended to include thumbnails of images in the src attribute. Then in the data-img attribute add the path to the image with higher resolution. If the data-img attribute is omitted, the lightbox will display the same image as in the reduced size.


          <div class="ecommerce-gallery">
            <div class="row">
              <div class="col-12 mb-1">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                  alt="Gallery image 1"
                  class="active w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                  alt="Gallery image 2"
                  class="w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                  alt="Gallery image 3"
                  class="w-100"
                />
              </div>
            </div>
          </div>
        

Activate on mouseenter

Activation on mouseenter can be enabled by adding a data-activation attribute with mouseenter value.


          <div class="ecommerce-gallery" data-activation="mouseenter">
            <div class="row">
              <div class="col-12 mb-1">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                  alt="Gallery image 1"
                  class="active w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                  alt="Gallery image 2"
                  class="w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                  alt="Gallery image 3"
                  class="w-100"
                />
              </div>
            </div>
          </div>
        

Zoom effect

Set data-zoom-effect to true to enable enlarging the main image on hover.


          <div class="ecommerce-gallery" data-zoom-effect="true">
            <div class="row">
              <div class="col-12 mb-1">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                  alt="Gallery image 1"
                  class="active w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                  alt="Gallery image 2"
                  class="w-100"
                />
              </div>
              <div class="col-4 my-1">
                <img
                  src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                  data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                  alt="Gallery image 3"
                  class="w-100"
                />
              </div>
            </div>
          </div>
        



Different positions

Thumnails at the top

Easily add a carousel before the main image to view thumbnails above it.


          <div class="ecommerce-gallery">
            <div class="multi-carousel" data-breakpoint="false" data-items="3">
              <div class="multi-carousel-inner">
                <div class="multi-carousel-item active">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="active w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                    alt="Gallery image 2"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                    alt="Gallery image 3"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                    alt="Gallery image 4"
                    class="w-100"
                  />
                </div>
              </div>
              <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
              </a>
              <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
              </a>
            </div>
            <div class="lightbox mt-1">
              <img
                src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                alt="Gallery image 1"
                class="ecommerce-gallery-main-img active w-100"
              />
            </div>
          </div>
        

Thumnails on the right

Add the carousel in the second column to display thumbnails on the right.


          <div class="ecommerce-gallery vertical">
            <div class="row">
              <div class="col-8 col-sm-9">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
              <div class="col-4 col-sm-3">
                <div class="multi-carousel vertical" data-items="3">
                  <div class="multi-carousel-inner">
                    <div class="multi-carousel-item active">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                        alt="Gallery image 1"
                        class="active w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                        alt="Gallery image 2"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                        alt="Gallery image 3"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                        alt="Gallery image 4"
                        class="w-100"
                      />
                    </div>
                  </div>
                  <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  </a>
                  <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  </a>
                </div>
              </div>
            </div>
          </div>
        

Different thumbnails number

2 thumbnails

Set data-items="2" to make two thumbnails visible.


          <div class="ecommerce-gallery">
            <div class="multi-carousel" data-breakpoint="false" data-items="2">
              <div class="multi-carousel-inner">
                <div class="multi-carousel-item active">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="active w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                    alt="Gallery image 2"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                    alt="Gallery image 3"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                    alt="Gallery image 4"
                    class="w-100"
                  />
                </div>
              </div>
              <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
              </a>
              <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
              </a>
            </div>
            <div class="lightbox mt-1">
              <img
                src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                alt="Gallery image 1"
                class="ecommerce-gallery-main-img active w-100"
              />
            </div>
          </div>
        

4 thumbnails

Set data-items="4" to make four thumbnails visible.


          <div class="ecommerce-gallery vertical">
            <div class="row">
              <div class="col-8 col-sm-9">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
              <div class="col-4 col-sm-3">
                <div class="multi-carousel vertical" data-items="4">
                  <div class="multi-carousel-inner">
                    <div class="multi-carousel-item active">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                        alt="Gallery image 1"
                        class="active w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/2.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/2.jpg"
                        alt="Gallery image 2"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/3.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/3.jpg"
                        alt="Gallery image 3"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                        alt="Gallery image 4"
                        class="w-100"
                      />
                    </div>
                  </div>
                  <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  </a>
                  <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  </a>
                </div>
              </div>
            </div>
          </div>
        

Different image sizes

Horizontal carousel

Image sizes are automatically adjusted to the view.


          <div class="ecommerce-gallery">
            <div class="lightbox mb-1">
              <img
                src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                alt="Gallery image 1"
                class="ecommerce-gallery-main-img active w-100"
              />
            </div>
            <div class="multi-carousel" data-breakpoint="false" data-items="3">
              <div class="multi-carousel-inner">
                <div class="multi-carousel-item active">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="active w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Square/1.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Square/1.jpg"
                    alt="Gallery image 2"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                    alt="Gallery image 3"
                    class="w-100"
                  />
                </div>
                <div class="multi-carousel-item">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Thumbnails/Vertical/1.jpg"
                    data-img="https://mdbootstrap.com/img/Photos/Vertical/1.jpg"
                    alt="Gallery image 4"
                    class="w-100"
                  />
                </div>
              </div>
              <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
              </a>
              <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
              </a>
            </div>
          </div>
        

Vertical carousel

In a vertical carousel, it works too.


          <div class="ecommerce-gallery vertical">
            <div class="row">
              <div class="col-4 col-sm-3">
                <div class="multi-carousel vertical" data-items="3">
                  <div class="multi-carousel-inner">
                    <div class="multi-carousel-item active">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/1.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                        alt="Gallery image 1"
                        class="active w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Square/1.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Square/1.jpg"
                        alt="Gallery image 2"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Slides/4.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Slides/4.jpg"
                        alt="Gallery image 3"
                        class="w-100"
                      />
                    </div>
                    <div class="multi-carousel-item">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Thumbnails/Vertical/1.jpg"
                        data-img="https://mdbootstrap.com/img/Photos/Vertical/1.jpg"
                        alt="Gallery image 4"
                        class="w-100"
                      />
                    </div>
                  </div>
                  <a class="carousel-control-prev" tabindex="0" role="button" data-slide="prev">
                    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                  </a>
                  <a class="carousel-control-next" tabindex="0" role="button" data-slide="next">
                    <span class="carousel-control-next-icon" aria-hidden="true"></span>
                  </a>
                </div>
              </div>
              <div class="col-8 col-sm-9">
                <div class="lightbox">
                  <img
                    src="https://mdbootstrap.com/img/Photos/Slides/1.jpg"
                    alt="Gallery image 1"
                    class="ecommerce-gallery-main-img active w-100"
                  />
                </div>
              </div>
            </div>
          </div>
        

Equal image sizes

A basic example of a gallery with images of equal sizes.


          <div class="ecommerce-gallery" data-zoom-effect="true">
            <div class="row">
              <div class="col-6">
                <div class="row py-3 shadow-5">
                  <div class="col-12 mb-1">
                    <div class="lightbox">
                      <img
                        src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/14a.jpg"
                        alt="Gallery image 1"
                        class="ecommerce-gallery-main-img active w-100"
                      />
                    </div>
                  </div>
                  <div class="col-3 mt-1">
                    <img
                      src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/14a.jpg"
                      data-img="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/14a.jpg"
                      alt="Gallery image 1"
                      class="active w-100"
                    />
                  </div>
                  <div class="col-3 mt-1">
                    <img
                      src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/12a.jpg"
                      data-img="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/12a.jpg"
                      alt="Gallery image 2"
                      class="w-100"
                    />
                  </div>
                  <div class="col-3 mt-1">
                    <img
                      src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/13a.jpg"
                      data-img="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/13a.jpg"
                      alt="Gallery image 3"
                      class="w-100"
                    />
                  </div>
                  <div class="col-3 mt-1">
                    <img
                      src="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/15a.jpg"
                      data-img="https://mdbootstrap.com/img/Photos/Horizontal/E-commerce/Vertical/15a.jpg"
                      alt="Gallery image 4"
                      class="w-100"
                    />
                  </div>
                </div>
              </div>
            </div>
          </div>
        

          .ecommerce-gallery .lightbox img { height: auto; }
        

eCommerce gallery - API


Usage

Via data attributes


        <div class="ecommerce-gallery" data-activation="mouseenter">
          <!-- content -->
        </div>
      

Via JavaScript


        const gallery = document.getElementById('gallery');
        const instance = EcommerceGallery.getInstance(gallery);
        instance.dispose();
      

Via jQuery

Note: By default, MDB does not include jQuery and you have to add it to the project on your own.

 $('#gallery').ecommerceGallery('dispose'); 

Options

Name Type Default Description
activation String 'click' Defines image toggle mouse event.
zoomEffect Boolean false Hovering over the image enlarges it in the given place.

Methods

Name Parameters Description Example
init Initializes EcommerceGallery. instance.init()
dispose Removes the EcommerceGallery instance. instance.dispose()
getInstance element Static method which allows to get the gallery instance associated with a DOM element. EcommerceGallery.getInstance(element)

        const gallery = document.getElementById('gallery');
        const instance = EcommerceGallery.getInstance(gallery);
        instance.dispose();
      

Import

MDB UI KIT also works with module bundlers. Use the following code to import this component:


        import { EcommerceGallery } from 'mdb-ecommerce-gallery';