Is there a way I can add ripple effect to MUI Card
component on click.
And I would also like to know, is it possible to make ripple effect to come on top of the content of Card component, rather that it showing as background.
Ripple. MDC Ripple provides the JavaScript and CSS required to provide components (or any element at all) with a material "ink ripple" interaction effect. It is designed to be efficient, uninvasive, and usable without adding any extra DOM to your elements.
A ripple effect occurs when an initial disturbance to a system propagates outward to disturb an increasingly larger portion of the system, like ripples expanding across the water when an object is dropped into it.
Ripple touch effect was introduced with material design in Android 5.0 (API level 21). Touch feedback in material design provides an instantaneous visual confirmation at the point of contact when users interact fwith UI elements.
According to Material-UI documentation, you can disable the ripple effect globally by providing the following in your theme: import React from "react"; import Button from "@material-ui/core/Button"; import { createMuiTheme, MuiThemeProvider } from "@material-ui/core"; export default function ContainedButtons() { const ...
I noticed that TouchRipple has been moved out of the internal
directory. It's now available in the ButtonBase folder.
Here is how I was able to add ripple effect by using the ButtonBase component -
Basically, you wrap your component, let's say <Card>
inside the <ButtonBase>
like so, and the ButtonBase
takes care of the TouchRipple
setting up for you -
<ButtonBase> <Card> .... </Card> </ButtonBase>
Here is a Codesandbox link to working demo. I know this is not the best way. You could directly use the TouchRipple
/Ripple
component, but I found this way to be very easy to use.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With