Badges draw attention to adjacent content by displaying a status, count, or label. Use them to highlight
notifications, categorize items, or flag new activity.
< cs-badge variant = " brand" >
< cs-icon slot = " start" name = " star" variant = " fill" > </ cs-icon>
Featured
< cs-icon slot = " end" name = " arrow_forward" > </ cs-icon>
</ cs-badge>
Code
Examples
Variant
Set the variant attribute to change the badge’s variant.
Brand
Success
Neutral
Warning
Danger
< cs-badge variant = " brand" > Brand</ cs-badge>
< cs-badge variant = " success" > Success</ cs-badge>
< cs-badge variant = " neutral" > Neutral</ cs-badge>
< cs-badge variant = " warning" > Warning</ cs-badge>
< cs-badge variant = " danger" > Danger</ cs-badge>
Code
Appearance
Use the appearance attribute to change the badge’s visual appearance.
Accent
Filled-Outlined
Filled
Outlined
Accent
Filled-Outlined
Filled
Outlined
Accent
Filled-Outlined
Filled
Outlined
Accent
Filled-Outlined
Filled
Outlined
Accent
Filled-Outlined
Filled
Outlined
< div class = " cs-stack" >
< div>
< cs-badge appearance = " accent" variant = " neutral" > Accent</ cs-badge>
< cs-badge appearance = " filled-outlined" variant = " neutral" > Filled-Outlined</ cs-badge>
< cs-badge appearance = " filled" variant = " neutral" > Filled</ cs-badge>
< cs-badge appearance = " outlined" variant = " neutral" > Outlined</ cs-badge>
</ div>
< div>
< cs-badge appearance = " accent" variant = " brand" > Accent</ cs-badge>
< cs-badge appearance = " filled-outlined" variant = " brand" > Filled-Outlined</ cs-badge>
< cs-badge appearance = " filled" variant = " brand" > Filled</ cs-badge>
< cs-badge appearance = " outlined" variant = " brand" > Outlined</ cs-badge>
</ div>
< div>
< cs-badge appearance = " accent" variant = " success" > Accent</ cs-badge>
< cs-badge appearance = " filled-outlined" variant = " success" > Filled-Outlined</ cs-badge>
< cs-badge appearance = " filled" variant = " success" > Filled</ cs-badge>
< cs-badge appearance = " outlined" variant = " success" > Outlined</ cs-badge>
</ div>
< div>
< cs-badge appearance = " accent" variant = " warning" > Accent</ cs-badge>
< cs-badge appearance = " filled-outlined" variant = " warning" > Filled-Outlined</ cs-badge>
< cs-badge appearance = " filled" variant = " warning" > Filled</ cs-badge>
< cs-badge appearance = " outlined" variant = " warning" > Outlined</ cs-badge>
</ div>
< div>
< cs-badge appearance = " accent" variant = " danger" > Accent</ cs-badge>
< cs-badge appearance = " filled-outlined" variant = " danger" > Filled-Outlined</ cs-badge>
< cs-badge appearance = " filled" variant = " danger" > Filled</ cs-badge>
< cs-badge appearance = " outlined" variant = " danger" > Outlined</ cs-badge>
</ div>
</ div>
Code
Size
Badges are sized relative to the current font size. You can set font-size on any badge (or an ancestor element) to change it.
Extra Small
Small
Medium
Large
Extra Large
< cs-badge variant = " brand" style = " font-size : var ( --cs-font-size-xs) ; " > Extra Small</ cs-badge>
< cs-badge variant = " brand" style = " font-size : var ( --cs-font-size-s) ; " > Small</ cs-badge>
< cs-badge variant = " brand" style = " font-size : var ( --cs-font-size-m) ; " > Medium</ cs-badge>
< cs-badge variant = " brand" style = " font-size : var ( --cs-font-size-l) ; " > Large</ cs-badge>
< cs-badge variant = " brand" style = " font-size : var ( --cs-font-size-xl) ; " > Extra Large</ cs-badge>
Code
Pill
Use the pill attribute to give badges rounded edges.
Brand
Success
Neutral
Warning
Danger
< cs-badge variant = " brand" pill > Brand</ cs-badge>
< cs-badge variant = " success" pill > Success</ cs-badge>
< cs-badge variant = " neutral" pill > Neutral</ cs-badge>
< cs-badge variant = " warning" pill > Warning</ cs-badge>
< cs-badge variant = " danger" pill > Danger</ cs-badge>
Code
Drawing Attention
Use the attention attribute to draw attention to the badge with a subtle animation. Supported effects are bounce, pulse and none.
< div class = " badge-attention" >
< cs-badge variant = " brand" attention = " pulse" pill > 1</ cs-badge>
< cs-badge variant = " success" attention = " pulse" pill > 1</ cs-badge>
< cs-badge variant = " neutral" attention = " pulse" pill > 1</ cs-badge>
< cs-badge variant = " warning" attention = " pulse" pill > 1</ cs-badge>
< cs-badge variant = " danger" attention = " pulse" pill > 1</ cs-badge>
</ div>
< div class = " badge-attention" >
< cs-badge variant = " brand" attention = " bounce" pill > 1</ cs-badge>
< cs-badge variant = " success" attention = " bounce" pill > 1</ cs-badge>
< cs-badge variant = " neutral" attention = " bounce" pill > 1</ cs-badge>
< cs-badge variant = " warning" attention = " bounce" pill > 1</ cs-badge>
< cs-badge variant = " danger" attention = " bounce" pill > 1</ cs-badge>
</ div>
< style>
.badge-attention {
margin-block-end : var ( --cs-space-m) ;
cs-badge:not(:last-of-type) {
margin-right : var ( --cs-space-m) ;
}
}
</ style>
Code
Set the --pulse-color custom property to color the pulse independently of the badge’s variant.
< cs-badge variant = " neutral" attention = " pulse" pill style = " --pulse-color : var ( --cs-color-brand-fill-loud) " > 1</ cs-badge>
Code
Start & End Decorations
Use the start and end slots to add presentational elements like <cs-icon> alongside the badge’s label.
< cs-badge>
< cs-icon slot = " start" name = " eco" > </ cs-icon>
Start
</ cs-badge>
< cs-badge>
< cs-icon slot = " end" name = " park" variant = " fill" > </ cs-icon>
End
</ cs-badge>
< cs-badge>
< cs-icon slot = " start" name = " pets" > </ cs-icon>
< cs-icon slot = " end" name = " flare" > </ cs-icon>
Both
</ cs-badge>
Code
One of the most common use cases for badges is attaching them to buttons. To make this easier, badges will be automatically positioned at the top-right when they’re a child of a button.
Requests
30
Warnings
8
Errors
6
< cs-button appearance = " filled" >
Requests
< cs-badge pill > 30</ cs-badge>
</ cs-button>
< cs-button appearance = " filled" style = " margin-inline-start : 1rem; " >
Warnings
< cs-badge variant = " warning" pill > 8</ cs-badge>
</ cs-button>
< cs-button appearance = " filled" style = " margin-inline-start : 1rem; " >
Errors
< cs-badge variant = " danger" pill > 6</ cs-badge>
</ cs-button>
Code
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import
needed. To cherry-pick this component, use one of the following snippets.
npm
Self-Hosted
React
import '@cruglobal/cornerstone-components/components/badge/badge.js' ;
import './cornerstone/components/badge/badge.js' ;
import CsBadge from '@cruglobal/cornerstone-components/react/badge/index.js' ;
Slots
Learn more about using slots .
Name Description (default) The badge's content. endAn element, such as <cs-icon>, placed after the label. startAn element, such as <cs-icon>, placed before the label.
Attributes & Properties
Learn more about attributes and properties .
Property Attribute Description Type Default Reflects appearanceappearanceThe badge's visual appearance. 'accent' | 'filled' | 'outlined' | 'filled-outlined''accent'Yes attentionattentionAdds an animation to draw attention to the badge. 'none' | 'pulse' | 'bounce''none'Yes pillpillDraws a pill-style badge with rounded edges. booleanfalseYes variantvariantThe badge's theme variant. Defaults to brand if not within another element with a variant. 'brand' | 'neutral' | 'highlight' | 'information' | 'success' | 'warning' | 'danger''brand'Yes
CSS Custom Properties
Learn more about CSS custom properties .
Name Description Default --pulse-colorThe color of the badge's pulse effect when using attention="pulse". —
CSS Parts
Learn more about CSS parts .
Name Description CSS selector badgeThe component's outer wrapper. ::part(badge) endThe container that wraps the end slot. ::part(end) startThe container that wraps the start slot. ::part(start)