Skip to content
RU
Scale
Density
Theme
Accent

Data display

Badge

The state of an object, named by a word from the library's fixed vocabulary. Five values, and a sixth cannot be added by accident.

The component
queued running done with remarks failed New beta
Markup
<span class="inst-badge"><span class="inst-dot"></span>queued</span>
<span class="inst-badge" data-tone="running"><span class="inst-dot"></span>running</span>
<span class="inst-badge" data-tone="ok"><span class="inst-dot"></span>done</span>
<span class="inst-badge" data-tone="warn"><span class="inst-dot"></span>with remarks</span>
<span class="inst-badge" data-tone="error"><span class="inst-dot"></span>failed</span>

<span class="inst-badge inst-badge--outline" data-tone="ok">New</span>
<span class="inst-badge inst-badge--outline" data-tone="warn">beta</span>

Contract

What Required Why
A word inside the badge yes Colour has no right to be the only carrier of a state
A data-tone from the closed vocabulary yes, on a status Five values. An invented sixth will not be painted at all
An inst-dot inside yes, on a status A second carrier of the mark beside the word
A data-tone on the dot no The dot inherits the tone from the badge: the attribute is set once per group

Accessibility

Colour is not the only carrier A status carries a dot and a word. A reader who does not tell tones apart reads the label
Contrast The label of every tone is checked at 4.5:1 against its own tinted background in five themes. That is what the tone has a separate step of the ramp for text for: the step of the fill does not reach 4.5:1 on itself
Reduced motion The pulse of a running dot slows down rather than going out: an indicator of busyness has to stay visible
Forced-colours mode The dot survives the reset (forced-color-adjust: none), because it carries meaning
Type size --text-2xs — 11px, the lower limit of type size. We go no lower

Anatomy

The dot is the carrier of a second mark: colour has no right to be the only carrier of a state, so a status travels with a dot and a word. A badge with no dot is used where it is not a status but a label of an object.

Example
done done terrain_chunk_04
Markup
<span class="inst-badge" data-tone="ok"><span class="inst-dot"></span>done</span>
<span class="inst-badge" data-tone="ok">done</span>
<span class="inst-badge">terrain_chunk_04</span>

A badge reads --tone-ink and --tone-bg and knows nothing else about the tone.

Variants

A tone is data-tone, one vocabulary for the whole library. The same attribute with the same values works on a note, a banner, a dot and a log row.

Tone Means
no attribute Neutral, not yet begun
data-tone="neutral" Explicitly neutral. It also plays the part of info — blue in the library is taken by the accent
data-tone="running" Happening now. The dot inside pulses
data-tone="ok" Finished successfully
data-tone="warn" Finished with remarks
data-tone="error" Failed

Composition

A counter in navigation

Example
Markup
<a class="inst-nav-item" href="#">Queue
  <span class="inst-badge inst-nav-count">7</span></a>

In a panel header

In context
Run running
worldgen-01 · 4 files
Markup
<div class="inst-panel">
  <div class="inst-panel-header">
    <span class="inst-panel-title">Run</span>
    <span class="inst-badge" data-tone="running"><span class="inst-dot"></span>running</span>
  </div>
  <div class="inst-panel-body">worldgen-01 · 4 files</div>
</div>

Customization

If you are building a component of your own on a tone: a tone has two foregrounds, and the one to take is the one that matches the work.

Variable What for Threshold
--tone-ink Text 4.5:1
--tone-mark A mark with no label: a dot, a caret, the fill of a meter 3:1, and against the track as well

On the statuses they coincide, on the accent they part.

API

Classes
NameWhat it does
class
inst-badgeThe base one
inst-dotThe state dot inside. It inherits the tone from the badge
inst-nav-countA modifier of position for a counter in navigation
modifier
inst-badge--outlineThe tone is carried by the border, with no fill. For a row where a badge stands beside icons and a plate is the heaviest thing in it
inst-badge--countA round counter laid over an icon: no horizontal padding, a solid fill in the accent
Attributes
NameValueWhat it does
attribute
data-tone—neutral running ok warn error. Closed
Tokens
NameValueWhere from
token
--control-h-xs20pxbase +14: density · scale
--radius-xs4pxbase +4: scale
--text-2xs0.6875rembase +4: scale
--weight-medium600one across every cell
--space-24pxone across every cell
--space-36pxone across every cell
--size-dot6pxbase +4: scale
--tone-inkvar(--accent-text)base +2:
--tone-bgvar(--surface-sunken)base +4:

Why the kit works this way — the constitution · Open source under MIT, github.com/keshon/instrument