Skip to content

@phun-ky/speccer / a11y

Function: a11y() ​

ts
function a11y(): Promise<void>;

Defined in: features/a11y/index.ts:50

Initializes the accessibility elements on the document.

This feature will annotate or highlight accessibility areas like landmarks and region. It can also display tab stops/sequence and any keyboard shortcuts assigned

Tab stops are numbered in the order the Tab key visits them. Add path to draw a line from each tab stop to the next. Lines that go against the reading order get the backwards class. Lines need the #ph-speccer-svg element in the document.

pin

Returns ​

Promise<void>

Example ​

Use the following code, either for html or js:

html
<div
  data-speccer="a11y [shortcuts|tabstops|landmark|headings|autocomplete]"
  class="…"
>
  …
</div>

<div data-speccer="a11y tabstops path">…</div>
ts
const targetElement = document.getElementById('target');
await a11y();

a11y contrast labels each element with text in the container with its WCAG 2 contrast ratio and the level it meets: AAA, AA or Fail. The label is ? when the color behind the text can't be known from styles, like over a background image or with opacity below 1.