ShtukbaseStandard

Accessibility to WCAG 2.2 AA

design-a11y · version 0.1.0
Design8 norms6 checks

Contrast of text/background pairs from the theme's CSS variables by the WCAG formula, alt on images, field labels, button names, heading order, lang on the page; color as the only signal and the keyboard are left to a judge.

About the package

Accessibility norms for a project with an interface: web pages, React, HTML lenses. Checks on the project's code (HTML, TSX, JSX, CSS) hold six norms; a judge holds two.

What it installs

  • The page Accessibility: norms, settings (minContrast, custom color pairs), what programs cannot see.
  • Norms:
    • A11Y-R01: theme text contrast is at least 4.5:1 in all schemes; the contrast check computes it by the WCAG formula from CSS variables (--x-foreground on --x, --on-x on --x, custom pairs).
    • A11Y-R02: an <img> has alt; the alt check.
    • A11Y-R03: a form field has a label; the labels check.
    • A11Y-R04: a button and a link have a name; the names check.
    • A11Y-R05: headings of an HTML page are in order, one h1; the headings check.
    • A11Y-R06: <html> has lang; the lang check.
    • A11Y-R07: color is not the only signal; the judge judges/color-alone.md.
    • A11Y-R08: keyboard, focus, 24 px target size, 3:1 border contrast, structure of the assembled page; the judge judges/keyboard-and-structure.md.

The checks stand on the library of the design-base package; where they look for files is on its page Which files the design checks look at.

Where the boundary is

  • The checks read code, not a running page. A label or name that arrives through {...props} or an expression is invisible to them: such places are skipped, not counted as violations. The package does not replace a full audit in a browser (axe, Lighthouse) and does not install one.
  • A program checks heading order only in HTML: in TSX it is assembled from different components, so a judge looks at it.
  • Level AAA is not required; the contrast threshold can be raised with the minContrast field.

Norms 8

IDNormLevelModeEnforcer
A11Y-R01
In every theme scheme (:root, .dark, [data-theme=…]) a "text on background" pair of CSS variables gives a contrast of at least 4.5:1 by the WCAG 2.2 formula.
MUST blocks
check
A11Y-R02
Every <img> in the project's HTML, TSX and JSX has an alt attribute: a description in words, or alt="" for decoration.
MUST blocks
check
A11Y-R03
Every form field (input, select, textarea and the shadcn fields: Input, Textarea, Checkbox, Switch, SelectTrigger, RadioGroupItem) has a label that a screen reader will read.
MUST blocks
check
A11Y-R04
Every button and link (button, a with href, Button, Link) has a name: text inside, text for a screen reader (sr-only), aria-label, aria-labelledby or title.
MUST blocks
check
A11Y-R05
In a project HTML page a heading is no more than one level deeper than the previous one (h2 → h3, not h2 → h4), and there is one <h1>.
SHOULD blocks
check
A11Y-R06
Every <html> in HTML files and in TSX/JSX markup (for example app/layout.tsx) has a non-empty lang.
MUST blocks
check
A11Y-R07
A meaning conveyed by color (an error, a status, a selection, a link in text, a chart series) is conveyed by something else too: a word, an icon, a shape, an underline.
MUST observes
judge
A11Y-R08
Everything done with a mouse can be done with the keyboard; focus is visible; a click target is at least 24×24 px; field borders and icons differ from the background by at least 3:1; headings of the assembled page are in order.
MUST observes
judge

"Blocks": the enforcer stops a violation. "Observes": it only notes it. Level MUST means required; SHOULD means yes by default.

Actions 6

NameWhat it doesFileWhen
contrastTheme text contrast is at least 4.5:1checks/contrast.ts
check
altAn image has altchecks/alt.ts
check
labelsA form field has a labelchecks/labels.ts
check
namesA button and a link have a namechecks/names.ts
check
headingsHeadings of an HTML page are in orderchecks/headings.ts
check
langA page has a languagechecks/lang.ts
check

shtuk check runs the checks; shtuk run design-a11y <name> runs any action. "After install" actions run by themselves only if the package comes from a trusted source.

Pages 9

They go into the project at these paths.

Package files 10

They go into .shtukbase/packages/design-a11y/; actions run from there.