Import
Usage
Props
variant
'default' | 'secondary' | 'outline' | 'ghost' | 'link' | 'success' | 'warning' | 'info' | 'danger'
default:"default"
The semantic variant that determines the badge’s color scheme.
default- Primary brand colorsecondary- Secondary brand coloroutline- Outlined with borderghost- Subtle background on hoverlink- Text with underline on hoversuccess- Green for positive stateswarning- Yellow/orange for cautionary statesinfo- Blue for informational statesdanger- Red for error or critical states
Controls the badge size, affecting height, padding, and text size.
xs- Height 4 (16px), text 0.65remsm- Height 5 (20px), text xsmd- Height 6 (24px), text xslg- Height 7 (28px), text smxl- Height 8 (32px), text base
Base UI render prop for custom element composition. Receives props and state.
Additional CSS classes to apply to the badge.
Examples
Variants
All available badge variants:Sizes
Badges in all available sizes:With icons
Badges can contain icons using data attributes for positioning:As link
Use the render prop to create interactive badges:Custom styling
Override default styles with className:Data Attributes
[data-size]- Reflects the current size (xs, sm, md, lg, xl)[data-slot]- Always “badge”[data-variant]- Reflects the current variant[data-icon="inline-start"]- Applied to leading icons for spacing[data-icon="inline-end"]- Applied to trailing icons for spacing
Accessibility
- Uses semantic
<span>element by default - Can be customized to any element via render prop
- Supports
aria-invalidfor error states - Focus visible states with ring for interactive badges
- Sufficient color contrast for all variants
Composition
The Badge uses Base UI’suseRender hook for flexible composition. You can render it as any element: