# Ripple button

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

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/ripple-button
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## 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.

## Code

### React (Motion)

```tsx
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 assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Ripple button” block (Buttons) from AIMRAN Library to my project.

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

## Chosen settings
- Color: #0071e3
- Corner radius: 24px (from 0 to 24px)
- Text: "Click me"
- Intensity: 1 (from 0.2 to 2)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with React + TypeScript, with framer-motion for the animation and lucide-react for the icons. If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
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>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
