Ripple effect

A ripple effect is a ring or wave that spreads out from the point you tap, confirming the press exactly where it happened.

A ripple is a circle that grows out from the point of contact and fades, like a drop landing on water. Material Design made it the standard press feedback on Android, and the same idea works for waves that run along a row of items or through a surface.

Build it with transform and opacity only: on pointerdown, place a circle at the pointer position inside the button (which needs overflow: hidden and position: relative), size it to cover the farthest corner, then scale it from 0 to 1 while it fades out, and remove it when the animation ends.

Keep it fast, around 400 to 600 ms, so it never delays the action, and let keyboard presses start the ripple from the centre so they get the same feedback.

button.addEventListener('pointerdown', (e) => {
  const r = button.getBoundingClientRect();
  const size = Math.hypot(r.width, r.height) * 2;
  const dot = Object.assign(document.createElement('span'), { className: 'ripple' });
  dot.style.cssText = `width:${size}px;height:${size}px;left:${e.clientX - r.left - size / 2}px;top:${e.clientY - r.top - size / 2}px`;
  button.append(dot);
  dot.animate([{ transform: 'scale(0)', opacity: 0.35 }, { transform: 'scale(1)', opacity: 0 }], 500).onfinish = () => dot.remove();
});

See it live

Related terms