shadcn.io is not affiliated with official shadcn/ui
Badge examples · Secondary
Badge with Link (Secondary) for React
A secondary badge rendered as a link that underlines on hover, for quiet tags and filters.
A clickable badge doesn't always need a bold color. This React badge renders a link in the Badge component's secondary variant, with hover:underline as the cue that it can be clicked. Use it for supporting navigation, secondary category links, tag clouds and filters that should be easy to find but shouldn't lead the page.
Preview
Installation
FAQ
How does this badge become a link in React?
This demo underlines the link on hover.
Pass render with an a and its href, as this file does with href="#link". className="hover:underline" stays on Badge.
Use a real URL, not #.
What does variant secondary change on the link?
variant="secondary" keeps the muted secondary fill and secondary-foreground text on the link. The variant adds a hover background when the badge is an anchor, and this file adds hover:underline.
Can I reach the link from the keyboard?
Yes. It is an a with an href, so Tab focuses it and Enter follows it. Screen readers announce a link.
Should a toggle filter be this badge?
No. This pattern goes to another page. An on and off filter is a Button or a toggle.
Related
- Badge with Text (Secondary)A secondary badge with a muted label for
- Badge with Link (Standard)A default badge rendered as a link that
- Badge with Icon on Left (Secondary)A secondary badge with a star icon before
- Badge with Link (Outline)An outline badge rendered as a link that
- Badge with Icon on Right (Secondary)A secondary badge with a star icon after
- Circular Badge with Count (Secondary)A circular secondary badge showing a