Skip to content

Badge ​

A badge is a small pill of bold text, usually a count or a short status, shown next to another element to flag new or pending content.

IonBadge is an inline-block span that wraps its child content.

Basic usage ​

A badge does not wrap its text and is filled with the primary color by default. A badge with no content is hidden.

razor
<IonBadge>99+</IonBadge>
<IonBadge>New</IonBadge>

In an item ​

Put a badge in an IonItem's End slot for a trailing count, or in the Start slot to lead the row. A badge after the label in the default slot also ends up at the trailing edge, because the label grows to fill the row.

razor
<IonList>
    <IonItem>
        <ChildContent>
            <IonLabel>Inbox</IonLabel>
        </ChildContent>
        <End>
            <IonBadge>@_unread</IonBadge>
        </End>
    </IonItem>
    <IonItem>
        <Start>
            <IonBadge Color="success">New</IonBadge>
        </Start>
        <ChildContent>
            <IonLabel>Release notes</IonLabel>
        </ChildContent>
    </IonItem>
</IonList>

@code {
    private int _unread = 12;
}

Colors ​

Color fills the badge with a palette color and uses the matching contrast text (dark text on light, success, and warning) — see Theming.

razor
<IonBadge Color="primary">11</IonBadge>
<IonBadge Color="secondary">22</IonBadge>
<IonBadge Color="tertiary">33</IonBadge>
<IonBadge Color="success">44</IonBadge>
<IonBadge Color="warning">55</IonBadge>
<IonBadge Color="danger">66</IonBadge>
<IonBadge Color="light">77</IonBadge>
<IonBadge Color="medium">88</IonBadge>
<IonBadge Color="dark">99</IonBadge>

In tab buttons ​

A badge inside a tab button floats over the top corner of the icon with smaller, tab-specific metrics, and in md mode an empty badge shows as a dot instead of being hidden. See Tabs.

API ​

Every component also accepts Class (extra CSS classes), Style (an inline Style object) and Id (the root element's id) — see Conventions.

IonBadge ​

ParameterTypeDefaultDescription
Colorstring?nullNamed palette color (Ionic color): "primary", "danger", ....
SlotTypeDescription
ChildContentRenderFragment?Content placed between the component's tags.

Styling ​

Theme tokens ​

Theme token IonicTheme.Badge (BadgeToken). Assign only the values you want to change — the rest keep the mode defaults below. App-wide: builder.AddIonic(o => o.Theme.Badge = new BadgeToken { … }); for one subtree: a ConfigProvider. See Theming.

TokenTypemdios
BackgroundColor#0054e9#0054e9
BorderRadiusfloat410
ColorColor#ffffff#ffffff
FontSizefloat1313
MinWidthfloat1010
PaddingBottomfloat43
PaddingEndfloat48
PaddingStartfloat48
PaddingTopfloat33

CSS classes ​

App stylesheet rules always win over Ionic's own rules (see Theming), so these classes can be targeted directly from GlobalStyles.cs.

SelectorElement
.ion-badgeThe badge host. Also carries the mode (md / ios).
.ion-color, .ion-color-{name}Color (e.g. .ion-color-danger).
csharp
// GlobalStyles.cs — pill-shaped badges app-wide
[".ion-badge"] = new()
{
    BorderRadius = new BorderRadius(999),
},

Released under the MIT License.