Badge

A small pill for counts, tags and statuses.

ClassDoes what
badgeRounded pill on a raised surface
text-errorError-colored text, for validation messages
text-secondaryMuted text

Basic

<div class="prose">
  <p>Status <small class="badge">Draft</small> <small class="badge">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>

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.

Same markup in both builds
<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>

Counts on tabs

A count beside each tab label says what is waiting behind it.

Same markup in both builds
<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>

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.

Same markup in both builds
<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>