Skip to content
Elements Badge

Badge

A short label for a status, a count or a category.

On this page

Examples

Variants

primarysuccesswarningerrorneutral
primarysuccesswarningerrorneutral
primarysuccesswarningerrorneutral
primarysuccesswarningerrorneutral
XsSmMdLgXl
Razor
<div class="flex flex-col items-center gap-3">
    @foreach (var variant in Enum.GetValues<KlyVariant>())
    {
        <div class="flex flex-wrap gap-2">
            @foreach (var color in new[] { KlyColor.Primary, KlyColor.Success, KlyColor.Warning, KlyColor.Error, KlyColor.Neutral })
            {
                <KlyBadge Color="color" Variant="variant" Label="@color.Value" />
            }
        </div>
    }
    <div class="flex flex-wrap items-center gap-2">
        @foreach (var size in Enum.GetValues<KlySize>())
        {
            <KlyBadge Size="size" Label="@size.ToString()" Variant="KlyVariant.Subtle" />
        }
    </div>
</div>

API

KlyBadge

Small label for a status, a count or a category, in the colors and variants of the theme.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Color KlyColor "primary" Semantic color of the badge: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else the default of the component. Values: primary, secondary, success, info, warning, error, neutral.
Label string Text of the badge. Use ChildContent for markup.
Size KlySize KlySize.Md Size of the badge, from Xs to Xl . When not set, Size applies, else the default of the component. Values: Xs, Sm, Md, Lg, Xl.
Ui BadgeUi Per-instance class overrides of the slots of the badge, see BadgeUi . They are merged after the theme and the Class parameter wins on the root slot.
Variant KlyVariant KlyVariant.Solid Look of the badge: Solid , Outline , Soft or Subtle . Values: Solid, Outline, Soft, Subtle.

Slots

Name Type Description
LeadingIcon RenderFragment Icon shown before the label, as markup such as a KlyIcon .
TrailingIcon RenderFragment Icon shown after the label, as markup such as a KlyIcon .
ChildContent RenderFragment Content of the badge.

Ui slots

Ui takes a BadgeUi with one class string per slot, merged after the theme.

Slot Styles
Base Classes merged into the base slot of KlyBadge , after the theme and the app configuration.
Label Classes merged into the label slot of KlyBadge , after the theme and the app configuration.
LeadingIcon Classes merged into the leadingIcon slot of KlyBadge , after the theme and the app configuration.
TrailingIcon Classes merged into the trailingIcon slot of KlyBadge , after the theme and the app configuration.