Skip to content

Badge

A small badge that shows what state something is in. The colour is set with data-color.

data-colorUsed for
(omitted)Information, ongoing state. lt.badge({ color: "info" }) gives the same, without an attribute
successCompleted, approved, active
warningNeeds attention, but is not an error
dangerRejected, expired, critical
neutralInactive, archived, unknown

The badge usually sits next to what it describes. Here in a List with dividers between the rows:

If the badge should sit at the right of the row, the app’s layout decides that, with display: flex and justify-content: space-between on the li element.

ClassWhat it is
.lt-badgeThe badge itself. The colour comes from data-color.
VariableDefault
--lt-badge-paddingvar(--lt-spacing-0-5) var(--lt-spacing-2)
--lt-badge-radiusvar(--lt-spacing-4)

See Customising for how the variables and the layer work.

  • Colour alone says nothing to a screen reader. The text has to carry the meaning: “Rejected”, not just a red dot.
  • <span> inside a line of text, <div> when the badge stands alone.
  • If the badge changes while the page is otherwise still, put role="status" and aria-live="polite" on the element around it.