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

Checkbox

The native checkbox drawn as a 16px square that fills with the primary action colour and a ✓ or – glyph; single, or a fieldset group of independent choices.

stable · light DOM · 4.0.0. Visible native controls retain FormData, labels, constraints, disabled fieldsets and reset. No duplicate form-value mechanism is installed.

Live variants

default

✕ Confirm before continuing.

Markup
<j3w1-checkbox id="example-checkbox-default"><div class="checkbox">
  <label class="checkbox-option">
    <span class="checkbox-control">
      <input class="checkbox-input" type="checkbox" name="example-checkbox-default-wrap" aria-describedby="example-checkbox-default-cb-wrap-message">
      <svg class="checkbox-check" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3.5 8.5l3 3 6-6"></path></svg>
      <svg class="checkbox-dash" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M4 8h8"></path></svg>
    </span>
    <span class="checkbox-text">Wrap long lines <span class="checkbox-required" aria-hidden="true">*</span><span class="checkbox-required sr-only"> required</span></span>
  </label>
  <p class="checkbox-message" id="example-checkbox-default-cb-wrap-message">✕ Confirm before continuing.</p>
</div></j3w1-checkbox>

group

Bar modules required

✕ Choose at least one module.

Markup
<j3w1-checkbox id="example-checkbox-group"><fieldset class="checkbox checkbox-group" aria-describedby="example-checkbox-group-cb-modules-message">
  <legend class="checkbox-legend">Bar modules <span class="checkbox-required" aria-hidden="true">*</span><span class="checkbox-required sr-only"> required</span></legend>
  <label class="checkbox-option">
    <span class="checkbox-control">
      <input class="checkbox-input" type="checkbox" name="example-checkbox-group-modules" value="cpu">
      <svg class="checkbox-check" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3.5 8.5l3 3 6-6"></path></svg>
      <svg class="checkbox-dash" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M4 8h8"></path></svg>
    </span>
    <span class="checkbox-text">CPU load</span>
  </label>
  <label class="checkbox-option">
    <span class="checkbox-control">
      <input class="checkbox-input" type="checkbox" name="example-checkbox-group-modules" value="memory">
      <svg class="checkbox-check" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3.5 8.5l3 3 6-6"></path></svg>
      <svg class="checkbox-dash" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M4 8h8"></path></svg>
    </span>
    <span class="checkbox-text">Memory</span>
  </label>
  <label class="checkbox-option">
    <span class="checkbox-control">
      <input class="checkbox-input" type="checkbox" name="example-checkbox-group-modules" value="battery">
      <svg class="checkbox-check" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3.5 8.5l3 3 6-6"></path></svg>
      <svg class="checkbox-dash" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M4 8h8"></path></svg>
    </span>
    <span class="checkbox-text">Battery</span>
  </label>
  <p class="checkbox-message" id="example-checkbox-group-cb-modules-message">✕ Choose at least one module.</p>
</fieldset></j3w1-checkbox>

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/checkbox.css';
import '@j3w1/ui/register/checkbox';

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 checkbox --out ./vendor/j3w1/checkbox

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.
valueCustomEventForwards value to the primary native control.
requiredCustomEventForwards required to the primary native control.
readonlyCustomEventForwards readonly to the primary native control.
checkedCustomEventForwards checked to the primary native control.

properties

NameType / signatureMeaning
disabledbooleanDelegates disabled state to native children.
namestringNative control name; application form keys remain explicit.
valuestringPrimary native value; assignment does not fabricate user events.
checkedbooleanNative checkbox state.
requiredbooleanNative required constraint.
readOnlybooleanNative readonly property.
formHTMLFormElement | nullOwning native form. Read only.
indeterminatebooleanNative mixed state; Space changes a mixed checkbox to checked.
valuesstring[]Values of checked native options in this instance.

methods

NameType / signatureMeaning
refresh(): voidReconnect behavior after replacing native child structure.
focus(options?: FocusOptions): voidFocus the first usable native control.
checkValidity(): booleanCheck owned native constraints.
reportValidity(): booleanReport the first invalid owned control.
clear(): voidClear an editable primary input and emit native input/change.

events

NameType / signatureMeaning
j3w1-changeCustomEventNative change from an owned control, alongside the original native event.

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

Checkbox checkbox

  • Family: Basic forms
  • Maturity: stable
  • Priority: R1
  • Since: 0.1.0
  • Native control: native <input type="checkbox"> with <label>; fieldset and legend for a group — APG pattern
  • specified
  • demonstrated
  • test implemented

The native checkbox drawn as a 16px square that fills with the primary action colour and a ✓ or – glyph; single, or a fieldset group of independent choices.

Report an issue with this component

Open component workbench

Tokens

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

PartRoleValueUse
box.bgcolor.surface.inputapproveduse#000000Form-control fill.
box.bordercolor.border.controlapproveduse#c81a1aD-041 owner correction: red control and floating-frame borders, distinct from rose text.
box.bg-hovercolor.interaction.hover.bgapproveduse#1c1010D-041 interaction.hover.bg: color.primitive.modern.hover.
box.ringcolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
box.bg-checkedcolor.action.primary.bgapproveduse#7d1310Primary button fill; D-026 darkened it off color12, which stays fixed as heritage ANSI 12.
box.bg-checked-hovercolor.action.primary.hover-bgobserveduse#911410Primary button hover; pair with action.primary.text (D-033).
box.glyphcolor.action.primary.textapproveduse#ffa2a7Primary action labels: bright rose across rest, hover and pressed states (D-033).
box.ring-checkedcolor.interaction.focus.ring-containerobserveduse#ffa2a7Focus colour for containers and explicitly mapped filled controls (D-015); component rules determine ring geometry.
box.border-invalidcolor.status.danger.borderobserveduse#e53935Danger border, 2px on invalid inputs.
box.bg-disabledcolor.interaction.disabled.bgapproveduse#0d0707D-041 interaction.disabled.bg: color.primitive.modern.panel.
box.border-disabledcolor.border.disabledapproveduse#482b2bD-041 border.disabled: color.primitive.modern.divider.
box.glyph-disabledcolor.text.disabledapproveduse#a3676bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
text.defaultcolor.text.defaultapproveduse#e99499D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
text.disabledcolor.text.disabledapproveduse#a3676bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
legend.textcolor.text.brightapproveduse#ffa2a7D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
legend.required-markcolor.status.danger.textobserveduse#f07178D-041 readable error text on neutral surfaces and native warning tints.
message.textcolor.status.danger.textobserveduse#f07178D-041 readable error text on neutral surfaces and native warning tints.

State matrix

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

StateSingleGroup
default

✕ Confirm before continuing.

Bar modules required

✕ Choose at least one module.

hover
focus-visible
checked
mixed
checked+focus-visible
checked+disabled
disabled
invalid
required

Purpose

An independent yes/no choice, or several under one legend. A setting that takes effect immediately is a switch; one of several exclusive options is a radio group. A parent checkbox over a partly selected set shows the mixed state.

Anatomy

Parts as listed in the anatomy. Because the box is the native input, it keeps native focus, form and keyboard behaviour.

States

StateVisualNon-colour channel
default16px box, 1px color.border.control on color.surface.input; text color.text.default—
hoverbox → color.interaction.hover.bg; checked box → color.action.primary.hover-bgcursor: pointer; hover-capable pointers only
focus-visible1px dashed color.interaction.focus.ring ring at −2px around the boxthe ring
checkedfill color.action.primary.bg; ✓ in color.action.primary.text; border stays color.border.control✓ glyph; checked
mixedfill color.action.primary.bg; – in color.action.primary.text– glyph; indeterminate / aria-checked="mixed"
checked+focus-visiblethe fill plus a color.interaction.focus.ring-container ringglyph and ring
checked+disabledbox color.interaction.disabled.bg, 1px color.border.disabled; ✓ and text color.text.disabledglyph; disabled; cursor: not-allowed
disabledbox color.interaction.disabled.bg, 1px color.border.disabled; text color.text.disableddisabled; cursor: not-allowed
invalid2px color.status.danger.border box border; message with the ✕ glyphborder 1 → 2px; glyph; aria-invalid
required* after the text or legend in color.status.danger.text plus visually hidden “required”required; the mark

Precedence: disabled > invalid > checked > hover; focus-visible is always drawn.

Keyboard

Native; Enter does nothing. A mixed parent becomes checked on the first Space and unchecked on the second, never mixed again by keyboard.

Accessibility

A group’s legend is read before each option. The mixed state reads as “mixed” natively. A required group marks the legend, not every option, and validates on submit. Text and glyphs meet 4.5:1; box edges and rings 3:1.

Portability

Hosts that draw their own indicator make it square, 16px, with the same fill and glyph colours; a host without a mixed indicator draws the dash itself or records the gap.

Non-examples

Rounded or circular boxes. A tick drawn with a border trick or an icon font. A checked state shown by border colour alone. A box under 16px or a row under 24px. The mixed state as a third value. Saving on change. Disabling by opacity. A div with role="checkbox".

Contrast report

18 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
checkbox default borderdefaultuicolor.border.control #c81a1acolor.surface.input #0000003.623pass
checkbox hover borderhoveruicolor.border.control #c81a1acolor.interaction.hover.bg #1c10103.203pass
checkbox focus-visible borderfocus-visibleuicolor.border.control #c81a1acolor.surface.input #0000003.623pass
checkbox focus-visible outlinefocus-visibleuicolor.interaction.focus.ring #e53935color.surface.input #0000004.973pass
checkbox checked textcheckedtextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
checkbox mixed textmixedtextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
checkbox checked+focus-visible textchecked+focus-visibletextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
checkbox checked+focus-visible outlinechecked+focus-visibleuicolor.interaction.focus.ring-container #ffa2a7color.action.primary.bg #7d13105.573pass
checkbox invalid borderinvaliduicolor.status.danger.border #e53935color.surface.input #0000004.973pass
checkbox required borderrequireduicolor.border.control #c81a1acolor.surface.input #0000003.623pass
option text on the panel surface—textcolor.text.default #e99499color.surface.default #0d07078.724.5pass
legend on the panel surface—textcolor.text.bright #ffa2a7color.surface.default #0d070710.454.5pass
checked box edge against the panel (the border stays border.control)checkeduicolor.border.control #c81a1acolor.surface.default #0d07073.443pass
glyph on the hovered checked fillhovertextcolor.action.primary.text #ffa2a7color.action.primary.hover-bg #9114104.754.5pass
validation message on the panel surface—textcolor.status.danger.text #f07178color.surface.default #0d07076.984.5pass
disabled option text (exempt; house floor 3:1)disableduicolor.text.disabled #a3676bcolor.surface.default #0d07074.483pass
disabled glyph (exempt; house floor 3:1)checked+disableduicolor.text.disabled #a3676bcolor.interaction.disabled.bg #0d07074.483pass
disabled border (exempt)disableduicolor.border.disabled #482b2bcolor.interaction.disabled.bg #0d07071.581pass

Keys

KeyAction
Tab / Shift+TabMoves through every checkbox; each is its own tab stop.
SpaceToggles; a mixed box becomes checked.

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Related: radio-group switch fieldset field list

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