Badge Component — Astro
Small labels and tags for displaying status, categories, or counts
Badge Component
Small labels and tags for displaying status, categories, or counts. Badges are inline elements that can be used within text or alongside other components.
Add this component
The command below includes <strong>Badge</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.
Choose your package manager — click a tab to select, then copy the command.
Badge Variants
Badge Sizes
Pill Badges
Usage in Context
You have 3 new messages.
Status: Active
Priority: High
All badges:
- Use semantic theme variables
- Are inline elements (can be used within text)
- Support multiple variants and sizes
- Have pill/rounded variant option
- Automatically adapt to theme changes
Usage
Usage
Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.
Props
variant(optional) - Badge variant:primary,success,warning,error,info(default:primary)size(optional) - Badge size:sm,md,lg(default:md)pill(optional) - Boolean to enable pill/rounded variant (default:false)class(optional) - Additional CSS classes
Badge Variants
Text on solid semantic variants (success, warning, error, info) uses the same contrast variables as buttons (--success-text-on-solid, --warning-text-on-solid, etc.) so badge text stays readable across all themes.
badge--primary- Primary/accent color badgebadge--success- Success/positive badgebadge--warning- Warning badgebadge--error- Error/destructive badgebadge--info- Informational badge
Badge Sizes
badge--sm- Small badge (extra small font, minimal padding)badge--md- Medium badge (small font, standard padding) - defaultbadge--lg- Large badge (base font, larger padding)
Pill Variant
Add the badge--pill class or pill prop to create fully rounded badges:
<Badge variant="primary" pill>Pill Badge</Badge>
<span class="badge badge--primary badge--pill">Pill Badge</span>