Badge
Labels an item with a short category or status. The status badge shows the state of a build, test run, or job with a consistent icon and color.
Variants
Each color comes as a solid
fill
and a softer
light-fill
.
neutral
is the default color.
<div :for={
color <- ~w(neutral primary secondary information focus success attention warning destructive)
}>
<.badge size="large" label={String.capitalize(color)} color={color} />
<.badge size="large" label={String.capitalize(color)} color={color} style="light-fill" />
</div>
With icons
An icon before the label, in every color, style, and size.
<div :for={
color <- ~w(neutral primary secondary information focus success attention warning destructive)
}>
<.badge
:for={size <- ~w(large medium small)}
label={String.capitalize(color)}
color={color}
size={size}
>
<:icon><.bell /></:icon>
</.badge>
<.badge
:for={size <- ~w(small medium large)}
label={String.capitalize(color)}
color={color}
style="light-fill"
size={size}
>
<:icon><.bell /></:icon>
</.badge>
</div>
Sizes
Small is the default. Medium suits headers and cards with more room, and large suits page headers.
<.badge label="Small" size="small" color="primary" />
<.badge label="Medium" size="medium" color="primary" />
<.badge label="Large" size="large" color="primary" />
Dot and icon
A dot or an icon before the label reinforces the status at a glance.
<.badge size="large" label="Live" color="success" style="light-fill" dot />
<.badge size="large" label="Flaky" color="warning" style="light-fill">
<:icon><.alert_circle /></:icon>
</.badge>
Disabled
Ignores the color and uses the disabled presentation.
<.badge size="large" label="Disabled" color="success" disabled />
Status badge
Each status has its own icon.
<.status_badge status="success" label="Passed" />
<.status_badge status="error" label="Failed" />
<.status_badge status="warning" label="Cancelled" />
<.status_badge status="attention" label="Flaky" />
<.status_badge status="in_progress" label="Running" />
<.status_badge status="disabled" label="Skipped" />
Status badge with a dot
type="dot"
replaces the icon with a dot in the status color.
<.status_badge type="dot" status="success" label="Passed" />
<.status_badge type="dot" status="error" label="Failed" />
<.status_badge type="dot" status="warning" label="Cancelled" />
<.status_badge type="dot" status="attention" label="Flaky" />
<.status_badge type="dot" status="in_progress" label="Running" />
<.status_badge type="dot" status="disabled" label="Skipped" />
Guidelines
- Keep labels to one or two words. A badge annotates something else and should not carry a sentence.
-
Pick the color for its meaning, not for decoration:
successfor healthy or passing,destructivefor failures,warningandattentionfor things that need a look. -
Use
light-fillwhen several badges sit together, so the row stays calm. Savefillfor the one that needs attention. - For run and job states, use the status badge, which pairs each state with a consistent icon.
-
Map each outcome to the same status everywhere:
successfor passed,errorfor failed,warningfor cancelled,in_progressfor running. -
The status sets the status badge's icon and its color, and
disabledalso mutes the label. Write the label for the outcome, such as Passed or Failed. -
Use
type="dot"in dense lists where the status icons would compete with the content.
API reference
<.badge>
| Attribute | Type | Default | Description |
|---|---|---|---|
|
color
|
string
|
"neutral"
|
Controls the semantic color. Disabled badges ignore this value.
"neutral""destructive""warning""attention""success""information""focus""primary""secondary"
|
|
disabled
|
boolean
|
false
|
Uses the disabled presentation regardless of color.
|
|
dot
|
boolean
|
false
|
Displays a dot before the label when the icon slot is empty.
|
|
label
Required
|
string
|
–
|
The text displayed in the badge.
|
|
size
|
string
|
"small"
|
Controls the badge dimensions and text size.
"small""medium""large"
|
|
style
|
string
|
"fill"
|
Controls whether the badge uses a solid or light fill.
"fill""light-fill"
|
Also accepts global attributes.
| Slot | Description |
|---|---|
|
:icon
|
The icon to render next to the label. Overrides the
dot
attribute.
|
<.status_badge>
| Attribute | Type | Default | Description |
|---|---|---|---|
|
label
Required
|
string
|
–
|
The label of the badge
|
|
status
Required
|
string
|
–
|
The status of the badge
"success""error""warning""attention""disabled""in_progress"
|
|
type
|
string
|
"icon"
|
Whether to render the prefix as a dot, or a status-specific icon
"icon""dot"
|
Also accepts global attributes.