Badges are small status descriptors for UI elements, used to convey concise information about an item or its status. They provide a visual way to highlight important information, categorize content, or indicate states in your application. The badge component supports various semantic types, sizes, and icon integration for maximum flexibility.
When to Use
✅ Use badges when:
Indicating status or state changes (new, updated, approved)
Categorizing or labeling content (tags, categories)
Showing counts or quantities (notifications, items)
Highlighting important information (featured, urgent)
Providing visual feedback for user actions
❌ Don't use badges for:
Primary navigation elements (use buttons or links)
Large amounts of text (use cards or sections)
Interactive actions (use buttons)
Complex information display (use dedicated components)
Choose badge sizes based on context and visual hierarchy. Small badges work well for compact layouts, while large badges are more prominent:
<dap-ds-stackdirection="row"align="center"><dap-ds-badgesize="sm"> Small Badge</dap-ds-badge><dap-ds-badgesize="lg"> Large Badge</dap-ds-badge></dap-ds-stack>
Badges with icons
Badges can include icons to provide additional visual context:
<divstyle={{border:'var(--dds-border-width-base) solid var(--dds-border-neutral-subtle)', padding:'var(--dds-spacing-600)', borderRadius:'var(--dds-radius-base)'}}><dap-ds-stack><dap-ds-typographyvariant="h4">System Notifications</dap-ds-typography><dap-ds-stack><dap-ds-stackdirection="row"align="center"><dap-ds-badgetype="info"liveicon="mail-line"> 3 new messages </dap-ds-badge><dap-ds-typographyvariant="body"> You have unread messages from your team</dap-ds-typography></dap-ds-stack><dap-ds-stackdirection="row"align="center"><dap-ds-badgetype="warning"liveicon="alert-line"> Storage 85% full</dap-ds-badge><dap-ds-typographyvariant="body"> Consider upgrading your storage plan</dap-ds-typography></dap-ds-stack><dap-ds-stackdirection="row"align="center"><dap-ds-badgetype="positive"liveicon="shield-check-line"> Backup completed</dap-ds-badge><dap-ds-typographyvariant="body"> Last backup: Today at 3:00 AM</dap-ds-typography></dap-ds-stack></dap-ds-stack></dap-ds-stack></div>
The badge component supports extensive customization beyond the default variants. This section demonstrates practical styling techniques and advanced customization patterns.
Quick Customization with CSS Custom Properties
For simple customizations, use CSS custom properties directly on the component:
Create badges that automatically adapt to different themes:
<dap-ds-stackdirection="row"><dap-ds-badgetype="neutral"style={{'--dds-badge-neutral-background':'var(--dds-background-neutral-strong)','--dds-badge-neutral-color':'var(--dds-text-neutral-inverted)','--dds-badge-neutral-border-color':'var(--dds-border-neutral-strong)',}}> High Contrast</dap-ds-badge><dap-ds-badgetype="info"style={{'--dds-badge-info-background':'transparent','--dds-badge-info-color':'var(--dds-informative-600)','--dds-badge-info-border-color':'var(--dds-informative-600)','--dds-badge-border-width':'var(--dds-border-width-thick)',}}> Outlined</dap-ds-badge></dap-ds-stack>
Advanced CSS Classes
For more complex styling, use CSS classes that work with the component's CSS parts. Experiment with custom badge styling using CSS parts and custom properties. Try the presets below or create your own styles:
Select a presetGradient BadgeShadow BadgeGlow EffectScale EffectBorder Animate
Copy CSSFormat CSSResetLightDark
CSS Editor
Live Preview
Custom Badge
Implementation NotesUsing Custom Styles in Your Project
The badge component uses Shadow DOM, which encapsulates styles. Here's how to implement custom styling effectively:
1. Shadow DOM Limitations
Note: Keyframe animations defined outside the component won't work due to Shadow DOM encapsulation. Use:
Transitions with hover states (✅ Works)
Transform effects (✅ Works)
CSS custom property changes (✅ Works)
External keyframe animations (❌ Won't work)
2. Accessibility with Live Badges
Use the live property for dynamic content that should announce changes:
<dap-ds-badgetype="info"liveicon="mail-line">
3 new messages
</dap-ds-badge>
The icon of the badge, this is a name of a built in icon
live
boolean
false
Whether the badge represents dynamic content that should announce changes
Slots
Name
Description
(default)
The content of the badge.
icon
The icon of the badge.
Events
No custom events available.
CSS Parts
Part Name
Description
base
The main container of the badge.
icon
The icon of the badge.
content
The content of the badge.
icon-base
The base of the icon.
How to Use CSS Parts
You can style CSS parts using the ::part() pseudo-element selector:
/* Target a specific part */.my-custom-dap-ds-badge::part(base){/* Your custom styles */}/* Target multiple parts */.my-custom-dap-ds-badge::part(base),.my-custom-dap-ds-badge::part(icon){/* Shared styles */}