Design System

Using accessibility ​

How to pick an element, name it, and reach it without a pointer. For the model behind these rules, see Overview. For every criterion and role, see Reference.

Picking the element ​

Ask what the thing does, then write the element that already does it.

Does it perform an action? That is a button, even when it looks like a row, a tile or a chevron.

Does it go somewhere? That is an a with an href, which gets middle-click, open-in-new-tab and the status bar for free.

Does it introduce a section? That is a heading element, in an order that does not skip levels, styled by a type role rather than identified by one.

Do

A real control, so it takes focus and answers Enter. The ring is painted here to stand in for the one a browser draws on focus, which costs a real button nothing.

Do not

A container with a click handler, so it takes no focus and answers no key. There is no ring to draw.

Naming a control ​

Every interactive control needs a name, and the component layer turns a missing one into a compile error rather than a review comment.

vue
<template>
  <CInput label="Hostname" placeholder="example.com" />
  <CButton label="Delete request" icon="fas fa-trash" icon-only />
</template>

label is required on CInput, CSelect, CCheckbox, CRadio, CToggle, CSegmented and CButton, so a control built from one of those with no name does not build. CAutoComplete and CDropdown take no label prop, so a name on either is written by hand as an aria-label, and CSearchBar sets its own. On an input, hide-label hides the words and keeps the name. On a button, icon-only does the same job.

Sizing a pointer target ​

A pointer target is at least 24 by 24 CSS pixels, from criterion 2.5.8. The floor is in CSS pixels, so it does not relax when somebody lowers their interface text size, which is exactly when a derived height shrinks under it.

24 x 24

Do

The glyph stays small and the target around it clears the floor, so the control is easy to hit without looking heavier.

16 x 16

Do not

The target is the glyph, so it shrinks with the icon and lands under the floor at every text setting.

It applies to targets only. A tag, a status dot and a row that is not itself clickable keep shrinking.

Revealing something on hover ​

States covers why a hover-only row action is unreachable. Hiding it with visibility or display makes it worse: that takes it out of the tab order entirely, so focus can never reach it to reveal it.

Pair every mouse event with its focus equivalent, and reveal with opacity rather than visibility so the control stays focusable while it is faint.

Giving a double-click a second route ​

Double-click has no keyboard equivalent, so it is an accelerator rather than an action. Whatever it does has to be reachable another way, usually a context menu or a visible control in the same row.

That second route needs a name of its own. A rename reachable only through an unnamed icon button is not reachable.

Keeping focus in reading order ​

Focus moves in DOM order, so a layout that reorders things visually leaves the keyboard walking the screen in an order nobody can see. Reorder the markup rather than the presentation, and keep a positive tabindex out of it: it jumps ahead of everything that has none, which reorders the whole page rather than the one control.

Focus also has to stay somewhere visible. If an action removes the element that had focus, send focus somewhere deliberate, because focus left on a removed element falls to the body and the next tab starts from the top.

Leaving the focus ring alone ​

You do not write it, and the one thing you must not do is take it away. States covers why it fails silently when you do.

If a ring sits in the wrong place rather than being unwanted, move it with an offset.

Not trusting a green build ​

The lint rules skip a click handler on a component entirely, and do not match a handler written as a property of an object. So a container carrying @click="row.open" passes every check while being unreachable by keyboard, and so does any click handler you move onto a component to tidy the template.

A @mouseover is the exception: it is still checked on a component. The name check also reaches CDropdown, because the lint configuration names it.

Tab to anything you have built out of a container before you believe the build. If the keyboard cannot reach it, nothing the linter said about it matters.