Badge
A small pill for counts, tags and statuses.
| Class | Does what |
|---|---|
badge | Rounded pill on a raised surface |
text-error | Error-colored text, for validation messages |
text-secondary | Muted text |
Basic
<div class="prose">
<p>Status <small class="badge">Draft</small> <small class="badge">3 open</small></p>
</div>
<div>
<p>Status <small class="chip">Draft</small> <small class="chip">3 open</small></p>
</div>
Muted and error text
<div class="prose">
<p class="text-secondary">Secondary text</p>
<small class="text-error">That email address is already taken.</small>
</div>
<div>
<p class="secondary">Secondary text</p>
<small class="error">That email address is already taken.</small>
</div>
Composition
Common ways to put this together with other components. The general rules are on Composition.
Tags on an item
Short labels attached to a title, in a list of items.
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: var(--padding)">
<a href="#" class="semantic card">
<div style="aspect-ratio: 3 / 4; background: var(--fill-strong); border-radius: var(--border-radius); margin-bottom: calc(var(--padding) / 2)"></div>
<strong class="link">Item one</strong>
<p class="flex" style="gap: calc(var(--padding) / 4); margin-top: calc(var(--padding) / 4)"><span class="badge">Tag</span><span class="badge">Another</span></p>
</a>
<a href="#" class="semantic card">
<div style="aspect-ratio: 3 / 4; background: var(--fill-strong); border-radius: var(--border-radius); margin-bottom: calc(var(--padding) / 2)"></div>
<strong class="link">Item two</strong>
<p class="flex" style="gap: calc(var(--padding) / 4); margin-top: calc(var(--padding) / 4)"><span class="badge">Tag</span></p>
</a>
</div>
- Text: a badge sits on
--fill-strong, one step darker than a card, so it reads on a card as well as on the page. - Layout: badges in a row need a gap of their own; a quarter of
--paddingkeeps them grouped.
Counts on tabs
A count beside each tab label says what is waiting behind it.
<div class="tabs" role="tablist">
<button class="tab tab-active" role="tab" data-selected>Open <span class="badge">3</span></button>
<button class="tab" role="tab">Done <span class="badge">12</span></button>
</div>
- Text: a badge inherits the tab's font size, so it scales with whatever it sits in.
A table with a heading and status badges
A bordered block holds the heading and the table, and a badge marks each row's state.
<section class="card-border">
<div class="prose"><h3>Invoices</h3></div>
<table class="table">
<thead><tr><th>Month</th><th>Amount</th><th>Status</th></tr></thead>
<tbody>
<tr><td>September</td><td>$1,200</td><td><span class="badge">Paid</span></td></tr>
<tr><td>October</td><td>$1,200</td><td><span class="badge">Due</span></td></tr>
</tbody>
</table>
</section>
- Surface: a flat
.card-borderrather than a raised card, because a table is read, not picked up. - Text:
.prosesits on the heading only, so it does not add margins inside the table.