# Like button with particles

> The heart fills with color, gives a little bounce and throws out a small ring of particles.

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

## Where to use it

A like should feel good to press, otherwise nobody bothers. This heart fills, jumps slightly and scatters a few dots, like on the social apps people already know. Use it to save a recipe, favorite a listing or react to a post. Small as it is, an animated like button is often the most pressed thing on a page.

Eight particles is about right; more than that starts to look like confetti. Pick a color that belongs to your brand rather than the default red if hearts are not your thing. Tapping again removes the like, so it works as a real toggle.

## Code

### React (Motion)

```tsx
import { useState } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { Heart } from "lucide-react";

interface ParticleLikeButtonProps {
  color?: string;
  particles?: number;
}

export default function ParticleLikeButton({
  color = "#d25563",
  particles = 8,
}: ParticleLikeButtonProps) {
  const [liked, setLiked] = useState(false);

  return (
    <button
      type="button"
      aria-label="Like"
      aria-pressed={liked}
      onClick={() => setLiked((v) => !v)}
      className="relative grid h-14 w-14 place-items-center rounded-full bg-white dark:bg-[#1c1c1e] text-[#1d1d1f] dark:text-[#f5f5f7] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)]"
    >
      <motion.span
        animate={{ scale: liked ? [1, 1.35, 1] : 1 }}
        transition={{ type: "spring", stiffness: 300, damping: 30 }}
      >
        <Heart
          className="h-6 w-6"
          fill={liked ? color : "transparent"}
          stroke={liked ? color : "currentColor"}
        />
      </motion.span>
      <AnimatePresence>
        {liked &&
          Array.from({ length: particles }, (_, i) => (
            <motion.i
              key={i}
              className="absolute h-1 w-1 rounded-full"
              style={{ backgroundColor: color }}
              initial={{ x: 0, y: 0, opacity: 1 }}
              animate={{
                x: Math.cos((i / particles) * Math.PI * 2) * 30,
                y: Math.sin((i / particles) * Math.PI * 2) * 30,
                opacity: 0,
              }}
              exit={{ opacity: 0 }}
              transition={{ duration: 0.55 }}
            />
          ))}
      </AnimatePresence>
    </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 “Like button with particles” block (Buttons) from AIMRAN Library to my project.

## What it is
The heart fills with color, gives a little bounce and throws out a small ring of particles.

## Chosen settings
- Color: #d25563
- Particles: 8 (from 4 to 12)

## 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 { AnimatePresence, motion } from "framer-motion";
import { Heart } from "lucide-react";

interface ParticleLikeButtonProps {
  color?: string;
  particles?: number;
}

export default function ParticleLikeButton({
  color = "#d25563",
  particles = 8,
}: ParticleLikeButtonProps) {
  const [liked, setLiked] = useState(false);

  return (
    <button
      type="button"
      aria-label="Like"
      aria-pressed={liked}
      onClick={() => setLiked((v) => !v)}
      className="relative grid h-14 w-14 place-items-center rounded-full bg-white dark:bg-[#1c1c1e] text-[#1d1d1f] dark:text-[#f5f5f7] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)]"
    >
      <motion.span
        animate={{ scale: liked ? [1, 1.35, 1] : 1 }}
        transition={{ type: "spring", stiffness: 300, damping: 30 }}
      >
        <Heart
          className="h-6 w-6"
          fill={liked ? color : "transparent"}
          stroke={liked ? color : "currentColor"}
        />
      </motion.span>
      <AnimatePresence>
        {liked &&
          Array.from({ length: particles }, (_, i) => (
            <motion.i
              key={i}
              className="absolute h-1 w-1 rounded-full"
              style={{ backgroundColor: color }}
              initial={{ x: 0, y: 0, opacity: 1 }}
              animate={{
                x: Math.cos((i / particles) * Math.PI * 2) * 30,
                y: Math.sin((i / particles) * Math.PI * 2) * 30,
                opacity: 0,
              }}
              exit={{ opacity: 0 }}
              transition={{ duration: 0.55 }}
            />
          ))}
      </AnimatePresence>
    </button>
  );
}
```

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