How do I programatically show "ripple effect" with MUI?

All we need is an easy explanation of the problem, so here it is.

Basically the title. I want to manually show the ripple effect on my collection of MUI’s Buttons – the ripple effect works when I click the button, but I can’t find a way to show the ripple effect programmatically.

Do I need to disable the MUI’s ripple effect and then make my own ripple effect function, that I can attach to onClick?

{ => (
    <React.Fragment key={}>
        {button.render ? (
                <div className="col-3">
                        className="w-100 p-3"
                        classes={{root: classes.button}}
                        onClick={() => {updateState(button.onClick(text))}}
        ) : (<></>)}

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Button uses ButtonBase which uses TouchRipple under the hood. Here is a snippet of ButtonBase definition:

function ButtonBase(props) {
  // ...

  return (
      <TouchRipple ref={rippleRef} center={centerRipple} {...TouchRippleProps} />

There is no API to trigger the ripple manually. It’s handled internally inside the button, so in order to do that, you need to create and control your own ripple component provided by MUI:

import TouchRipple from '@mui/material/ButtonBase/TouchRipple';
const rippleRef = React.useRef(null);
const buttonRef = React.useRef(null);
const triggerRipple = () => {
  const container = buttonRef.current;
  const rect = container.getBoundingClientRect();

      clientX: rect.left + rect.width / 2,
      clientY: + rect.height / 2,
    // when center is true, the ripple doesn't travel to the border of the container
    { center: false },

  setTimeout(() => rippleRef.current.stop({}), 320);

return (
    <Button onClick={triggerRipple}>start ripple</Button>
    <Box display="flex" justifyContent="center" m={10}>
        sx={{ display: 'relative' }}
        My little ripple
        <TouchRipple ref={rippleRef} center />

Live Demo

How do I programatically show "ripple effect" with MUI?

Related answers

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply