React + MotionButtons

Ripple button

Each click sends a soft wave out from the exact spot you pressed, like a drop hitting water.

Settings

24px
1

Code

import { useState } from "react";
import { motion } from "framer-motion";

interface Ripple {
  id: number;
  x: number;
  y: number;
}

interface RippleButtonProps {
  color?: string;
  radius?: number;
  text?: string;
  intensity?: number;
}

export default function RippleButton({
  color = "#0071e3",
  radius = 24,
  text = "Click me",
  intensity = 1,
}: RippleButtonProps) {
  const [ripples, setRipples] = useState<Ripple[]>([]);

  return (
    <button
      type="button"
      className="relative overflow-hidden px-6 py-3 text-sm font-semibold text-white shadow-lg"
      style={{ backgroundColor: color, borderRadius: radius }}
      onClick={(e) => {
        const r = e.currentTarget.getBoundingClientRect();
        const id = Date.now();
        setRipples((p) => [...p, { id, x: e.clientX - r.left, y: e.clientY - r.top }]);
        setTimeout(() => setRipples((p) => p.filter((rp) => rp.id !== id)), 700);
      }}
    >
      <span className="relative z-10">{text}</span>
      {ripples.map((r) => (
        <motion.span
          key={r.id}
          className="absolute rounded-full bg-white/40"
          style={{ left: r.x, top: r.y, width: 10, height: 10, x: "-50%", y: "-50%" }}
          initial={{ scale: 0, opacity: 0.8 }}
          animate={{ scale: 20 * intensity, opacity: 0 }}
          transition={{ duration: 0.7, ease: "easeOut" }}
        />
      ))}
    </button>
  );
}

Prompt for AI

Paste it into ChatGPT, Claude or Cursor and it will adapt the block to your project with these settings, even if you don’t use React.

More in Buttons

Where to use it

The ripple is small feedback that tells people “yes, that worked”. It feels at home in dashboards, admin panels and forms where users click a lot: “Save”, “Add to list”, “Send”. Anyone who has used an Android phone will recognize this ripple effect button straight away, which makes it feel familiar from the first click.

Keep the button color fairly strong so the white wave shows. Lower the intensity on small buttons, or the wave covers everything at once. For a quiet, minimal site, a simple press effect may suit you better.