I have read different answers of similar questions, but they are all old and don't seem to work in the latest version of MUI.
I need to apply the touch ripple effect on a div, but I can't use a button or a ButtonBase element because there is another button inside it.
Thanks in advance for the reply.
Yes, you can use
TouchRippleto emulate the ripple effect. This component is undocumented, but you can see how it's used in theButtonBaseand learn to use it yourself.First, you need to pass a ref to
TouchRippleand callref.current.start(e)orref.current.stop(e)when you want to start or stop the effect respectively.eis the event object. When you callstart(e), it needs the mouse or touch position (frommousedownortouchstartevent) to know where to start the ripple effect (Source). You can override this behavior by settingcenterprops totrue, which makes the ripple effect always start at the middle.Below is the minimum working example to get you started:
Live Demo