Accessibility to WCAG 2.2 AA
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
contrastcheck computes it by the WCAG formula from CSS variables (--x-foregroundon--x,--on-xon--x, custom pairs). - A11Y-R02: an
<img>has alt; thealtcheck. - A11Y-R03: a form field has a label; the
labelscheck. - A11Y-R04: a button and a link have a name; the
namescheck. - A11Y-R05: headings of an HTML page are in order, one
h1; theheadingscheck. - A11Y-R06:
<html>has lang; thelangcheck. - 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.
- A11Y-R01: theme text contrast is at least 4.5:1 in all schemes; the
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
minContrastfield.
Norms 8
| ID | Norm | Level | Mode | Enforcer |
|---|---|---|---|---|
| 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
| Name | What it does | File | When |
|---|---|---|---|
| contrast | Theme text contrast is at least 4.5:1 norm A11Y-R01 | checks/contrast.ts | check |
| alt | An image has alt norm A11Y-R02 | checks/alt.ts | check |
| labels | A form field has a label norm A11Y-R03 | checks/labels.ts | check |
| names | A button and a link have a name norm A11Y-R04 | checks/names.ts | check |
| headings | Headings of an HTML page are in order norm A11Y-R05 | checks/headings.ts | check |
| lang | A page has a language norm A11Y-R06 | checks/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.
- /design/
- Accessibility page
- /norms/rules/design-a11y/
- Theme text contrast is at least 4.5:1 A11Y-R01
- An image has alt A11Y-R02
- A form field has a label A11Y-R03
- A button and a link have a name A11Y-R04
- Headings are in order A11Y-R05
- A page has a language A11Y-R06
- Color is not the only signal A11Y-R07
- Keyboard, focus and page structure A11Y-R08
Package files 10
They go into .shtukbase/packages/design-a11y/; actions run from there.