Badge
Small numerical value or status descriptor for UI elements.
When To Use
Badge normally appears in proximity to notifications or user avatars with eye-catching appeal, typically displaying unread messages count.
Intent
The visual intent or color scheme of the badge.
Primary Secondary Success Danger Warning Info
astro
<Badge intent="primary">Primary</Badge>
<Badge intent="secondary">Secondary</Badge>
<Badge intent="success">Success</Badge>
<Badge intent="danger">Danger</Badge>
<Badge intent="warning">Warning</Badge>
<Badge intent="info">Info</Badge> Variant
The style variant of the badge. Use `solid`, `soft` or `outline`.
Solid Soft Outline
astro
<Badge variant="solid" intent="primary">Solid</Badge>
<Badge variant="soft" intent="primary">Soft</Badge>
<Badge variant="outline" intent="primary">Outline</Badge> Size
Set size of the Badge.
Small Medium Large
astro
<Badge size="sm">Small</Badge>
<Badge size="md">Medium</Badge>
<Badge size="lg">Large</Badge> Shape
Badges can have different shapes like pill (default) or rounded.
Pill Rounded
astro
<Badge shape="pill">Pill</Badge>
<Badge shape="rounded">Rounded</Badge> Dot
This will simply display a badge dot, without a specific count.
astro
<Badge shape="dot" intent="primary" size="md" />
<Badge shape="dot" intent="success" size="md" />
<Badge shape="dot" intent="danger" size="md" />
<Badge shape="dot" intent="warning" size="md" />
<Badge shape="dot" intent="info" size="md" /> Standalone / Notification
Use the `notification` shape for numerical indicators like unread counts.
3 +99
astro
<Badge shape="notification" intent="danger" variant="solid">3</Badge>
<Badge shape="notification" intent="primary" variant="solid">+99</Badge> Positioning
Badges can be positioned absolutely relative to a parent container using the `position` prop.
9
astro
<div class="relative w-12 h-12 bg-zinc-200 dark:bg-zinc-800 rounded-md flex items-center justify-center">
<Badge position="top-right" shape="notification" intent="danger" variant="solid">9</Badge>
</div>
<div class="relative w-12 h-12 bg-zinc-200 dark:bg-zinc-800 rounded-md flex items-center justify-center">
<Badge position="bottom-right" shape="dot" intent="success" size="lg" />
</div> API
| Property | Description | Type | Default |
|---|---|---|---|
| intent | The visual intent or color scheme of the badge. | "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "primary" |
| variant | The style variant of the badge. | "solid" | "outline" | "soft" | "soft" |
| size | The size of the badge. | "sm" | "md" | "lg" | "md" |
| shape | The geometric shape of the badge. | "rounded" | "pill" | "dot" | "notification" | "pill" |
| position | Positions the badge absolutely relative to its nearest positioned ancestor. | "top-right" | "bottom-right" | "top-left" | "bottom-left" | - |
| class | Additional CSS classes to apply to the badge. | string | - |