UI Components Easy
Badge
Compact status badges and tags in multiple color variants, sizes, and styles — solid, outline, and with dot or remove button.
Open in Lab
MCP
css
Targets: HTML
Code
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Inter, system-ui, sans-serif;
background: #050910;
color: #f2f6ff;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem;
}
.demo {
width: 100%;
max-width: 600px;
}
.demo-title {
font-size: 1.5rem;
font-weight: 800;
margin-bottom: 0.375rem;
}
.demo-sub {
color: #475569;
font-size: 0.875rem;
margin-bottom: 2rem;
}
.section {
margin-bottom: 1.75rem;
}
.section-label {
font-size: 0.72rem;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #475569;
margin-bottom: 0.75rem;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: flex-start;
}
/* ── Badge base ── */
.badge {
display: inline-flex;
align-items: center;
gap: 0.3rem;
padding: 0.25rem 0.6rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 600;
line-height: 1;
white-space: nowrap;
background: rgba(255, 255, 255, 0.1);
color: #94a3b8;
border: 1px solid transparent;
}
/* ── Color vars ── */
.badge--blue {
--bc: #38bdf8;
}
.badge--green {
--bc: #22c55e;
}
.badge--amber {
--bc: #f59e0b;
}
.badge--red {
--bc: #ef4444;
}
.badge--purple {
--bc: #a78bfa;
}
.badge--blue,
.badge--green,
.badge--amber,
.badge--red,
.badge--purple {
background: color-mix(in srgb, var(--bc) 15%, transparent);
color: var(--bc);
}
/* ── Outline ── */
.badge--outline {
background: transparent;
border-color: currentColor;
}
.badge--outline.badge--blue,
.badge--outline.badge--green,
.badge--outline.badge--amber,
.badge--outline.badge--red,
.badge--outline.badge--purple {
background: transparent;
color: var(--bc);
border-color: var(--bc);
}
/* ── Sizes ── */
.badge--sm {
font-size: 0.65rem;
padding: 0.2rem 0.45rem;
}
.badge--lg {
font-size: 0.85rem;
padding: 0.35rem 0.8rem;
}
/* ── Dot ── */
.badge--dot::before {
content: "";
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
flex-shrink: 0;
}
/* ── Removable ── */
.badge--removable {
padding-right: 0.35rem;
}
.badge-remove {
background: none;
border: none;
color: currentColor;
cursor: pointer;
font-size: 0.9rem;
line-height: 1;
padding: 0 0.1rem;
opacity: 0.7;
transition: opacity 0.15s;
}
.badge-remove:hover {
opacity: 1;
}<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Badge</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="demo">
<h1 class="demo-title">Badge</h1>
<p class="demo-sub">Compact status labels, tags, and chips.</p>
<section class="section">
<p class="section-label">Color variants — Solid</p>
<div class="row">
<span class="badge">Default</span>
<span class="badge badge--blue">Blue</span>
<span class="badge badge--green">Green</span>
<span class="badge badge--amber">Amber</span>
<span class="badge badge--red">Red</span>
<span class="badge badge--purple">Purple</span>
</div>
</section>
<section class="section">
<p class="section-label">Outline variant</p>
<div class="row">
<span class="badge badge--outline">Default</span>
<span class="badge badge--outline badge--blue">Blue</span>
<span class="badge badge--outline badge--green">Green</span>
<span class="badge badge--outline badge--amber">Amber</span>
<span class="badge badge--outline badge--red">Red</span>
<span class="badge badge--outline badge--purple">Purple</span>
</div>
</section>
<section class="section">
<p class="section-label">Size variants</p>
<div class="row" style="align-items:center">
<span class="badge badge--blue badge--sm">Small</span>
<span class="badge badge--blue">Medium</span>
<span class="badge badge--blue badge--lg">Large</span>
</div>
</section>
<section class="section">
<p class="section-label">Dot indicator</p>
<div class="row">
<span class="badge badge--dot badge--green">Active</span>
<span class="badge badge--dot badge--amber">Pending</span>
<span class="badge badge--dot badge--red">Offline</span>
<span class="badge badge--dot">Unknown</span>
</div>
</section>
<section class="section">
<p class="section-label">Removable tags</p>
<div class="row">
<span class="badge badge--blue badge--removable">Design<button class="badge-remove" aria-label="Remove">×</button></span>
<span class="badge badge--green badge--removable">Frontend<button class="badge-remove" aria-label="Remove">×</button></span>
<span class="badge badge--purple badge--removable">React<button class="badge-remove" aria-label="Remove">×</button></span>
<span class="badge badge--amber badge--removable">TypeScript<button class="badge-remove" aria-label="Remove">×</button></span>
</div>
</section>
</div>
</body>
</html>Badge
Compact inline labels for status, categories, or counts.
Variants
- Solid — filled background, default style
- Outline — transparent background, colored border
- Dot — small colored dot prefix for status indicators
- Removable — with
×button for tag-style inputs
Colors
default · blue · green · amber · red · purple
Sizes
sm · md · lg