packages/components/eui-badge/eui-badge.component.ts
A badge component that can display text, numbers, or icons with various states and styles. Supports content truncation, empty states, and icon-only modes.
<eui-badge>99</eui-badge><eui-badge euiSuccess>Active</eui-badge>
<eui-badge euiDanger>Error</eui-badge><eui-icon-svg icon="eui-email">
<eui-badge euiDanger euiSizeS>9</eui-badge>
</eui-icon-svg><button euiButton euiPrimary>
Primary
<span euiBadge>99</span>
</button><eui-badge [maxCharCount]="2" charReplacement="99+">150</eui-badge><eui-badge [euiIconBadge]="true" euiDanger></eui-badge>
| changeDetection | ChangeDetectionStrategy.OnPush |
| HostDirectives |
BaseStatesDirective
Inputs : euiPrimary euiSecondary euiSuccess euiInfo euiWarning euiDanger euiVariant euiSizeS euiSizeM euiSizeVariant euiOutline
|
| selector | div[euiBadge], span[euiBadge], eui-badge |
| imports |
ObserversModule
|
| templateUrl | ./eui-badge.component.html |
| styleUrl | ./eui-badge.scss |
Properties |
Methods |
Inputs |
HostBindings |
Accessors |
| aria-label |
Type : string | null
|
Default value : 'badge'
|
| charReplacement |
Type : string
|
Default value : ''
|
|
String to display when content is truncated due to maxCharCount. |
| colorPalette |
Type : string
|
|
Extra color palette to be used on the badge. Accepts custom color palette names for extended theming beyond standard variants. |
| e2eAttr |
Type : string
|
Default value : 'eui-badge'
|
| euiDottedBadge |
Type : boolean
|
Default value : false
|
|
Whether to display the badge with dotted styling variant. Applies alternative visual treatment to the badge. |
| euiIconBadge |
Type : boolean
|
Default value : false
|
|
Whether the badge contains only an icon (displays as a small dot indicator). When true, no text content is shown, creating a minimal status indicator. |
| maxCharCount |
Type : number
|
Default value : 0
|
|
Maximum number of characters to display before truncating. When content exceeds this limit, it will be replaced with charReplacement value. Useful for displaying large numbers in a compact format (e.g., "99+" for values over 99). |
| attr.role |
Type : string
|
Default value : 'status'
|
| class |
Type : string
|
|
Computes and returns the CSS classes for the badge based on its current state |
| onContentChanged |
onContentChanged()
|
|
Handles content changes and triggers content checking
Returns :
void
|
| content |
Type : ElementRef
|
Decorators :
@ViewChild('contentRef', {static: false})
|
| role |
Type : string
|
Default value : 'status'
|
Decorators :
@HostBinding('attr.role')
|
| cssClasses |
getcssClasses()
|
|
Computes and returns the CSS classes for the badge based on its current state
Returns :
string
|