Help us shape the future of Go! Take the 2026 Go Developer Survey

a11y

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package a11y is the no-browser accessibility checker run over every golden page and partial: structural rules on the HTML (names, landmarks, ids, headings, tables, dialogs, CSP-hostile attributes) plus contrast and CSS lint on the tokens. It cannot replace a screen-reader pass (docs/QA.md has the by-hand checklist) but it fails the build on the mistakes machines can see.

Index

Constants

This section is empty.

Variables

View Source
var DeclaredPairs = []Pair{
	{"--color-sumi", "--color-paper", 4.5, "text on surface"},
	{"--color-sumi", "--color-shiro", 4.5, "text on page"},
	{"--color-sumi-soft", "--color-paper", 4.5, "body text on surface"},
	{"--color-sumi-soft", "--color-kasumi", 4.5, "body text on hover"},
	{"--color-hai", "--color-paper", 4.5, "muted text on surface"},
	{"--color-hai", "--color-shiro", 4.5, "muted text on page"},
	{"--color-hai", "--color-kasumi", 4.5, "muted text on hover/fill"},
	{"--color-accent", "--color-paper", 4.5, "link on surface"},
	{"--color-accent", "--color-shiro", 4.5, "link on page"},
	{"--color-accent", "--color-accent-soft", 4.5, "accent on accent-soft"},
	{"--color-success", "--color-success-soft", 4.5, "success text"},
	{"--color-warning", "--color-warning-soft", 4.5, "warning text"},
	{"--color-danger", "--color-danger-soft", 4.5, "danger text"},
	{"--color-danger", "--color-paper", 4.5, "danger text on surface"},
	{"--color-paper", "--color-sumi", 4.5, "primary button text"},
	{"--color-paper", "--color-danger", 4.5, "danger button text"},
	{"--color-paper", "--color-sumi-soft", 4.5, "primary button hover text"},
	{"--color-accent", "--color-paper", 3, "focus ring on surface"},
	{"--color-accent", "--color-shiro", 3, "focus ring on page"},
	{"--border-control", "--color-paper", 3, "control border on surface"},
	{"--border-control", "--color-shiro", 3, "control border on page"},
	{"--chart-1", "--color-paper", 3, "chart series 1 on surface"},
	{"--chart-2", "--color-paper", 3, "chart series 2 on surface"},
	{"--chart-3", "--color-paper", 3, "chart series 3 on surface"},
	{"--chart-4", "--color-paper", 3, "chart series 4 on surface"},
	{"--chart-5", "--color-paper", 3, "chart series 5 on surface"},
	{"--chart-6", "--color-paper", 3, "chart series 6 on surface"},
	{"--color-brand", "--color-paper", 3, "brand mark on surface"},
	{"--color-brand", "--color-shiro", 3, "brand mark on page"},
	{"--color-sumi", "--color-accent-soft", 4.5, "bulk bar text"},
	{"--color-sumi", "--color-kasumi", 4.5, "active nav text"},
	{"--color-success", "--color-paper", 4.5, "success text on surface"},
	{"--color-warning", "--color-paper", 4.5, "warning text on surface"},
	{"--color-success", "--color-shiro", 4.5, "success text on page"},
	{"--color-warning", "--color-shiro", 4.5, "warning text on page"},
	{"--color-danger", "--color-shiro", 4.5, "danger text on page"},
	{"--color-sumi-soft", "--color-shiro", 4.5, "nav text on sidebar"},
	{"--color-sumi", "--color-kasumi", 4.5, "table head on hover"},
	{"--color-sumi", "--chart-bar-soft", 4.5, "bar list name on its bar"},
	{"--color-sumi", "--chart-bar-quiet", 4.5, "quiet bar list name on its bar"},
}

DeclaredPairs are the combinations the partials actually use.

Functions

func Check

func Check(doc string, o Options) []string

Check returns one string per violation; empty means clean.

func CheckPublicWidgets

func CheckPublicWidgets(doc string) (errs, warns []string)

CheckPublicWidgets lints a public page-builder fragment (the inside of <main>, island applied or not). Fragment mode: no document rules. errs fail a build; warns are advice (heading order, header-less table). Canvas output is not meant for it.

func ContrastIssues

func ContrastIssues(css string) []string

ContrastIssues checks every declared pair in both themes.

func Ratio

func Ratio(fg, bg string) (float64, error)

Ratio is the WCAG contrast ratio of two #rrggbb colours.

Types

type Options

type Options struct{ Page bool }

Options selects the rule set: Page applies document-level rules (one h1, lang, title, landmarks, skip link) that make no sense for a fragment.

type Pair

type Pair struct {
	FG, BG string
	Min    float64
	What   string
}

Pair is a foreground/background token pair and the minimum ratio: 4.5 for text, 3 for UI boundaries and focus rings (WCAG 2.2 1.4.3 / 1.4.11).

type Tokens

type Tokens map[string]string

Tokens are the custom properties of one theme, resolved (var() followed).

func ParseTokens

func ParseTokens(css string) (light, dark Tokens)

ParseTokens reads tokens.css into the light and dark token sets (dark inherits whatever it does not override, as the cascade does).

func (Tokens) Resolve

func (t Tokens) Resolve(name string) (string, bool)

Resolve follows var() references.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL