Badge
Small label or count indicator with variant styling (default, secondary, outline, destructive).
Installation
Add the Badge component using the CLI:
Usage
The Badge component displays small labels or count indicators. Use ChildContent for the label text. Set Variant to default, secondary, destructive, outline, or ghost. Set Size for Sm, Md, or Lg.
Examples
Variants
Use the Variant parameter to change the variant of the badge.
With Icon
You can render an icon inside the badge. Place the icon as the first child for inline-start or as the last child for inline-end.
With Spinner
You can render a spinner inside the badge for loading states. Use LuLoaderCircle with animate-spin.
Link
Use the BadgeLink component to render a badge as a link for clickable badges that navigate.
Custom Colors
Customize badge colors by adding custom classes such as bg-green-100 dark:bg-green-900 to the Badge component.
API Reference
Badge
A small label or count indicator for highlighting status or metadata.
Properties
| Name | Type | Description |
|---|---|---|
AdditionalAttributes |
Dictionary<string, Object> |
|
ChildContent |
RenderFragment |
The content of the badge. |
Class |
string |
|
Size |
Size |
The size of the badge. |
Variant |
Variant |
The visual style variant of the badge. |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |