Skip to content
GitHub11 stars

Displays a badge or a component that looks like a badge.

Badge Secondary Destructive Outline
<div class="flex w-full flex-wrap justify-center gap-2">
    <Badge>Badge</Badge>
    <Badge Variant="BadgeVariant.Secondary">Secondary</Badge>
    <Badge Variant="BadgeVariant.Destructive">Destructive</Badge>
    <Badge Variant="BadgeVariant.Outline">Outline</Badge>
</div>

Installation

dnx Blazix.Cli add badge

Usage

<Badge Variant="BadgeVariant.Default">Badge</Badge>

Variants

Use the Variant parameter to change the variant of the badge.

Default Secondary Destructive Outline Ghost
<div class="flex flex-wrap gap-2">
    <Badge>Default</Badge>
    <Badge Variant="BadgeVariant.Secondary">Secondary</Badge>
    <Badge Variant="BadgeVariant.Destructive">Destructive</Badge>
    <Badge Variant="BadgeVariant.Outline">Outline</Badge>
    <Badge Variant="BadgeVariant.Ghost">Ghost</Badge>
</div>

With Icon

You can render an icon inside the badge. Use data-icon="inline-start" to render the icon on the left and data-icon="inline-end" to render the icon on the right.

Verified Bookmark
<div class="flex flex-wrap gap-2">
    <Badge Variant="BadgeVariant.Secondary">
        <Icon Data="LucideIcons.BadgeCheck" data-icon="inline-start" />

With Spinner

You can render a spinner inside the badge. Remember to add the data-icon="inline-start" or data-icon="inline-end" parameter to the spinner.

Deleting Generating
<div class="flex flex-wrap gap-2">
    <Badge Variant="BadgeVariant.Destructive">
        <Spinner data-icon="inline-start" />

Use the Render parameter to render a link as a badge.

<Badge>
    <Render>
        <a @attributes="context.Attributes" href="#link">
            Open Link
            <Icon Data="LucideIcons.ArrowUpRight" data-icon="inline-end" />
        </a>
    </Render>
</Badge>

Custom Colors

You can customize the colors of a badge by adding custom classes such as bg-green-50 dark:bg-green-800 to the Badge component.

Blue Green Sky Purple Red
<div class="flex flex-wrap gap-2">
    <Badge Class="bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300">Blue</Badge>
    <Badge Class="bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300">Green</Badge>
    <Badge Class="bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300">Sky</Badge>
    <Badge Class="bg-purple-50 text-purple-700 dark:bg-purple-950 dark:text-purple-300">Purple</Badge>
    <Badge Class="bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300">Red</Badge>
</div>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

شارة ثانوي مدمر مخطط متحقق إشارة مرجعية
<div class="flex w-full flex-wrap justify-center gap-2">
    <Badge>@T.Badge</Badge>
    <Badge Variant="BadgeVariant.Secondary">@T.Secondary</Badge>

API Reference

Badge

ParameterTypeDefault
Render RenderFragment<UseRenderProps>? -
Variant BadgeVariant BadgeVariant.Default
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.