<cs-badge>
StableFeedbackSince 0.1

Badges draw attention to adjacent content by displaying a status, count, or label. Use them to highlight notifications, categorize items, or flag new activity.

New
Featured

Examples

Variant

Set the variant attribute to change the badge’s variant.

Brand Success Neutral Warning Danger

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

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

Pill

Use the pill attribute to give badges rounded edges.

Brand Success Neutral Warning Danger

Drawing Attention

Use the attention attribute to draw attention to the badge with a subtle animation. Supported effects are bounce, pulse and none.

1 1 1 1 1
1 1 1 1 1

Set the --pulse-color custom property to color the pulse independently of the badge’s variant.

1

Start & End Decorations

Use the start and end slots to add presentational elements like <cs-icon> alongside the badge’s label.

Start End Both

With Buttons

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

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.

NameDescription
(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.

PropertyAttributeDescriptionTypeDefaultReflects
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.

NameDescriptionDefault
--pulse-colorThe color of the badge's pulse effect when using attention="pulse".

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS 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)