shadcn.io is not affiliated with official shadcn/ui
Badge examples · Destructive
Badge with Icon on Left (Destructive) for React
A destructive badge with a star icon before its label for errors that need a symbol.
Icons make badges scannable at a glance. This React badge puts a Lucide star before its label in the Badge component's destructive variant, with data-icon="inline-start" so the badge sizes and spaces the icon itself. Swap the star for the symbol your status needs (an X for failed, an alert for critical, a ban for blocked): people take in an icon faster than a word.
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 destructive change?
variant="destructive" sets text-destructive on bg-destructive/10. The star stays the first child and picks up that text color.
Related
- Badge with Icon on Right (Destructive)A destructive badge with a star icon
- Badge with Text (Destructive)A destructive badge for an error, a
- Badge with Icon on Left (Outline)An outline badge with a star icon before
- Badge with Icon on Left (Standard)A default badge with a star icon before
- Error with Everything AlertA destructive alert with an error icon, a
- Circular Badge with Count (Destructive)A circular destructive badge showing a