Skip to content
Español

Navigate

Type to search. Press Escape to close.

    Components · css

    Badge

    A compact label for status or counts. Badges are not interactive; if the label matters to assistive technology, keep it as real text, not colour alone.

    CSS: css/components/badge.css (in ivolt.css).

    Tones, subtle and solidfixtures/badge/variants.htmlOpen alone — Tones, subtle and solid
    <div class="iv-stack iv-u-gap-4">
      <div class="iv-cluster iv-u-gap-2">
        <span class="iv-badge">Draft</span>
        <span class="iv-badge iv-badge--primary">Primary</span>
        <span class="iv-badge iv-badge--success">Published</span>
        <span class="iv-badge iv-badge--warning">Needs review</span>
        <span class="iv-badge iv-badge--danger">Failed</span>
        <span class="iv-badge iv-badge--info">Beta</span>
      </div>
      <div class="iv-cluster iv-u-gap-2">
        <span class="iv-badge iv-badge--solid">Draft</span>
        <span class="iv-badge iv-badge--solid iv-badge--primary">Primary</span>
        <span class="iv-badge iv-badge--solid iv-badge--success">Published</span>
        <span class="iv-badge iv-badge--solid iv-badge--warning">Needs review</span>
        <span class="iv-badge iv-badge--solid iv-badge--danger">Failed</span>
        <span class="iv-badge iv-badge--solid iv-badge--info">Beta</span>
      </div>
      <p class="iv-u-m-0 iv-u-text-sm">
        A badge is a label, not a control. When the colour carries the only
        meaning, the text repeats it: <span class="iv-badge iv-badge--danger">Build failed</span>
      </p>
    </div>

    Classes

    iv-badge plus --primary --success --warning --danger --info (subtle background, coloured text) and --solid (filled). Without a variant the badge is neutral.

    Common mistakes

    • Using a badge as a button; use iv-button--sm instead.
    • Conveying state by colour only: include a word such as “Paid”.

    When to use a badge

    A badge labels something that is already on the screen: the status of an invoice, the plan of an account, the number of unread items next to a link. It is read as part of the sentence or the row it sits in, so keep the word short and specific — “Paid”, “Beta”, “3 new” — and put the full explanation in the surrounding text.

    If the label has to be clicked, it is a button (iv-button iv-button--sm); if it summarises a number that needs context, a stat says more; if it announces something that just happened, use an alert or a toast.

    Customising

    A variant only reassigns the tone locals, and --solid only swaps background and foreground, so any tone combines with --solid without a third class. To make a brand-new tone, set the locals on a class of your own:

    .badge-teal {
      --iv-badge-tone: #0f766e;
      --iv-badge-tone-subtle: #ccfbf1;
      --iv-badge-on-tone: #ffffff;
    }

    Locals: --iv-badge-tone, --iv-badge-tone-subtle, --iv-badge-on-tone, --iv-badge-bg, --iv-badge-fg, --iv-badge-border, --iv-badge-radius. Check the contrast of a custom tone yourself; the shipped tones are tested in both themes.

    Class index

    Parts and modifiers of this family that the examples above do not show. The full list per stylesheet lives in the reference.

    ClassWhat it does
    iv-badge--primaryPrimary tone.
    iv-badge--infoInformative tone.
    iv-badge--successSuccess tone.
    iv-badge--warningWarning tone.
    iv-badge--dangerDanger tone.
    iv-badge--solidFilled variant: the tone becomes the background instead of the tint.