Badge
Compact label for status, category or count.
Badges and alerts are small status components. Their job is to communicate state quickly without becoming visual noise.
.badge { border-radius: 999px; padding: .35rem .65rem; }
.alert { border-left: 4px solid currentColor; padding: 1rem; }
Component mental model
Badges label content. Alerts interrupt or warn. They are related, but they do not have the same visual weight.
Good status styling uses text, color, shape and sometimes icons. Color alone is not enough.
A design system should define status variants such as info, success, warning, danger and neutral.
Compact label for status, category or count.
Block-level message that needs attention.
Info, success, warning, danger and neutral each need meaning.
Status colors must remain readable.
Visual model
Blue or neutral guidance.
Positive confirmation.
Attention without panic.
Clear error or destructive risk.
Good CSS versus fragile CSS
.badge { border-radius: 999px; padding: .35rem .65rem; font-weight: 800; }
.badge--success { background: #dcfce7; color: #14532d; }
.alert { border-left: 4px solid currentColor; padding: 1rem; }
.status-good { color: green; }
.status-bad { color: red; }
.alert { background: yellow; }
Rules of thumb
A tiny label and an interrupting message need different visual weight.
Status should remain clear without relying on color alone.
Danger should not sometimes mean warning.
Soft backgrounds still need readable foreground text.
If everything is urgent, nothing is urgent.
Icons can help but should not replace text meaning.
Production thinking
Status components control attention. Clear status reduces cognitive load; noisy status creates distrust.
Use text labels and sufficient contrast. For dynamic alerts, behavior and ARIA live regions may be needed outside CSS.
Document each status variant and use the same meaning across the product.
Badges and alerts mainly support comprehension, not ranking, but clearer pages keep users oriented.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If a state, long label or mobile width breaks the component, the component is not finished yet.
Senior audit upgrade
Badges and alerts often use color, but users should understand the state even if color perception differs.
Write the status in words, not only as green or red.
Use an icon or visual form to support the message.
A tiny badge and an interrupting alert need different visual weight.