Bootstrap Badge component.

Examples #

Badges scale to match the size of the immediate parent element by using relative font sizing and em units. As of Bootstrap v5, badges no longer have focus or hover styles for links.

Headings #

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New
Example heading New
<h1>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h1>
<h2>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h2>
<h3>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h3>
<h4>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h4>
<h5>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h5>
<h6>Example heading <HxBadge Color="ThemeColor.Secondary">New</HxBadge></h6>

Buttons #

Badges can be used as part of links or buttons to provide a counter.

<HxButton Color="ThemeColor.Primary">
    Notifications <HxBadge Color="ThemeColor.Secondary">4</HxBadge>

Positioned #

Use utilities to modify a HxBadge and position it in the corner of a link or button.

<HxButton Color="ThemeColor.Primary" CssClass="position-relative">
    Inbox<HxBadge Color="ThemeColor.Danger" CssClass="position-absolute top-0 start-100 translate-middle" >99+</HxBadge>

Background colors #

Use our background utility classes to quickly change the appearance of a badge. Please note that when using Bootstrap’s default .bg-light, you’ll likely need a text color utility like .text-dark for proper styling. This is because background utilities do not set anything but background-color.

Primary Secondary Success Danger Warning Info Light Dark

Pill badges #

Use the Type="BadgeType.RoundedPill" to make badges more rounded with a larger border-radius.

Primary Secondary Success Danger Warning Info Light Dark



Name Type Description
AdditionalAttributes Dictionary<string, object> Additional attributes to be splatted onto an underlying HTML element.
ChildContent RenderFragment Content of the component.
Color ThemeColor? Badge color (background).
CssClass string Any additional CSS class to apply.
Settings BadgeSettings Set of settings to be applied to the component instance (overrides HxBadge.Defaults, overriden by individual parameters).
TextColor ThemeColor? Color of badge text. Use Color for the background color. Default is ThemeColor.None (color automatically selected to work with chosen background color).
Type BadgeType? Badge type - Regular or rounded-pills. Default is BadgeType.Regular.

Static properties

Property Type Description
Defaults BadgeSettings Application-wide defaults for HxBadge and derived components.
An unhandled error has occurred. Reload 🗙