Susegad UI Accessibility GitHub

How this site looks

The view settings need JavaScript. Every page reads well without them.

Mood

The same pages, in three moods.

Theme

Components

Checkbox

A native checkbox that submits, validates and takes Space with or without JavaScript.

quiet warm playful

Open the live demo npx @susegad/cli add check

Stands on: Core, Core: components, Engine, Sound, Stamp, Tokens

The prompt

the prompt

A box to tick, the oldest mark on a form.

A native checkbox that works with no JavaScript at all: it submits, it validates, Space ticks it, and a screen reader says what it is. The register changes how the box and the tick are drawn, never how the control behaves.

<link rel="stylesheet" href="susegad/components/check/check.css">
<script type="module" src="susegad/components/check/check.js"></script>

<sg-check>
  <label><input type="checkbox" name="rules" value="agreed" required> I have read the house rules</label>
</sg-check>

<sg-check controls="x-breakfast x-pickup">
  <label><input type="checkbox" id="x-all"> All extras</label>
</sg-check>
AttributeValuesWhat it does
indeterminatepresent or absentShows "some" (a dash). HTML has no attribute for this, so the element sets the input's indeterminate property. A click clears it.
controlsids of child checkboxesMakes this a "select all" box: checked when all are, mixed when some are, clear when none are. Ticking it ticks them all.
seedany wordThe hand-drawn marks. Defaults to the label.

The prompt

Make a checkbox web component that wraps a real <input type="checkbox"> inside its <label>, so the form works with JavaScript turned off. Style the native input with appearance: none as a hairline box with the tick drawn in CSS: a ::before clipped to a tick shape with clip-path, scaled in when checked, clipped to a bar when indeterminate, all in token colours with system-colour fallbacks. Put the box in the first column of a grid and align it with the first line of the label using the lh unit, so long labels and Devanagari or Kannada labels line up. Give it three registers. Quiet: exactly that CSS. Warm: lay an aria-hidden SVG over the box, in the same grid cell, with a box sketched in four separate pencil strokes that each run a little past their corners, so the corners cross and the box reads as drawn even at rest, and a heavy pencil tick half as thick again as the CSS one: resample each stroke and push it sideways with seeded noise so it wavers like a hand, and give the tick the small flick a pencil makes at the end. When someone ticks it, draw the tick in with a stroke-dashoffset animation over about a quarter of a second, starting slow the way a pen sets down; never animate on first paint. Playful: make the box a little rubber-stamp block, a heavy inked edge with a fine inner rule, and stamp a bold filled tick in ink, cut bigger than the box so it overprints the edge, with a seeded tilt, three spots of ink, and the Wave 1 stamp's ink texture starving it in places; press it down past flat (0.92) and back. Support a "select all" box through a controls attribute: it reflects its children as checked, mixed or clear, and ticking it ticks every child and fires real change events. In forced-colours mode, bring back the native checkbox and hide the drawing. Under reduced motion, marks appear with no movement.

Words to code

When you sayTechniqueWhat happens
a real <input type="checkbox"> inside its <label>native firstThe input submits, validates (required), takes Space and names itself from the label. With JavaScript off the element is never defined and none of that changes.
a ::before clipped to a tick shapeCSS shapesOne pseudo-element, clip-path: polygon(...) for the tick and inset(...) for the dash, scaled from 0 to 1 on :checked and :indeterminate. The colour is --sg-accent-text with a CanvasText fallback.
align it with the first line using the lh unitlayoutmargin-top: calc((1lh - 1.15em) / 2) centres the box on the first line whatever the script's line height. The browser check measures it within 3px for Marathi, Kannada and Konkani labels.
in the same grid celllayeringThe input and the SVG both take grid-area: 1 / 1; the SVG has pointer-events: none, so every click still lands on the real input.
wavers like a hand … the flick a pencil makesnoisehandLine resamples the stroke every 0.8 units and moves each point along its normal by seeded Perlin noise. The tick's last point runs 8% past the corner.
a box sketched in four strokes … the corners crosssketchsketchBox(seed) jitters the four corners, then draws each side from a seeded 0.35 to 1 times 1.8 units before its corner to as far past the next, each with handLine. Four M commands in one path.
a heavy pencil tickstrokestroke-width: 3.45 on the 20-unit grid, 1.5 times the old 2.3, so the mark reads at 1x.
over about a quarter of a secondWeb Animationsarrival('ambient', 'draw') is 280 ms on cubic-bezier(0.55, 0.05, 0.3, 1), so the pen visibly starts and runs; the finished animation is cancelled.
a rubber-stamp block … overprints the edgestampThe playful box is pencilBox at a 2.1 stroke plus a 0.7 inner rule at 70%, hidden once the stamp prints. The tick is STAMP_TICK scaled 1.4 about a point just up and right of centre, so its long arm crosses the top edge.
the Wave 1 stamp's ink texturealpha maskinkMask() from stamp.core.js paints a 56 × 56 alpha mask (2 per unit) into a canvas, once per label, and an SVG <mask style="mask-type: alpha"> prints the tick through it. A tick this small can lose too much to one soft patch, so the skin takes the first of six seed variants that still prints 85% of the middle.
draw the tick in … never animate on first painta real changeThe skin remembers the last state and animates stroke-dashoffset only on a change from clear to ticked.
a "select all" boxtri-statetriState(children) gives checked, mixed or clear. The parent sets aria-controls, and a screen reader hears "mixed". Ticking it sets each child and dispatches input and change, so the children's own drawings and any listeners follow.
bring back the native checkboxforced coloursUnder forced-colors: active the input gets appearance: auto and the drawing display: none, so high-contrast users get the system control in system colours.

Accessibility

  • The native checkbox is the control: its name comes from the label, its state from the browser, "mixed" included.
  • Every drawing is aria-hidden and never takes a click.
  • The box edge, the pencil and the tick are 3:1 or more against every surface in every palette and theme (tested).
  • A required box left clear is marked by the browser; after interaction the edge turns --sg-danger too (:user-invalid), never colour alone, because the browser's message says what is wrong.
  • Forced colours: the system checkbox. Reduced motion: no movement.

<sg-check> wraps one native <input type="checkbox"> and its label. Everything a checkbox does, the input does, with or without JavaScript.

Use

<link rel="stylesheet" href="susegad/components/check/check.css">
<script type="module" src="susegad/components/check/check.js"></script>

<sg-check>
  <label><input type="checkbox" name="extras" value="breakfast" checked> Breakfast on the balcão</label>
</sg-check>

A label beside the input (<input id="doc-x"><label for="x">) also works.

Select all

<sg-check controls="x-breakfast x-pickup x-late">
  <label><input type="checkbox" id="x-all"> All extras</label>
</sg-check>
<sg-check><label><input type="checkbox" id="x-breakfast" name="extras" value="breakfast"> Breakfast</label></sg-check>
...

Give the "select all" input no name, so it is not sent with the form. Without JavaScript it is an ordinary checkbox that does nothing, so for a page that must work without scripts, leave it out or render it only when scripts run.

Attributes and properties

ValuesDefault
indeterminateboolean attributeabsent
controlsspace-separated ids of child checkboxesnone
seedany string, for the drawn marksthe label
registerquiet, warm, playfulinherited
checked (property)boolean; setting it fires changethe input's

Registers

LookMotion
quiet (and no JS)hairline box, crisp tick, a bar for "some"the tick scales in under 200ms
warma box sketched in four pencil strokes whose corners cross, a heavy pencil tick, a pencil dashthe tick is drawn in over 280 ms when ticked
playfula rubber-stamp block (a heavy inked edge and a fine inner rule); a bold stamped tick, cut bigger than the box and printed through the Wave 1 stamp's ink texture, with ink spotsthe stamp presses down past flat and settles

Reduced motion: marks appear with no movement. Forced colours: the system checkbox.

Accessibility

How this component meets WCAG 2.2 level A and AA, criterion by criterion, how each was checked, and what your page still owns.

  • Meets 16
  • Meets with author's part 3
  • Not applicable 1
CriterionStatusHow it was checked
1.1.1 Non-text contentMeetsThe pencil box and tick in warm and playful are aria-hidden drawings over the native input, and the label is the name. packages/components/check/check.check.mjs: "the drawing is hidden from assistive tech" in warm and playful.
1.3.1 Info and relationshipsMeetsA native <input type="checkbox"> inside its <label>, groups in a <fieldset> with a <legend>. check.check.mjs: "no JS: Space ticks it", and "some children on: All extras is mixed, and says so" reads the accessibility tree.
1.3.5 Identify input purposeNot applicableA checkbox holds a choice, not personal data that has a WCAG input purpose (the 53 autocomplete tokens), so the criterion does not apply.
1.4.1 Use of colorMeetsState is the tick, the dash for mixed, or the stamp, never colour alone: packages/components/check/check.test.js, "the pencil tick is deterministic, stays in its box" and "the stamp: a closed filled tick"; check.check.mjs: "Space ticks it and the drawing follows" in each register.
1.4.3 Contrast (minimum)MeetsThe label is page text in --sg-text, tested at 4.5:1 on every surface in packages/tokens/tokens.test.js. axe color-contrast is clean: tools/axe.mjs --url /packages/components/check/demo.html: 0 violation(s) across 6 run(s) (three registers, light and dark, desktop), 2026-10-07.
1.4.4 Resize textMeetsManual test, 2026-10-06: the demo with the root font size at 200 percent in three registers (1280 px wide), no sideways scroll and no clipped label (throwaway Playwright script).
1.4.10 ReflowMeetsManual test at 320 CSS px, three registers, 2026-10-06: no sideways scroll and no clipped label (throwaway Playwright script). No check in the repository asserts it yet.
1.4.11 Non-text contrastMeetspackages/components/check/check.test.js: "1.4.11: <palette> <theme>: the box edge and the tick are 3:1 or more" on every surface, every palette, light and dark. The focus ring is tested 3:1 or more in packages/tokens/tokens.test.js.
1.4.12 Text spacingMeetsManual test, 2026-10-06: the WCAG text-spacing values (line height 1.5, letter 0.12em, word 0.16em, paragraph spacing 2em) injected on the demo in three registers, no clipped or overlapping text (throwaway Playwright script). check.check.mjs also keeps the box level with Marathi, Kannada and Konkani labels.
2.1.1 KeyboardMeetscheck.check.mjs: "no JS: Space ticks it", "Space ticks it and the drawing follows" in each register, and ticking or clearing "All extras" with the keyboard.
2.1.2 No keyboard trapMeetsManual test: packages/components/check/check.js binds no keydown and sets no tabindex; the native input takes Tab and Shift+Tab as any checkbox does.
2.4.3 Focus orderMeetsManual test: the native input is the only tab stop and keeps its place in the page's order; the drawing takes no focus (packages/components/check/check.js sets no tabindex).
2.4.7 Focus visibleMeetstools/touch.check.mjs Tabs onto the control in each register and requires a focus style; the rule is input[type="checkbox"]:focus-visible in packages/components/check/check.css.
2.4.11 Focus not obscured (minimum)Meets with author's partManual test: packages/components/check/check.css has no position: fixed or sticky and no overlay. A sticky header or banner the page adds can cover a box that is scrolled to.
2.5.3 Label in nameMeetsThe accessible name is the visible label text, because the label wraps the input and the component adds no aria-label (check.check.mjs reads the box by that label in the accessibility tree).
2.5.8 Target size (minimum)MeetsManual test, 2026-10-06: the click target is the whole <label>, not only the box. The box alone is 20.7 by 20.7 px at 1280 px and 18.5 by 18.5 px at 390 px, but the label is 28.8 px tall at 1280 px and 25.7 px tall at 390 px on one line, at least 90 px wide, in the demo (throwaway Playwright script). The label must stay around the input.
3.2.2 On inputMeetscheck.check.mjs: the form submits only when the page's own button is pressed, and a "select all" box changes the children it names and nothing else, which its label says ("All extras").
3.3.1 Error identificationMeets with author's partrequired is the native attribute: check.check.mjs: "no JS: a required box left clear stops the form" and "no JS: the browser marks it invalid". The browser says why in its own words; a page that writes its own error message owns putting it in text next to the box.
3.3.2 Labels or instructionsMeets with author's partThe native <label> is the name (packages/components/check/check.check.mjs reads each box by its label). The label text and any instruction are the author's.
4.1.2 Name, role, valueMeetscheck.check.mjs: a checkbox with its label, mixed for a select-all box with some children on, and checked as the native one; axe: 0 violation(s), tools/axe.mjs --url /packages/components/check/demo.html, 2026-10-07.

The page author owns:

  • The label text, in the language of the page, inside the <label> that wraps the input, and lang on a label in another language (3.1.2).
  • A <fieldset> and <legend> for a group of boxes.
  • Any error text the page writes for a required box, next to the box (3.3.1).
  • Sticky headers and banners that could cover a box when it takes focus (2.4.11).
  • The colours the page sets behind the box, if it overrides the tokens.

How it behaves

  • Keyboard: Tab to it, Space to tick. Nothing added, nothing taken away.
  • A screen reader hears the label and "checked", "not checked" or "mixed".
  • Required: use required on the input. The browser stops the form and says why.
  • Contrast: box edge, pencil and tick are 3:1 or more on every surface (WCAG 1.4.11), tested for every palette and theme.

All 57 tables, and how the library tests

Budget

Behaviour 8.6 KB of 12 KB (check.js + check.core.js); skins 0.3, 2.2 and 1.9 KB.