HxBadge

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>
</HxButton>

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>
</HxButton>

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 .rounded-pill utility class to make badges more rounded with a larger border-radius.

Primary Secondary Success Danger Warning Info Light Dark

API

Parameters

Name Type Description
ChildContent RenderFragment
Color ThemeColor Badge color (background). Required.
TextColor ThemeColor
Type BadgeType Badge type - Regular or rounded-pills.
CssClass string Any additional CSS class to apply.
AdditionalAttributes Dictionary<string, object> Additional attributes to be splatted onto an underlying HTML element.
An unhandled error has occurred. Reload 🗙