shadcn.io is not affiliated with official shadcn/ui
Button examples · Link
Button with Count (Link) for React
A link-styled button with a count beside the label, when a quiet action should show how many items it actually covers.
The link variant, plus a badge with a number. The demo shows 3. If the number's meaning is not obvious, say it in the label.
Use it for View comments or Open cart when the count helps and the action is small. If the number is the whole point, a Badge on its own is enough. In React, Base UI does not know the count. You pass it.
Preview
Installation
FAQ
Does the badge track a selection?
No. The number 3 is the Badge children, written in the demo. Render your own count there when the selection changes.
How is this different from a filled button with a count?
variant="link" is primary text, no fill, underline on hover. The badge is variant="secondary" and pill, so the count reads as a small chip after the label.
How do I make it open a page in React?
Pass your link with render, such as render={<a href="/pricing" />}.
What should I do when the count is 0?
Pass disabled if the action shouldn't run empty. Or skip rendering the button. The demo does neither: it always shows 3.
Related
- Button with Text (Link)Underline on hover, no fill
- Button with Left Icon (Link)An icon before a quiet action
- Button with Count (Standard)A count on the main action
- Button with Count (Outline)A count on an outline
- Badge with Text (Standard)A default badge with a short label for a
- Loading Button (Link)A quiet action, while it runs