shadcn.io is not affiliated with official shadcn/ui
Button Group examples · Badges
Like with Count Button Group for React
A like button joined to its count, shown with a label, icon-only and in the filled liked state.
A like button with its count attached. ButtonGroupText holds the number and shares the button's border, so the pair reads as one control. The three rows are the labeled button, the icon-only button and the liked state, a filled button with a filled heart.
Preview
Installation
FAQ
Why is the count in ButtonGroupText and not in the button?
The count isn't something you press. ButtonGroupText shows 1.2k or 342 next to the button without taking focus, and it shares the group's border.
How is the liked state drawn?
The third group's button uses the default variant, the label Liked and fill-current on HeartIcon, so the heart fills with the text color. It also sets aria-pressed, so a screen reader announces it as pressed.
How is the icon-only like button named?
It has aria-label="Like" and size="icon-sm". The heart icon has aria-hidden="true".
Does pressing Like switch to Liked?
No. The three rows are static samples. Keep a liked flag, and switch the button's variant, label, heart fill and aria-pressed from it.
Related
- Social Actions Button GroupLike, Comment and Share in one button
- Messages and Followers Button GroupA Messages button with a red unread
- Cart Button Button GroupA cart button with an item count badge on
- Badge with Text (Standard)A default badge with a short label for a
- Button with Text (Standard)The one filled action
- Notifications Button Button GroupTwo bell buttons joined in a group, each