Make a notification badge and copy the code
Type what the badge counts. Get a bell, cart or inbox icon with a badge that bounces in, as HTML and CSS, JS or React.
- Free, no sign-up
- Runs in your browser
- HTML + CSS, JS, React
A number gives a count badge, "new" a dot, a status like online a presence dot. You can change it after.
Nothing in mind? Try one:
How it works
- Type what the badge counts. "3 new notifications" puts a 3 on a bell, "12 items in cart" a 12 on a cart, "120 unread emails" 99+ on a mail icon, "new message" a dot, "online" a green status dot on an avatar.
- Pick a type and an icon and tune it. Count, dot or status; bell, cart, mail, chat or avatar. Change how it arrives (bounce, squash, fade), how long it takes, the bell ring, the status pulse, the cap, the colours, the size and the corner. Press +1 to watch a new notification arrive.
- Check it. The page checks the timing against the animation rules for badges (a badge bounces in 300 to 400 ms, a bell rings for 400 to 600 ms, a status pulses every 1500 to 2500 ms), the contrast of the badge and its number, the cap, the tap size and the name screen readers hear.
- Copy it. As HTML and CSS, CSS only, HTML only, a small JavaScript function that updates the count, or a React component, or download a standalone .html page.
Questions
- How long should a notification badge animation take?
- The badge bounces in over 300 to 400 ms. A bell rings for 400 to 600 ms, swinging 15 degrees each way. A status dot pulses once every 1500 to 2500 ms. Hover scales the icon in 100 to 150 ms and a press in 50 to 100 ms.
- When should a badge show a dot instead of a number?
- Show a number when it matters, like unread messages or items in a cart. Show a dot when only something new matters, or when the number changes so often that it turns into noise. Cap long counts at 99+ so the badge stays small and legible.
- Is the badge accessible?
- The icon is a button whose aria-label carries the count, like Notifications, 3 unread, and the badge itself is hidden from screen readers so the number is not read twice. The JavaScript keeps the label up to date. The CSS has a prefers-reduced-motion rule that turns off the bounce, ring and pulse, and the page checks the badge for 3:1 contrast and the number for 4.5:1.
- Is anything uploaded?
- No. The badge, the check and the code are made in your browser. The optional AI advice sends the settings and your description, only when you press its button. If you sign in, the badges you copy or download are also kept in your SkillSafe account.
- How do I update the count from my app?
- Copy the JS tab. Its
setBadge(button, count)changes the number, hides the badge at 0, keeps the aria-label in step and plays the bounce and ring again when the count goes up. The React component does the same with acountprop.