j3w1 / theme

j3w1 / theme4.0.0

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Workbench
  • SPEC Form builder
  • SPEC Task kit
  • SPEC Recipes
  • SPEC Figma bridge
  • SPEC Report an issue
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • SPEC Specification
  • DEMO Vue application demo

Badge

A small square label for a status or a count; every status carries its glyph and its fill, the outline form uses the status border, and an empty badge is a dot with a name.

stable · light DOM · 4.0.0. Light DOM retains static content, native semantics, label relationships and host composition without duplicating controls.

Live variants

status

Failed Drifted Verified Proposed Deferred
Markup
<j3w1-badge id="example-badge-status"><span class="badge badge-danger"><span class="badge-glyph" aria-hidden="true">✕</span><span class="badge-text">Failed</span></span>
<span class="badge badge-warning"><span class="badge-glyph" aria-hidden="true">!</span><span class="badge-text">Drifted</span></span>
<span class="badge badge-success"><span class="badge-glyph" aria-hidden="true">✓</span><span class="badge-text">Verified</span></span>
<span class="badge badge-info"><span class="badge-glyph" aria-hidden="true">i</span><span class="badge-text">Proposed</span></span>
<span class="badge badge-neutral"><span class="badge-glyph" aria-hidden="true">·</span><span class="badge-text">Deferred</span></span></j3w1-badge>

count

12 unread
Markup
<j3w1-badge id="example-badge-count"><span class="badge badge-count"><span class="badge-text">12<span class="badge-unit"> unread</span></span></span></j3w1-badge>

outline

Failed Drifted Verified Proposed Deferred
Markup
<j3w1-badge id="example-badge-outline"><span class="badge badge-outline badge-danger"><span class="badge-glyph" aria-hidden="true">✕</span><span class="badge-text">Failed</span></span>
<span class="badge badge-outline badge-warning"><span class="badge-glyph" aria-hidden="true">!</span><span class="badge-text">Drifted</span></span>
<span class="badge badge-outline badge-success"><span class="badge-glyph" aria-hidden="true">✓</span><span class="badge-text">Verified</span></span>
<span class="badge badge-outline badge-info"><span class="badge-glyph" aria-hidden="true">i</span><span class="badge-text">Proposed</span></span>
<span class="badge badge-outline badge-neutral"><span class="badge-glyph" aria-hidden="true">·</span><span class="badge-text">Deferred</span></span></j3w1-badge>

Install and register

Use the exact version. If npm publication is pending, install the release tarball from the installation guide.

npm install --save-exact @j3w1/ui@4.0.0
import '@j3w1/ui/tokens.css';
import '@j3w1/ui/styles/badge.css';
import '@j3w1/ui/register/badge';

Insert the maintained markup above after loading these imports. Its native children provide accessible names and form behavior; the empty custom tag alone does not create a control.

Vue SFC, React, Astro and plain HTML integration →

Copy the complete implementation

npx --package=@j3w1/ui@4.0.0 j3w1-ui copy badge --out ./vendor/j3w1/badge

The CLI verifies every file before writing and refuses overwrites. Serve the output over HTTP and open index.html. Keep its modules, CSS, tokens and licence notices together.

Public API

attributes

NameType / signatureMeaning
disabledCustomEventDisable the native controls owned by this instance.
loadingCustomEventMark the primary control busy and prevent duplicate activation.

properties

NameType / signatureMeaning
disabledbooleanDelegates disabled state to native children.
namestringNative control name; application form keys remain explicit.

methods

NameType / signatureMeaning
refresh(): voidReconnect behavior after replacing native child structure.
focus(options?: FocusOptions): voidFocus the first usable native control.

events

NameType / signatureMeaning

Dependencies and verification

Registered components: none. Style dependencies: none.

Package presence establishes an available implementation. Actual passes depend on the tested artifact and environment. Read specification execution evidence; read packed-consumer evidence; inspect the complete state matrix.

Full implementation manifest, API and token dependency closure

Canonical specification

Badge badge

  • Family: Information display
  • Maturity: stable
  • Priority: R1
  • Since: 0.1.0
  • Native control: native span; an empty badge is role="img" with aria-label
  • specified
  • demonstrated

A small square label for a status or a count; every status carries its glyph and its fill, the outline form uses the status border, and an empty badge is a dot with a name.

Report an issue with this component

Tokens

Focus a role to inspect its values; follow its link for persistent usage and source details.

PartRoleValueUse
danger.bgcolor.status.danger.fillobserveduse#dc282eDanger fill.
danger.textcolor.status.danger.on-fillobserveduse#f9faf9Text on the danger fill (4.58:1).
danger.bordercolor.status.danger.borderobserveduse#e53935Danger border, 2px on invalid inputs.
danger.outline-textcolor.status.danger.textobserveduse#f07178D-041 readable error text on neutral surfaces and native warning tints.
warning.bgcolor.status.warning.fillapproveduse#e5c07bD-041 status.warning.fill: color.primitive.modern.amber.
warning.textcolor.status.warning.on-fillapproveduse#000000Text on the warning fill (7.54:1).
warning.bordercolor.status.warning.borderapproveduse#e5c07bD-041 status.warning.border: color.primitive.modern.amber.
warning.outline-textcolor.status.warning.textapproveduse#e5c07bD-041 status.warning.text: color.primitive.modern.amber.
success.bgcolor.status.success.fillapproveduse#82d9a0D-041 status.success.fill: color.primitive.modern.green.
success.textcolor.status.success.on-fillapproveduse#000000Text on the success fill (7.13:1).
success.bordercolor.status.success.borderapproveduse#82d9a0D-041 status.success.border: color.primitive.modern.green.
success.outline-textcolor.status.success.textapproveduse#82d9a0D-041 status.success.text: color.primitive.modern.green.
info.bgcolor.status.info.fillapproveduse#82b4ffD-041 status.info.fill: color.primitive.modern.blue.
info.textcolor.status.info.on-fillapproveduse#000000Text on the info fill (7.08:1).
info.bordercolor.status.info.borderapproveduse#82b4ffD-041 status.info.border: color.primitive.modern.blue.
info.outline-textcolor.status.info.textapproveduse#82b4ffD-041 status.info.text: color.primitive.modern.blue.
neutral.bgcolor.status.neutral.fillapproveduse#986f72D-041 status.neutral.fill: color.primitive.modern.control.
neutral.textcolor.status.neutral.on-fillobserveduse#000000Text on the neutral fill (4.71:1).
neutral.bordercolor.status.neutral.borderapproveduse#986f72D-041 status.neutral.border: color.primitive.modern.control.
neutral.outline-textcolor.status.neutral.textapproveduse#d4868bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
count.bgcolor.action.primary.bgapproveduse#7d1310Primary button fill; D-026 darkened it off color12, which stays fixed as heritage ANSI 12.
count.textcolor.action.primary.textapproveduse#ffa2a7Primary action labels: bright rose across rest, hover and pressed states (D-033).

State matrix

Every declared state and combination, statically rendered; the default cell is live. Sizes: compact, comfortable (switch with the density control above).

StateStatusCountOutline
default
Failed Drifted Verified Proposed Deferred
12 unread
Failed Drifted Verified Proposed Deferred
empty

Purpose

Names a status or shows a count next to the thing it describes. A badge is read-only: it never opens, toggles or removes anything. An interactive label is a chip; a message with a status is an alert.

Anatomy

Parts as listed in the anatomy. The glyphs are ✕ danger, ! warning, ✓ success, i info and · neutral.

States

StateVisualNon-colour channel
defaultfill, glyph and text for the status; or the outline formthe glyph; the text
emptyan 8px square dot in the status fill; glyph and text visually hiddenrole="img" with aria-label, or the hidden text; the dot’s position beside its subject

No hover, focus, pressed or disabled state: a badge is not a control.

Keyboard

None. When a badge summarises something the user can act on, the action lives in the neighbouring control and the badge is part of that control’s name or description.

Accessibility

The text carries the meaning, so a reader hears “Failed”, not “cross Failed”. The count’s hidden unit reads as “12 unread”. An empty badge may wrap hidden text instead of aria-label; a dot with no name is decoration and must be aria-hidden. Text meets 4.5:1; outline borders and dots 3:1 on the panel surface. Badges are not targets, so no size minimum applies beyond legibility at 11px caption type.

Portability

Toolkits without background colours on labels use the outline form. Hosts without the glyph characters use the nearest available (x, !, check mark, i, bullet) and record it.

Non-examples

Rounded or pill badges. A clickable badge. A status by colour without its glyph. A count unit hidden from assistive technology. Purple, cyan or magenta statuses. A badge in body type. Wrapping text. A dot without a name.

Contrast report

22 declared pairs measured on resolved sRGB values with the WCAG 2.x formula; 0 waived (decorative only), 0 failing. A pass is a design target for the named role, not an application-wide conformance claim.

PairStateKindForegroundBackgroundRatioMinResult
badge default textdefaulttextcolor.status.danger.on-fill #f9faf9color.status.danger.fill #dc282e4.584.5pass
badge empty textemptytextcolor.status.danger.on-fill #f9faf9color.status.danger.fill #dc282e4.584.5pass
warning badge—textcolor.status.warning.on-fill #000000color.status.warning.fill #e5c07b12.164.5pass
success badge—textcolor.status.success.on-fill #000000color.status.success.fill #82d9a012.384.5pass
info badge—textcolor.status.info.on-fill #000000color.status.info.fill #82b4ff9.924.5pass
neutral badge—textcolor.status.neutral.on-fill #000000color.status.neutral.fill #986f724.854.5pass
count badge—textcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
danger outline text—textcolor.status.danger.text #f07178color.surface.default #0d07076.984.5pass
warning outline text—textcolor.status.warning.text #e5c07bcolor.surface.default #0d070711.574.5pass
success outline text—textcolor.status.success.text #82d9a0color.surface.default #0d070711.794.5pass
info outline text—textcolor.status.info.text #82b4ffcolor.surface.default #0d07079.444.5pass
neutral outline text—textcolor.status.neutral.text #d4868bcolor.surface.default #0d07077.224.5pass
danger outline border—uicolor.status.danger.border #e53935color.surface.default #0d07074.733pass
warning outline border—uicolor.status.warning.border #e5c07bcolor.surface.default #0d070711.573pass
success outline border—uicolor.status.success.border #82d9a0color.surface.default #0d070711.793pass
info outline border—uicolor.status.info.border #82b4ffcolor.surface.default #0d07079.443pass
neutral outline border—uicolor.status.neutral.border #986f72color.surface.default #0d07074.623pass
danger dot on the panel surfaceemptyuicolor.status.danger.fill #dc282ecolor.surface.default #0d07074.173pass
warning dot on the panel surfaceemptyuicolor.status.warning.fill #e5c07bcolor.surface.default #0d070711.573pass
success dot on the panel surfaceemptyuicolor.status.success.fill #82d9a0color.surface.default #0d070711.793pass
info dot on the panel surfaceemptyuicolor.status.info.fill #82b4ffcolor.surface.default #0d07079.443pass
neutral dot on the panel surfaceemptyuicolor.status.neutral.fill #986f72color.surface.default #0d07074.623pass

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Related: chip alert table list

Stress fixtures: FX-I18N FX-RTL FX-ZOOM-200 FX-320 FX-RM FX-HC FX-STATE-MATRIX