shadcn.io is not affiliated with official shadcn/ui
Badge examples · Standard
Badge with Link (Standard) for React
A default badge rendered as a link that underlines on hover, for tags and filtered views.
Sometimes a badge needs to go somewhere. This React badge is itself the link: the Badge component moves its styles onto an a, and hover:underline shows it can be clicked. People can open every post with a tag, every item in a category or every issue with a label. Use it for blog tags, product categories and issue labels that lead to a filtered view.
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 #.
Which variant is the link?
No variant is set, so the link keeps the default colors. That variant also adds a hover background when the badge is an anchor. hover:underline is the extra cue in this file.
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 (Standard)A default badge with a short label for a
- Badge with Icon on Left (Standard)A default badge with a star icon before
- Badge with Link (Secondary)A secondary badge rendered as a link that
- Button with Text (Link)Underline on hover, no fill
- Badge with Icon on Right (Standard)A default badge with a star icon after
- Circular Badge with Count (Standard)A circular default badge showing a number