Vue Bootstrap Hover Effects
Vue Hover Effects - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
Bootstrap hover effect appears when user positions computer cursor over an element without activating it. Hover effects make a website more interactive.
However, we don't recommend to mix hover effects with functional elements (like dropdown on hover or hidden buttons visible only after hovering) because such approach isn't mobile-friendly.
MDB is a mobile-first framework, so we attach great importance to make each component easy to use for touch screens.
That's why our hover effects are gentle and decorative.
Basic examples
Here is the most common example of hover effects usage.
Shadow effect
Light blue overlay
<template>
<mdb-view hover src="https://mdbootstrap.com/img/Photos/Horizontal/People/6-col/img%20(7).webp" alt="">
<mdb-mask flex-center overlay="blue-light" text="Light overlay" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Strong red overlay
<template>
<mdb-view hover src="https://mdbootstrap.com/img/Photos/Horizontal/People/6-col/img%20(7).webp" alt="">
<mdb-mask flex-center overlay="red-strong" text="Strong overlay" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Super light green overlay
<template>
<mdb-view hover src="https://mdbootstrap.com/img/Photos/Horizontal/People/6-col/img%20(7).webp" alt="">
<mdb-mask flex-center overlay="green-slight" text="Super light overlay" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Zoom effect
<template>
<mdb-view class="zoom" src="https://mdbootstrap.com/img/Photos/Horizontal/People/6-col/img%20(7).webp" alt="">
<mdb-mask flex-center text="Zoom effect" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Shadow effect
<template>
<img src="[...]" class="hoverable">
</template>
Usage
Step 1: Create a wrapper containing component mdb-view
.
<template>
<mdb-view>
[...]
</mdb-view>
</template>
<script>
import { mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView
}
}
</script>
Step 2: Add a class of the effect you want to use (for example .overlay
or .zoom
).
<template>
<mdb-view class="overlay">
[...]
</mdb-view>
</template>
<script>
import { mdbView } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView
}
}
</script>
Step 3: Set a path to the image by adding src
prop.
<template>
<mdb-view class="overlay" src="https://mdbootstrap.com/img/Photos/Horizontal/City/6-col/img%20(3).webp" alt="">
[...]
</mdb-view>
</template>
<script>
import { mdbView } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView
}
}
</script>
Step 4: Add a component mask
to cover the image with the overlay and choose color and intensity of the overlay.
<template>
<mdb-view class="overlay" src="https://mdbootstrap.com/img/Photos/Horizontal/City/6-col/img%20(3).webp" alt="">
<mdb-mask overlay="red-strong" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Step 5: If you want to add some text, you can use a prop flex-center
to center it, and text
to give your text a stronger contrast and make it more visible.
<template>
<mdb-view class="overlay" src="https://mdbootstrap.com/img/Photos/Horizontal/City/6-col/img%20(3).webp" alt="">
<mdb-mask overlay="red-strong" flex-center text="Strong overlay" />
</mdb-view>
</template>
<script>
import { mdbView, mdbMask } from "mdbvue";
export default {
name: "HoverEffect",
components: {
mdbView,
mdbMask
}
}
</script>
Zoom effect.
To use a zoom effect, follow the instruction above, but instead of
.overlay
add a class.zoom
.
Shadow effect.
To use a shadow effect, you only need to add a
.hoverable
class to chosen element.
Colors and intensity
Use one of the view
's overlay
prop to change the color and
intensity.
Strong overlay
blue-strong
red-strong
pink-strong
purple-strong
indigo-strong
cyan-strong
teal-strong
green-strong
lime-strong
yellow-strong
orange-strong
brown-strong
grey-strong
blue-grey-strong
black-strong
stylish-strong
white-strong
Light overlay
blue-light
red-light
pink-light
purple-light
indigo-light
cyan-light
teal-light
green-light
lime-light
yellow-light
orange-light
brown-light
grey-light
blue-grey-light
black-light
stylish-light
white-light
Super light overlay
blue-slight
red-slight
pink-slight
purple-slight
indigo-slight
cyan-slight
teal-slight
green-slight
lime-slight
yellow-slight
orange-slight
brown-slight
grey-slight
blue-grey-slight
black-slight
stylish-slight
white-slight