shadcn.io is not affiliated with official shadcn/ui
Button examples · Secondary
Button with Count (Secondary) for React
A muted button with a count beside the label, when a supporting action should show how many items it actually covers.
Secondary fill and a badge. The demo shows 3. The number should match what the button acts on, not sit there as decoration.
Use it for a quieter list action, like Archive selected, next to a stronger button. If the count is why people came, use the default Button. In React, the number is whatever you pass to the badge.
Preview
Installation
FAQ
Is the 3 a live count?
No. The Badge children are the characters 3. Nothing in the demo reads a selection or updates the number. Pass your count as the badge's children.
How is the badge colored on a secondary button?
variant="secondary" is the quieter fill. The badge is variant="outline" and pill, a round outline on that fill.
Should I disable it when the count is 0?
When a delete with nothing selected shouldn't run, pass disabled yourself. The demo always shows 3 and stays enabled. Hide the button only when that action isn't part of the screen.
How do I show singular and plural?
The badge is only the number. Put the noun on the button, such as Delete, or write the whole phrase as the button's children. This demo doesn't pick a plural form for you.
Related
- Button with Kbd (Secondary)A shortcut, kept quiet
- Button with Left Icon (Secondary)An icon, kept quiet
- Button with Right Icon (Secondary)An arrow, kept quiet
- Button with Text (Secondary)Quieter than the main action
- Loading Button (Secondary)A side action, while it runs
- Rounded Button (Secondary)A pill, kept quiet