StealThis .dev

Ripple Button

A Material Design inspired button that shows a ripple wave effect expanding from the exact click point.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

Ripple Button

A button that creates an expanding circular ripple wave from the exact point where the user clicks, inspired by Material Design’s touch feedback.

How it works

  1. On click, JavaScript calculates the cursor position relative to the button
  2. A <span> element is injected at that position with a CSS animation
  3. The @keyframes ripple animation scales the circle outward while fading opacity
  4. After the animation completes, the span is removed from the DOM

Customization

  • Color: Change the ripple span’s background for different ripple colors
  • Duration: Adjust animation-duration for faster or slower ripples
  • Size: The ripple auto-sizes to the button dimensions using Math.max(width, height)

When to use it

  • Any clickable button or interactive element
  • Form submit buttons
  • Navigation actions where tactile feedback improves UX