# Bouncing notification badge

> A counter that drops onto the bell icon with a little bounce when something new arrives.

- Category: [Microinteractions](https://library.aimran.es/components/microinteractions)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/bouncing-notification-badge
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A badge on a bell is the universal sign for “something is waiting for you”. The bounce makes new items noticeable without sound or popups. It belongs on the messages icon of a marketplace, a forum’s notifications or a shop’s cart. That small bounce separates a notification badge people notice from one they ignore.

Above 99 it is common to show “99+” instead of the full number. Keep the red for real notifications only, and do not animate the badge again every time the page loads, or people stop noticing it.

## Code

### React (Motion)

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

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

interface NotificationBadgeProps {
  color?: string;
  count?: number;
}

export default function NotificationBadge({
  color = "#d25563",
  count = 3,
}: NotificationBadgeProps) {
  const [show, setShow] = useState(true);

  return (
    <button
      type="button"
      aria-label={show ? `${count} notificaciones` : "Notifications"}
      onClick={() => setShow((s) => !s)}
      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)]"
    >
      <Bell className="h-6 w-6" />
      <AnimatePresence>
        {show && (
          <motion.span
            initial={{ scale: 0, y: -10 }}
            animate={{ scale: 1, y: 0 }}
            exit={{ scale: 0 }}
            transition={spring}
            className="absolute -right-1 -top-1 grid h-6 min-w-6 place-items-center rounded-full px-1 text-[11px] font-semibold text-white"
            style={{ backgroundColor: color }}
          >
            {count}
          </motion.span>
        )}
      </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 “Bouncing notification badge” block (Microinteractions) from AIMRAN Library to my project.

## What it is
A counter that drops onto the bell icon with a little bounce when something new arrives.

## Chosen settings
- Color: #d25563
- Amount: 3 (from 1 to 99)

## 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 { Bell } from "lucide-react";

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

interface NotificationBadgeProps {
  color?: string;
  count?: number;
}

export default function NotificationBadge({
  color = "#d25563",
  count = 3,
}: NotificationBadgeProps) {
  const [show, setShow] = useState(true);

  return (
    <button
      type="button"
      aria-label={show ? `${count} notificaciones` : "Notifications"}
      onClick={() => setShow((s) => !s)}
      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)]"
    >
      <Bell className="h-6 w-6" />
      <AnimatePresence>
        {show && (
          <motion.span
            initial={{ scale: 0, y: -10 }}
            animate={{ scale: 1, y: 0 }}
            exit={{ scale: 0 }}
            transition={spring}
            className="absolute -right-1 -top-1 grid h-6 min-w-6 place-items-center rounded-full px-1 text-[11px] font-semibold text-white"
            style={{ backgroundColor: color }}
          >
            {count}
          </motion.span>
        )}
      </AnimatePresence>
    </button>
  );
}
```

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