j3w1 / CheckboxVue · HTML · React · Astro

J3W1 / DESIGN SYSTEM

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 · 1.1.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.

<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.

<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@1.1.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@1.1.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

Purpose

An independent yes/no choice, or several of them 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

The box is the native input itself with appearance: none, so it keeps native focus, form and keyboard behaviour. The ✓ and – glyphs are inline SVGs stacked over it in the same 16px cell. The option row is a <label>, at least 24px tall, which makes the text part of the target. A group is a <fieldset> with a <legend>.

States

StateVisualNon-colour channel
default16px box, 1px color.border.control on color.surface.input; text color.text.default
hoverbox background → color.interaction.hover.bg; checked box → color.action.primary.hover-bgcursor: pointer; hover-capable pointers only
focus-visiblering 1px dashed color.interaction.focus.ring at −2px around the boxthe ring
checkedbox fills color.action.primary.bg; ✓ in color.action.primary.text; border stays color.border.controlthe ✓ glyph; checked
mixedbox fills color.action.primary.bg; – in color.action.primary.textthe – glyph; indeterminate / aria-checked="mixed"
checked+focus-visiblethe fill and a ring in color.interaction.focus.ring-containerglyph and ring
checked+disabledbox color.interaction.disabled.bg with 1px color.border.disabled; ✓ and text in color.text.disabledglyph; disabled; cursor: not-allowed
disabledbox color.interaction.disabled.bg with 1px color.border.disabled; text color.text.disableddisabled; cursor: not-allowed
invalidbox border 2px color.status.danger.border; message with the ✕ glyphborder width 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. Space toggles; Enter does nothing. Every checkbox in a group is a separate tab stop, unlike radios. A mixed parent becomes checked on the first Space and unchecked on the second, never mixed again by keyboard.

Accessibility

The text is the label through the wrapping <label>; a group has its legend read before each option. indeterminate is a DOM property with no attribute, so the host mirrors it to data-state-mixed for styling and the state reads as “mixed” natively. A required group marks the legend, not every option, and validates on submit. Contrast: text 8.43:1, glyph 9.28:1 on the fill, box edge 4.45:1 on the input surface and 4.33:1 against the panel when checked, ring 4.69:1, container ring 5.57:1 on the fill.

Portability

A square with a border and a fill plus two glyphs. Hosts that draw their own indicator set it square, 16px, and use 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 with no glyph. A box smaller than 16px or a row shorter than 24px. The mixed state used as a third value. A checkbox that saves on change. Disabling by opacity. A div with role="checkbox".

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • DEMO Vue application demo
  • SPEC Complete UI theme specification