Skip to the content
Konstruktor UI

Surfaces and display

Badge, tag and chip

Small labels. A .kui-badge states a fact (a state, a count). A .kui-tag is a topic, often a link. A .kui-chip is a filter that turns on and off, or a chosen value that can be removed; <kui-chips> makes both work.

<kui-chips> needs kui.js; the markup works without it as described below

Examples

Badges in every tone

The tone says what kind of fact it is; the word says the fact. An icon can go before the word.

Draft New Paid Due in 3 days Overdue Na čekanju Beta 12
HTML
<span class="kui-badge">Draft</span>
<span class="kui-badge kui-badge--accent">New</span>
<span class="kui-badge kui-badge--ok"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#circle-check"></use></svg>Paid</span>
<span class="kui-badge kui-badge--warn"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#clock"></use></svg>Due in 3 days</span>
<span class="kui-badge kui-badge--danger"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#circle-alert"></use></svg>Overdue</span>
<span class="kui-badge kui-badge--info">Na čekanju</span>
<span class="kui-badge kui-badge--solid">Beta</span>
<span class="kui-badge kui-badge--count" aria-label="12 unread">12</span>

Tags

Tags name topics. As links they lead to everything with that topic.

HTML
<ul class="kui-chips" aria-label="Topics">
  <li><a class="kui-tag" href="#badge-t1">Porez na imovinu</a></li>
  <li><a class="kui-tag" href="#badge-t2">Nasleđivanje</a></li>
  <li><a class="kui-tag" href="#badge-t3">Arbeitsrecht</a></li>
  <li><span class="kui-tag"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#tag"></use></svg><span>Not a link</span></span></li>
</ul>

Filter chips

Each chip is a toggle button with aria-pressed. Press one: it turns on and shows a tick; the element fires kui-change with the values that are on.

HTML
<kui-chips>
  <div class="kui-chips" role="group" aria-label="Filter cases by state">
    <button class="kui-chip" type="button" aria-pressed="true" data-value="open">Open</button>
    <button class="kui-chip" type="button" aria-pressed="false" data-value="waiting">Waiting for the court</button>
    <button class="kui-chip" type="button" aria-pressed="false" data-value="appeal">Žalba</button>
    <button class="kui-chip" type="button" aria-pressed="false" data-value="closed">Closed</button>
  </div>
</kui-chips>

Removable chips

Chosen values with a remove button each. Removing one moves focus to the next remove button, so the keyboard never loses its place. The button’s name is the keyed “Remove {name}”.

  • Beograd
  • Novi Sad
  • Šabac
  • Ниш
HTML
<kui-chips>
  <ul class="kui-chips" aria-label="Chosen cities">
    <li class="kui-chip"><span>Beograd</span><button class="kui-chip__remove" type="button"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#x"></use></svg></button></li>
    <li class="kui-chip"><span>Novi Sad</span><button class="kui-chip__remove" type="button"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#x"></use></svg></button></li>
    <li class="kui-chip"><span>Šabac</span><button class="kui-chip__remove" type="button"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#x"></use></svg></button></li>
    <li class="kui-chip"><span>Ниш</span><button class="kui-chip__remove" type="button"><svg class="kui-icon" aria-hidden="true"><use href="kit/icons.svg#x"></use></svg></button></li>
  </ul>
</kui-chips>

States

Every state

A filter chip that is on has the text colour’s fill and a tick; hover darkens its line; focus shows the ring. A long tag or chip is cut with an ellipsis at the width of its container. Badges never wrap. On a touch screen every chip and remove button is 44 pixels at least.

Rechtsschutzversicherungsbedingungen für Selbstständige 99+
HTML
<div class="kui-chips" role="group" aria-label="Chip states">
  <button class="kui-chip" type="button" aria-pressed="true">On</button>
  <button class="kui-chip" type="button" aria-pressed="false">Off</button>
  <button class="kui-chip" type="button" aria-pressed="false" disabled>Disabled</button>
</div>
<span class="kui-tag" style="max-width: calc(var(--kui-space-8) * 4)"><span>Rechtsschutzversicherungsbedingungen für Selbstständige</span></span>
<span class="kui-badge kui-badge--count kui-badge--danger" aria-label="99 or more">99+</span>

Classes and attributes

.kui-badge
A fact. --neutral, --accent, --ok, --warn, --danger, --info, --solid; --count for a number.
.kui-tag
A topic: a span, or a link.
button.kui-chip[aria-pressed]
A filter that is on or off.
.kui-chip > span + .kui-chip__remove
A chosen value with its remove button.
.kui-chips
A row of tags or chips that wraps; a ul, or a div with role="group".
kui-chips
Toggles filter chips and removes chips. Events kui-change (detail.values) and kui-remove (cancelable, detail.value).
data-kui-after="ID"
On kui-chips: where focus goes when the last chip is removed.

Keyboard

Tab
Moves to each chip or remove button and each tag link.
Enter or Space
Turns a filter chip on or off; presses a remove button.

Accessibility

  • A filter chip is a toggle button: aria-pressed is read as “pressed” or “not pressed”.
  • A group of filter chips has role="group" and a name, so it is read as one set.
  • A remove button is named “Remove Beograd”, not only “Remove”.
  • A count badge carries its meaning in aria-label (“12 unread”), not just the number.
  • Badge colours keep 4.5:1 for their text in every theme; the word carries the meaning anyway.

Do and do not

Do

  • Use one or two words.
  • Use the same tone for the same state everywhere.
  • Show a count badge only when the number matters.

Do not

  • Do not make a badge a button.
  • Do not use colour as the only difference between two badges.
  • Do not put more than one count on one thing.