React Hover Effects
React 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
React Bootstrap hover effect appears when a 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
Shadow effect
import React from "react";
import { MDBMask, MDBView, MDBContainer, MDBRow, MDBCol } from "mdbreact";
class HoverPage extends React.Component {
render() {
return (
<MDBContainer className="mt-5">
<MDBRow>
<MDBCol md="4">
<MDBView hover>
<img
src="https://mdbootstrap.com/img/Others/documentation/forest-sm-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask className="flex-center" overlay="red-strong">
<p className="white-text">Strong overlay</p>
</MDBMask>
</MDBView>
</MDBCol>
<MDBCol md="4">
<MDBView hover>
<img
src="https://mdbootstrap.com/img/Others/documentation/forest-sm-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask className="flex-center" overlay="red-light">
<p className="white-text">Light overlay</p>
</MDBMask>
</MDBView>
</MDBCol>
<MDBCol md="4">
<MDBView hover>
<img
src="https://mdbootstrap.com/img/Others/documentation/forest-sm-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask className="flex-center" overlay="red-slight">
<p className="white-text">Super light overlay</p>
</MDBMask>
</MDBView>
</MDBCol>
</MDBRow>
<MDBRow className="mt-4">
<MDBCol md="6">
<MDBView hover zoom>
<img
src="https://mdbootstrap.com/img/Others/documentation/img%20(131)-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask className="flex-center">
<p className="white-text">Zoom effect</p>
</MDBMask>
</MDBView>
</MDBCol>
<MDBCol md="6">
<h5 className="text-center">Shadow effect</h5>
<img
src="https://mdbootstrap.com/img/Others/documentation/4.webp"
className="img-fluid rounded-circle hoverable"
alt=""
/>
</MDBCol>
</MDBRow>
</MDBContainer>
);
}
}
export default HoverPage;
Usage
Step 1: Create a wrapper containing component <MDBView>
.
<MDBView>
...
</MDBView>
Step 2: Add a prop of the effect you want to use (for example hover
or zoom
).
<MDBView hover zoom>
...
</MDBView>
Step 3: Set a path to the image by adding src
attribute.
<MDBView hover zoom>
<img
src="https://mdbootstrap.com/img/Others/documentation/img%20(131)-mini.webp"
className="img-fluid"
alt=""
/>
</MDBView>
Step 4: Add a component <MDBMask>
to cover the image with the overlay and
choose color
and intensity of the overlay.
<MDBView hover zoom>
<img
src="https://mdbootstrap.com/img/Others/documentation/img%20(131)-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask overlay="red-slight">
</MDBMask>
</MDBView>
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.
<MDBView hover zoom>
<img
src="https://mdbootstrap.com/img/Others/documentation/img%20(131)-mini.webp"
className="img-fluid"
alt=""
/>
<MDBMask className="flex-center" overlay="red-slight">
<p className="white-text">Super light overlay</p>
</MDBMask>
</MDBView>
Colors and intensity
Use one of the <MDBMask>
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
React Hover Effects - API
In this section you will find advanced information about the Hover Effects in MDB.
Import statement
In order to use Hover Effects make sure you have imported proper modules first.
import { MDBView, MDBMask } from "mdbreact";
API Reference: View Properties
The table below shows the configuration options of the MDBView component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
cascade |
Boolean | false |
Places content cascade | <MDBView cascade /> |
className |
String |
|
Adds custom classes | <MDBView className="customClass" /> |
hover |
Boolean | false |
Switches on hover effects | <MDBView hover /> |
rounded |
Boolean | false |
Sets View's border-radius to 50% | <MDBView rounded /> |
src |
String |
|
Sets fixed image backround; accepts url to your image | <MDBView src="/assets/image.webp" /> |
tag |
String | div |
Changes default tag | <MDBView tag="span" /> |
waves |
Boolean | false |
Switches on waves effect (on mouse up) | <MDBView waves /> |
zoom |
Boolean | false |
Switch on zomm efect (on hover) | <MDBView zoom /> |
API Reference: Mask Properties
The table below shows the configuration options of the MDBMask component.
Name | Type | Default | Description | Example |
---|---|---|---|---|
className |
String |
|
Adds custom classes | <MDBMask className="customClass" /> |
overlay |
String |
|
Creates overlay in passed color; for colors list check Mask's docs | <MDBMask overlay="grey-light" /> |
pattern |
String/Number |
|
Creates pattern with chosen style; for patterns list check Mask's docs | <MDBMask pattern="1" /> |
tag |
String | div |
Changes default tag | <MDBMask tag="span" /> |