shadcn.io is not affiliated with official shadcn/ui
Badge examples · Secondary
Badge with Icon on Left (Secondary) for React
A secondary badge with a star icon before its label for muted categories with a symbol.
Icons in muted badges guide without shouting. This React badge puts a Lucide star before its label in the Badge component's secondary variant, with data-icon="inline-start" so the badge sizes and spaces the icon itself. Use it for content types, metadata categories or any classification where a symbol helps the eye but a strong color would distract from the main content.
Preview
Installation
FAQ
How does the star sit before the label in React?
The icon is the first child, with data-icon="inline-start" and aria-hidden="true". The badge styles size the svg and space it with the badge's gap, so the icon has no size class.
Why hide the star from assistive tech?
The label is the word in the badge. The star is decoration.
aria-hidden="true" is already on the icon, so screen readers read the word and skip the star.
Does the star need its own color?
No. Lucide icons paint with currentColor, so the star uses the badge's text color and follows the variant, including in dark mode.
What does variant secondary change?
variant="secondary" uses the secondary background and secondary-foreground text. The star stays the first child, with the same icon attributes as in this file.
Related
- Badge with Icon on Right (Secondary)A secondary badge with a star icon after
- Badge with Text (Secondary)A secondary badge with a muted label for
- Badge with Icon on Left (Standard)A default badge with a star icon before
- Badge with Icon on Left (Outline)An outline badge with a star icon before
- Badge with Link (Secondary)A secondary badge rendered as a link that
- Circular Badge with Count (Secondary)A circular secondary badge showing a