Hover effects

Vue Bootstrap 5 Hover effects

MDB hover effect appears when the user positions the computer cursor over an element without activating it. Hover effects make a website more interactive.

However, we don't recommend that you mix hover effects with functional elements (like a drop-down on hover or hidden buttons visible only after hovering) because such an approach isn't mobile-friendly.

MDB is a mobile-first framework, so we attach great importance to making each component easy to use for touch screens.

That's why our hover effects are gentle and decorative.


Basic example

Here is the most common example of hover effects usage - an image changed to link.

Additionally, we added shadows and rounded corners.

        
            
            <template>
              <div class="bg-image hover-overlay shadow-1-strong rounded" v-mdb-ripple="{ color: 'light' }">
                <img src="https://mdbootstrap.com/img/new/fluid/city/113.webp" class="w-100" />
                <a href="javascript:void(0);">
                  <div class="mask" style="background-color: rgba(251, 251, 251, 0.2)"></div>
                </a>
              </div>
            </template>
          
        
    

Types

In MDB there are 3 types of the hover effects: overlay, zoom and shadow.

Overlay

Overlay is an effect that covers with color and defined level of opacity the entire image. The same as with mask you can change the color and opacity by manipulating RGBA code.

Our overlay hover effect relies on masks. Have a look at our masks docs to learn more.

Add .overlay class to the .mask element to apply hover effect. Then manipulate RGBA code to change the color of the overlay.

rgba(18, 102, 241, 0.5)
rgba(178, 60, 253, 0.2)
rgba(0, 183, 74, 0.78)
rgba(249, 49, 84, 0.34)
rgba(251, 251, 251, 0.35)
rgba(57, 192, 237, 0.3)

You can even set a fancy gradient as an overlay.

        
            
              <template>
                <div class="bg-image hover-overlay">
                  <img src="https://mdbootstrap.com/img/new/standard/city/053.webp" class="w-100" />
                  <div
                    class="mask"
                    style="
                      background: linear-gradient(
                        45deg,
                        rgba(29, 236, 197, 0.5),
                        rgba(91, 14, 214, 0.5) 100%
                      );
                    "
                  ></div>
                </div>
              </template>
            
        
    

Zoom

To apply zoom hover effect you have to use slightly different, but simpler syntax.

You only need to add .hover-zoom class to the .bg-image element.

        
            
            <template>
              <div class="bg-image hover-zoom">
                <img src="https://mdbootstrap.com/img/new/standard/city/053.webp" class="w-100" />
              </div>
            </template>
          
        
    

Shadow

Shadow hover effect is even simpler. Simply add .hover-shadowcode> class to any element to apply the effect.

        
            
              <template>
                <img
                  src="https://mdbootstrap.com/img/new/standard/city/041.webp"
                  class="w-100 hover-shadow"
                  alt=""
                />
              </template>
            
        
    

Mixing effects

You can freely mix all the effects with each other. However, be careful not to overdo it. MDB adheres to the principle of minimalism and subtlety.

        
            
            <template>
              <div class="bg-image hover-overlay hover-zoom hover-shadow" v-mdb-ripple>
                <img src="https://mdbootstrap.com/img/new/fluid/city/113.webp" class="w-100" />
                <a href="javascript:void(0);">
                  <div class="mask" style="background-color: rgba(57, 192, 237, 0.2)"></div>
                </a>
              </div>
            </template>
          
        
    

Overlay over mask

If you want to put a text on the image and you need a proper contrast, but still you wish to have hover effect, you can apply overlay on the already existing mask.

        
            
            <template>
              <div class="bg-image" v-mdb-ripple>
                <img src="https://mdbootstrap.com/img/new/standard/city/053.webp" class="w-100" />
                <a href="javascript:void(0);">
                  <div class="mask" style="background-color: rgba(0, 0, 0, 0.4)">
                    <div class="d-flex justify-content-center align-items-center h-100">
                      <p class="text-white mb-0">Can you see me?</p>
                    </div>
                  </div>
                  <div class="hover-overlay">
                    <div class="mask" style="background-color: rgba(251, 251, 251, 0.2)"></div>
                  </div>
                </a>
              </div>
            </template>
          
        
    

CSS variables

        
            
          // .hover-overlay
          --#{$prefix}image-hover-transition: #{$image-hover-overlay-transition};

          // .hover-zoom
          --#{$prefix}image-hover-zoom-transition: #{$image-hover-zoom-transition};
          --#{$prefix}image-hover-zoom-transform: #{$image-hover-zoom-transform};
        
          // .hover-shadow
          --#{$prefix}image-hover-shadow-transition: #{$image-hover-shadow-transition};
          --#{$prefix}image-hover-shadow-box-shadow: #{$image-hover-shadow-box-shadow};

          // .hover-shadow-soft
          --#{$prefix}image-hover-shadow-box-shadow-soft: #{$image-hover-shadow-box-shadow-soft};
        
        
    

SCSS variables

        
            
        $image-hover-overlay-transition: all 0.3s ease-in-out;

        $image-hover-zoom-transition: all 0.3s linear;
        $image-hover-zoom-transform: scale(1.1);
        
        $image-hover-shadow-transition: $image-hover-overlay-transition;
        $image-hover-shadow-box-shadow: $box-shadow-4-strong;
        $image-hover-shadow-box-shadow-soft: $box-shadow-5;