Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Badge examples · Outline

Badge with Icon on Left (Outline) for React

An outline badge with a star icon before its label for tags and categories with a symbol.

Framework
UI library

Icons make outline badges scannable without adding visual weight. This React badge puts a Lucide star before its label in the Badge component's outline variant, with data-icon="inline-start" so the badge sizes and spaces the icon itself. Use it for tags with a symbol (a star for featured, a tag for labels, a folder for categories) and metadata types that should be recognized at a glance while the interface stays light.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

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 outline change?

variant="outline" sets a border-border edge and text-foreground, and leaves the background unset. The star stays the first child.

How do I change the badge size?

size on Badge takes sm, md or lg, and pill rounds the badge fully. This demo sets neither, so the label stays the normal height.

Can I use a different icon?

Yes. Replace the star and keep the attributes this demo puts on the icon.