Accessibility

Contrast, focus, keyboard, target size and names: what every screen has to meet, with the WCAG 2.2 criterion behind each number.

Every action works by keyboard, by touch and through a screen reader, and every word and edge is readable in every theme held to the numbers below.

The bar is WCAG 2.2 level AA. Each number below links the success criterion (SC) it comes from; where a page asks for more than AA, it says so and names the source. @orz/ui's components are built on Radix, which brings roles, keyboard handling and focus management with it. What they cannot do for an app is choose its words, its colours and what it puts on a screen, and most of this page is about that.

Contrast#

UseTokensRatio
Body textforeground on background–
Secondary textmuted-foreground on background–
Inactive tabmuted-foreground on muted–
Primary buttonprimary-foreground on primary–
Error messagedestructive on background–
Focus ringring on background–
Field borderinput on background–

The table measures the theme you are reading this in; pick another from the theme menu and it follows.

  • Text: 4.5:1 against what it sits on (SC 1.4.3). Large text, 24px or 18.66px bold and up, needs 3:1. A tag's name is held to 4.5:1 on its own fill, in each of its colours.
  • Edges and states: 3:1 — the edge that shows where a field is, the focus ring, the tick that marks a highlighted or open row and the bar that marks a picked one in a list box or a table, the edge across the current tab and the edge of a toggle held down while it is on, a chart's series, the thumb of a switch, an icon that carries meaning on its own (SC 1.4.11). A fill alone is never the state: a row's highlight measures barely over 1:1 against the list around it. A marker badge's count is held to 4.5:1 on its fill, as text is.
  • Disabled controls are exempt. They are drawn at half opacity on purpose; do not use the same look for anything a reader is meant to read.
  • Colour reads from the tokens, never a hard-coded value. A token is held to these numbers in every built-in theme but the ones used as published; a hex code is held to them in the one theme it was picked in.
  • Never colour alone (SC 1.4.1). An invalid field is red and says what is wrong; a diff line is green and starts with +; a failed run is red and has a failed icon.

Catppuccin and Prohibitorum keep their published values, so a few of their pairs fall below these numbers. A few other themes keep a file tree's status colours on a hovered row's accent or in a sidebar, where the letter beside each says the status too. These are all of them, measured from the palettes:

ThemeTokenOnLowest
Picotera Picodestructiveaccent, sidebar-accent3.75:1, under 4.5:1
Picotera Picosuccessaccent, sidebar-accent3.79:1, under 4.5:1
Picotera Picowarningaccent, sidebar-accent3.88:1, under 4.5:1
Picotera Teradestructiveaccent, sidebar-accent4.32:1, under 4.5:1
Visual Studio lightdestructivesidebar-accent4.02:1, under 4.5:1
Visual Studio lightsuccesssidebar-accent4.00:1, under 4.5:1
Visual Studio lightwarningaccent, sidebar, sidebar-accent3.63:1, under 4.5:1
Visual Studio lightmuted-foregroundsidebar-accent4.49:1, under 4.5:1
Visual Studio darkdestructiveaccent, sidebar-accent3.46:1, under 4.5:1
Visual Studio dark · AMOLEDdestructiveaccent, sidebar-accent4.28:1, under 4.5:1
GitHub lightdestructivesidebar-accent4.27:1, under 4.5:1
GitHub lightsuccessaccent, sidebar-accent4.02:1, under 4.5:1
GitHub lightwarningaccent, sidebar-accent3.85:1, under 4.5:1
GitHub darkdestructiveaccent, sidebar-accent3.74:1, under 4.5:1
GitHub dark · AMOLEDdestructiveaccent, sidebar-accent4.10:1, under 4.5:1
Catppuccin Lattemuted-foregroundbackground, muted, accent, sidebar, sidebar-accent3.20:1, under 4.5:1
Catppuccin Lattesuccessbackground, popover, accent, sidebar, sidebar-accent2.17:1, under 4.5:1
Catppuccin Lattewarningbackground, popover, accent, sidebar, sidebar-accent1.70:1, under 4.5:1
Catppuccin Lattedestructiveaccent, sidebar, sidebar-accent3.52:1, under 4.5:1
Catppuccin Latteinputbackground, card, popover2.30:1, under 3:1
Catppuccin Latteringbackground, card, popover, muted2.06:1, under 3:1
Catppuccin Lattesidebar-ringsidebar2.62:1, under 3:1
Catppuccin Lattechart-2background2.96:1, under 3:1
Catppuccin Lattechart-3background2.31:1, under 3:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)muted-foregroundbackground, muted, accent, sidebar, sidebar-accent3.16:1, under 4.5:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)successbackground, popover, accent, sidebar, sidebar-accent2.17:1, under 4.5:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)warningbackground, popover, accent, sidebar, sidebar-accent1.70:1, under 4.5:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)destructiveaccent, sidebar, sidebar-accent3.52:1, under 4.5:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)inputbackground, card, popover2.29:1, under 3:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)ringbackground, card, popover, muted2.06:1, under 3:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)sidebar-ringsidebar2.62:1, under 3:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)chart-2background2.96:1, under 3:1
Catppuccin Latte · Mocha (Gray), Frappé (Gray), Macchiato (Gray)chart-3background2.32:1, under 3:1
Catppuccin Mocha · Frappémuted-foregroundmuted, accent, sidebar-accent4.26:1, under 4.5:1
Catppuccin Mocha · Frappédestructiveaccent, sidebar-accent3.57:1, under 4.5:1
Catppuccin Mocha · Frappéinputbackground, card, popover2.87:1, under 3:1
Catppuccin Mocha · Frappé (Gray)muted-foregroundmuted, accent, sidebar-accent4.25:1, under 4.5:1
Catppuccin Mocha · Frappé (Gray)destructiveaccent, sidebar-accent3.56:1, under 4.5:1
Catppuccin Mocha · Frappé (Gray)inputbackground, card, popover2.86:1, under 3:1
Catppuccin Mocha · Frappé · AMOLEDinputbackground, card, popover2.87:1, under 3:1
Catppuccin Mocha · Frappé (Gray) · AMOLEDinputbackground, card, popover2.86:1, under 3:1
Gruvbox lightdestructivesidebar-accent4.10:1, under 4.5:1
Gruvbox lightsuccessaccent, sidebar-accent3.82:1, under 4.5:1
Gruvbox lightwarningaccent, sidebar-accent3.85:1, under 4.5:1
Gruvbox lightmuted-foregroundsidebar-accent4.44:1, under 4.5:1
Gruvbox darkdestructiveaccent, sidebar-accent3.24:1, under 4.5:1
Gruvbox darksuccessaccent, sidebar-accent3.31:1, under 4.5:1
Gruvbox darkwarningaccent, sidebar-accent4.13:1, under 4.5:1
Gruvbox darkmuted-foregroundaccent, sidebar-accent4.15:1, under 4.5:1
Gruvbox dark · AMOLEDdestructiveaccent, sidebar-accent4.24:1, under 4.5:1
Gruvbox dark · AMOLEDsuccessaccent, sidebar-accent4.33:1, under 4.5:1
Prohibitorum lightsuccesssidebar-accent4.22:1, under 4.5:1
Prohibitorum lightwarningsidebar-accent3.96:1, under 4.5:1
Prohibitorum lightmuted-foregroundsidebar-accent4.38:1, under 4.5:1
Prohibitorum lightsidebar-ringsidebar2.48:1, under 3:1
Prohibitorum light · Norddestructivesidebar-accent4.33:1, under 4.5:1
Prohibitorum light · Nordsuccessaccent, sidebar, sidebar-accent3.62:1, under 4.5:1
Prohibitorum light · Sandsuccessaccent, sidebar-accent3.99:1, under 4.5:1
Prohibitorum light · Sandwarningaccent, sidebar-accent3.74:1, under 4.5:1
Prohibitorum light · Sandmuted-foregroundsidebar-accent4.49:1, under 4.5:1
Prohibitorum light · Matchasuccessaccent, sidebar-accent3.89:1, under 4.5:1
Prohibitorum light · Matchawarningaccent, sidebar, sidebar-accent3.64:1, under 4.5:1
Prohibitorum light · Matchamuted-foregroundsidebar-accent4.29:1, under 4.5:1
Prohibitorum light · Sakurasuccessaccent, sidebar-accent3.99:1, under 4.5:1
Prohibitorum light · Sakurawarningaccent, sidebar-accent3.74:1, under 4.5:1
Prohibitorum light · Lavenderdestructivesidebar-accent4.34:1, under 4.5:1
Prohibitorum light · Lavendersuccessaccent, sidebar, sidebar-accent3.63:1, under 4.5:1
Prohibitorum light · Lavendermuted-foregroundsidebar-accent4.23:1, under 4.5:1
Prohibitorum light · Lagoonsuccessaccent, sidebar-accent3.98:1, under 4.5:1
Prohibitorum light · Lagoonwarningaccent, sidebar-accent3.73:1, under 4.5:1
Prohibitorum light · Lagoonmuted-foregroundsidebar-accent4.39:1, under 4.5:1
Prohibitorum light · Citrusprimarybackground, card, accent1.19:1, under 3:1
Prohibitorum light · Citrussuccesssidebar-accent4.06:1, under 4.5:1
Prohibitorum light · Citruswarningaccent, sidebar-accent3.81:1, under 4.5:1
Prohibitorum light · Citruschart-1background1.33:1, under 3:1
Prohibitorum dark · Norddestructiveaccent, sidebar-accent4.50:1, under 4.5:1
Prohibitorum dark · Nordsuccessaccent, sidebar-accent4.45:1, under 4.5:1
Prohibitorum dark · Nordmuted-foregroundaccent, sidebar-accent4.33:1, under 4.5:1
Prohibitorum dark · Matchamuted-foregroundaccent, sidebar-accent4.00:1, under 4.5:1
Prohibitorum dark · Lavenderdestructiveaccent, sidebar-accent4.35:1, under 4.5:1
Dracula darkdestructiveaccent, sidebar-accent3.77:1, under 4.5:1
Nord darkdestructiveaccent, sidebar-accent3.47:1, under 4.5:1
Nord darksuccessaccent, sidebar-accent4.47:1, under 4.5:1
Tokyo Night darkdestructiveaccent, sidebar-accent4.12:1, under 4.5:1
Tokyo Night darkmuted-foregroundaccent, sidebar-accent4.44:1, under 4.5:1
One Dark darkdestructiveaccent, sidebar-accent3.65:1, under 4.5:1
One Dark darkwarningaccent, sidebar-accent3.85:1, under 4.5:1
One Dark darkmuted-foregroundaccent, sidebar-accent4.36:1, under 4.5:1
Monokai darkdestructiveaccent, sidebar-accent3.15:1, under 4.5:1
Monokai darksuccessaccent, sidebar-accent4.22:1, under 4.5:1
Monokai darkmuted-foregroundaccent, sidebar-accent4.47:1, under 4.5:1
Monokai dark · AMOLEDdestructiveaccent, sidebar-accent4.03:1, under 4.5:1
Afterglow darkdestructiveaccent, sidebar-accent3.85:1, under 4.5:1
Afterglow darkmuted-foregroundaccent, sidebar-accent4.43:1, under 4.5:1

A row here is a gap in that palette, not a licence to copy it. A custom theme is held to the same numbers, and the theme editor shows each token's ratio against the surface it is drawn on.

Focus#

Do

Keep the focus ring every @orz/ui control draws on :focus-visible, and give anything else that takes focus the same one.

Don't

Remove the ring because it looks heavy after a click. :focus-visible already leaves it off for a mouse click and shows it for the keyboard.

  • Visible (SC 2.4.7): whatever has keyboard focus shows it. A clickable surface that is not an @orz/ui control is a <button> or <a>, so it takes focus at all, and borrows the focus-visible: classes from Button.
  • Drawn apart from the control (SC 2.4.13): the ring is a 2px ring outline 2px off the control's edge, so the page shows between the two and the ring is measured against the page, never against a filled button that may share its colour. A destructive Button draws it in destructive. Being an outline, not a shadow, it still shows in Windows' contrast themes, which drop shadows.
  • Not hidden (SC 2.4.11, new in 2.2): a sticky header, a toolbar or the on-screen keyboard never covers the focused element entirely. Give a scroller with a sticky header scroll-padding-top of the header's height, so Tab lands clear of it; useScrollInsets does the same for the page's own scrollIntoView calls, and counts the on-screen keyboard.
  • In reading order (SC 2.4.3): Tab follows the DOM, so the DOM follows the layout. No positive tabIndex.
  • Returned. A Dialog, Sheet or menu holds focus while open and gives it back to what opened it on close. When that opener is gone — a menu item that removed its own row, a confirmed delete that took it — send focus to the next meaningful control yourself, as LoadFailure's retryRef exists to; ConfirmDialog's onCloseAutoFocus is the moment for it. A key or a row's own button that removes the row it was on drops the focus the same way. In a list the next meaningful control is the row now in its place, else the one before it, else the empty state that stands in for the emptied list, which takes the focus with tabIndex={-1}. What opened it is the control the reader pressed, focused or not (Safari focuses no button or link it presses), so open one from a control that can take the focus back, a button or a link, never a bare image or div with a click handler.

Keyboard#

Everything a pointer can do, the keyboard can do (SC 2.1.1), and nothing the keyboard enters it cannot leave (SC 2.1.2). The components follow the WAI-ARIA patterns, so an app keeps to these keys and adds no competing ones:

KeyDoes
Tab, Shift+TabMoves between controls, and into and out of a group as one stop
Arrow keysMove within a group: RadioGroup, Tabs, a Toolbar, a menu, Select's list, a Slider
EnterActivates a button or link, submits a form, picks a menu item
SpaceActivates a button, toggles a Checkbox or Switch
EscapeCloses the innermost open overlay, and nothing else; among the toasts, takes the focus back where it was instead
Alt+TMoves the focus to the toasts, over an open overlay too; Tab past them takes it back
/Focuses the page's search (useSlashShortcut) unless shortcuts are turned off; typed as itself inside a field

Touch sizes for the toolbar icons

designreview

Do it without the mouse. Tab reaches the bar once and the arrow keys walk it, and each button's tooltip says what it is. Enter or Space archives, and the button becomes Move to Inbox with the focus still on it. In Labels the arrow keys move, Space ticks a label and leaves the menu open, and Escape closes the menu and nothing else, with the focus back on its button. / here reaches this site's search.

A single-key shortcut that acts can be turned off (SC 2.1.4): speech input types stray single keys, and a stray key that archives, sends or deletes costs the user work. An app with shortcuts like that offers a setting for keyboard shortcuts, and does not mount those bindings while it is off. / alone is the mild case: it only moves focus to the search, so a stray one costs an Escape. WCAG still counts it, and once an app has the setting, useSlashShortcut(onSlash, { enabled }) takes it and binds nothing while it is false. This site's Settings page does exactly this.

Target size#

  • 24 × 24px at least for anything clickable (SC 2.5.8, AA, new in 2.2). A smaller target passes only when a 24px circle on its centre touches no other target.
  • 36 × 36px on touch, around every control and between neighbouring targets. Apple's Human Interface Guidelines give a control 44 × 44pt by default and 28 × 28pt at the least, and count the room between controls as much as their size; SC 2.5.5 (AAA) asks 44 × 44px of every target. @orz/ui takes the room rather than drawing a dense screen larger (Touch & mobile).
  • Drags have a click. Anything done by dragging can also be done with single clicks or taps (SC 2.5.7, AA, new in 2.2): a Slider moves to where its track is clicked, and with the arrow keys; every row of a Reorder has a pair of move buttons beside its handle (Reordering).

On a mouse, @orz/ui's Button is 28px tall and its xs size 22px; a Checkbox and a RadioGroup item are 16px, and a Switch 20px tall. Those three pass by the spacing exception, so keep other targets out of the 24px around them, and pair each with its Label: the words then toggle it too. On a touch screen each control takes a 36px hit area and stands that far from the next; Pointer and Touch above any example on this site show both.

Names and roles#

Like name@example.com.

Clear the email and press Save profile. The error appears beside the field in words, the field is marked invalid and takes the focus, and a screen reader reads the error with the field's name. Fix it and save: the toast that confirms it is announced without moving the focus.

  • Every control has a name a screen reader can announce (SC 4.1.2). A field gets a Label with htmlFor; an icon-only button gets an aria-label, and the same words in a Tooltip for sighted readers. A placeholder is not a name: it is gone once the reader types.
  • The visible words start the name (SC 2.5.3): a button that shows "Save" is not named "Submit form", or a speech user saying "click Save" misses it.
  • Status is announced (SC 4.1.3) without moving focus. toast() goes through the Toaster's live region, and LoadFailure is a role="status"; a message of your own that appears after an action needs one of the two. A FilterMenu, or a submenu with a filter box, says what the typing left once it rests: how many rows, or its empty state's words, or while a loading menu's rows are on their way its loadingLabel.
  • An error says what to fix (SC 3.3.1), in text beside the field, and the field gets aria-invalid, which @orz/ui's inputs draw in red.
  • Structure is markup. Headings are h1–h3 in order, lists are lists, and a table of data is a Table, so a screen reader's headings and table navigation work. A Markdown under the page's own h1, such as an issue's body under its title, takes headingLevel={2}, so the body's # is not a second h1; a document embedded in it moves a level further down by itself.

Motion and zoom#

  • Motion stops on request. Under prefers-reduced-motion, a slide, zoom or parallax is turned off and a fade may stay (SC 2.3.3, AAA, and Apple's HIG). @orz/ui's overlays already do this; motion an app adds is gated as Motion describes.
  • Zoom is the reader's. Never set maximum-scale or user-scalable=no in the viewport tag. Text reaches 200% without loss (SC 1.4.4) and a page works 320px wide without scrolling sideways (SC 1.4.10); a log, a diff or a table may scroll inside its own box.

On each platform#

Pointer and keyboardTouch and screen reader
Moving aroundTab and the arrow keys, with the focus ring showing whereVoiceOver or TalkBack swipes through the page in DOM order
HoverTooltips appear on hover and on focusThere is no hover; a tooltip's words must also be the control's name
Target24px, or the spacing around it36px, and that far apart
Shortcuts/ and the menus' own keysNone; every shortcut has a visible control too

Checking a screen#

  1. Put the mouse away and do the screen's main task with the keyboard alone, watching the focus ring.
  2. Go through the built-in themes, light and dark, and read every word; the contrast table above follows each one.
  3. Zoom to 200%, then narrow the window to 320px.
  4. Turn on VoiceOver or TalkBack and find every control by its name.
  5. On a phone, or with Touch chosen above an example, reach every control with a thumb.

In the demos