shadcn.io is not affiliated with official shadcn/ui
Button Group examples · Badges
Notifications Button Button Group for React
Two bell buttons joined in a group, each with a notification badge on its corner, one showing 12 and one capped at 99+.
Icon buttons with an unread count. Each bell carries a small round Badge on its top corner, the default fill for 12 and the destructive fill for 99+. Since the buttons have no text, each one has an aria-label that includes the count.
Preview
Installation
FAQ
How does the badge sit on the icon?
The Button has relative, and the Badge has absolute -end-2 -top-1 z-10. The z-10 keeps the first badge above the second button, whose border it overlaps.
How are the bell buttons named?
With aria-label: Notifications, 12 unread and Alerts, more than 99 unread. The label replaces the badge text, so the name is a full phrase rather than a bare number.
Where does 99+ come from?
It's the badge's text. Cap the number yourself before you pass it, since the badge shows whatever it gets.
Why is one badge red?
The second sets variant="destructive", for alerts that need attention. The first uses the default fill.
Is the count updated live?
No. Both numbers are written into the file. Pass your unread count to the badge and the aria-label together.
What does a bell open?
Nothing in the demo. A Popover with the notification list is the usual choice.
Related
- Cart Button Button GroupA cart button with an item count badge on
- Messages and Followers Button GroupA Messages button with a red unread
- Circular Badge with Count (Standard)A circular default badge showing a number
- Circular Badge with Count (Destructive)A circular destructive badge showing a
- Basic Button GroupThree rows of outline buttons joined into
- Like with Count Button GroupA like button joined to its count, shown