# Justified behaviour rules

These are the behaviour rules of Justified by Blackwood & Blake: how forms, buttons, dialogs and other parts of an interface should behave in a shadcn app. Each one was tried against WCAG 2.2 and weighed by established design systems; the verdict says how strongly they agree. Following them helps you work toward WCAG 2.2 AA. It does not make a product compliant on its own and is not a certification.

## How to use this file

- This file holds 79 rules and 23 guidelines, each as one short statement. Keep them in mind whenever you build, change or review interface code.
- Each entry is followed further down by its full rule: Why, Do, Don't and Exceptions. Apply the exceptions only as written.
- Prefer Justified's components where they exist. They already follow the rules. Install them with the shadcn CLI, for example `npx shadcn@latest add https://blackwoodblake.com/design-system/r/field.json`, and the theme with `npx shadcn@latest add https://blackwoodblake.com/design-system/r/justified-theme.json`.
- When you review code, name each rule by its id, for example "FRM-002a".
- Entries marked "proposed" are complete but may still change. The others are decided: what they ask is not expected to change, though their wording may still be made clearer.

## Rules and guidelines

- **A rule that WCAG requires:** follow it. If the person you work for asks for something else, do what they ask, and tell them that a WCAG 2.2 Level AA criterion is involved, by number and name.
- **Any other rule:** follow it. If the person you work for asks for something else, do what they ask, and tell them which rule it departs from and why the rule exists.
- **A guideline:** follow it where the project has no convention of its own. Where the project already does it another way, keep the project's way and say nothing.
- **When two apply:** a rule that WCAG requires comes before other rules, a narrower rule before a wider one, and any rule before a guideline.

Every rule and guideline, with its verdict and the sources behind it: https://blackwoodblake.com/design-system/patterns/

## Rules that WCAG 2.2 AA requires

A WCAG 2.2 Level AA criterion requires the behaviour. Where a rule adds advice of our own, the rule says so.

- **ACT-001b** Give a button that shows no text an accessible name that says what pressing it does, not what its icon pictures. Give a button that shows text an accessible name that contains the visible words in the same order; case and punctuation may differ. Starting the name with the visible text is our advice, not a requirement. Requirement. [Full rule](#act-001b)
- **ACT-006** Make every target that people press with a pointer at least 24 by 24 CSS pixels, or place it so that a circle 24 CSS pixels across, centred on its bounding box, touches no other target and no other small target's circle. Requirement. [Full rule](#act-006)
- **ACT-007a** Anything people can do by dragging on the page can also be done with a single pointer and no dragging, such as buttons, a menu or a field. A keyboard route alone does not count, and the other way may not be a swipe or another gesture that follows a path. Requirement, proposed. [Full rule](#act-007a)
- **ACT-009** Everything people click or tap to go somewhere or to act has a control role in code, such as link or button. Something shown as a link whose only job is to take people to another address has the link role. Requirement, proposed. [Full rule](#act-009)
- **DLG-006** When a modal dialog opens, keyboard focus moves into it. When it closes, focus returns to the control that opened it, or to a logical place nearby if that control is gone. Requirement, proposed. [Full rule](#dlg-006)
- **FBK-004** When a message about a result, a wait, progress or an error appears while focus stays where it is, give it a role or property that lets assistive technology announce it without it taking focus. Our own way, which WCAG does not prescribe, is a polite live region, with role="alert" kept for an error or warning that needs attention now. Requirement. [Full rule](#fbk-004)
- **FRM-007** When a field asks for the person's own details and WCAG 2.2 lists a matching input purpose, give the field the exact `autocomplete` value for that purpose and never remove it. Our own addition, which 1.3.5 does not ask for: never stop the browser or a password manager from filling the field in. Requirement. [Full rule](#frm-007)
- **FRM-008** At every step of signing in, let user name, password and code fields take a pasted value in one go and be filled by the browser or a password manager, ask for selected characters of a secret only if another route needs no such step, and give any other test, such as a CAPTCHA, a route without a test. Requirement. [Full rule](#frm-008)
- **FRM-009** Within one process, when a step needs information the person already entered or the service already showed them, either put it in the field or offer it on the same page to pick, and never make them type it again. Our own addition, which 3.3.7 does not ask for: a value put in the field stays editable. Requirement. [Full rule](#frm-009)
- **FRM-010** Give every form control a name in code that assistive technology can read. When a control has a visible text label, its name contains that text. When a group's options need the group label to make sense, that label can be read in code together with the options. Requirement, proposed. [Full rule](#frm-010)
- **FRM-012a** Changing a control's value, such as choosing an option, ticking a box or typing, does not send a form, open a page, a window or a dialog that takes focus, or move focus, unless text before the control tells people it will. Changes in place, such as a list that filters, are allowed while focus stays put. Requirement, proposed. [Full rule](#frm-012a)
- **FRM-013** When a control receives focus, by Tab, a click or a script, that alone never sends a form, opens a page, a window or a dialog that takes focus, or moves focus to another control. A notice before the control does not change this. Content that appears beside the control and leaves focus in it is allowed. Requirement, proposed. [Full rule](#frm-013)
- **KBD-001** Everything a person can do with a pointer can also be done with the keyboard alone, unless the task depends on the path of the movement; and whenever an element has keyboard focus, a visible indicator marks it for as long as it has focus. Requirement. [Full rule](#kbd-001)
- **KBD-002** When an element has keyboard focus, at least part of it stays in view: no sticky header or footer, toast, cookie banner, chat button or panel that the page put on screen may cover it completely. Requirement. [Full rule](#kbd-002)
- **KBD-003** When the page reacts to a shortcut made only of character keys (letters, digits, punctuation or symbols, with or without Shift), people can turn it off or change it to include a key that types nothing, such as Ctrl, Alt or Cmd, unless it works only while its own control has focus. Requirement, proposed. [Full rule](#kbd-003)
- **LAY-001** When the viewport is 320 CSS pixels wide, every piece of content and every function is still there. Nothing needs scrolling in two directions to be read or used, except a part that needs two dimensions to be understood or used, such as a data table or a map. Requirement. [Full rule](#lay-001)
- **LAY-002** Where the order of content carries meaning or affects how it is used, the order in the code, which screen readers read and the keyboard follows, tells the same story as the order on screen, and layout tools such as grid placement or the order property never rearrange that content so the two disagree. Requirement. [Full rule](#lay-002)
- **LAY-003a** Text, also in controls and labels, can be enlarged to 200 percent without losing content or function: nothing is cut off, laid over other content or stops working. Do not switch off zoom or cap it below 200 percent in the viewport setting, and size no text in viewport units alone. Requirement, proposed. [Full rule](#lay-003a)
- **LAY-003b** When a person sets line height to 1.5 times the font size, space after paragraphs to 2 times, letter spacing to 0.12 times and word spacing to 0.16 times, no text is cut off, hidden or laid over other content, and every function still works. The page need not use these values itself. Requirement, proposed. [Full rule](#lay-003b)
- **NAV-002a** When a navigation menu shows which item is the page the person is on, the code or the text says so too, so a screen reader announces that item as the current page. The usual way is `aria-current="page"` on its link. Requirement, proposed. [Full rule](#nav-002a)
- **NAV-003** Navigation that repeats on several pages of a product, such as a top bar, a sidebar or a row of footer links, lists its items in the same relative order on every page, unless the person changed the order themselves. Requirement, proposed. [Full rule](#nav-003)
- **STA-004** When the product sets a time limit that can end a person's chance to act or throw away their work, let them turn it off, lengthen it, or extend it after a warning, unless an exception applies. Each option meets 2.2.1 only with the conditions listed for it first under Do. Our advice is to prefer them in that order. Requirement. [Full rule](#sta-004)
- **STR-001** Give every page a title, in the `title` element, that says what the page holds or is for. In a single page app, set a new title on every route change, so the title names the view now shown, not only the app. Requirement, proposed. [Full rule](#str-001)
- **STR-002a** When text heads a part of the view, such as a section, a card, a panel or a dialog, mark it as a heading in code, not only with bold or large type. Requirement, proposed. [Full rule](#str-002a)
- **STR-002b** Word every heading so it says what the part below it holds or is for. A heading that would fit any part of any page, such as "Details" or "Section 2", does not. Requirement, proposed. [Full rule](#str-002b)
- **STR-005** Give an image or icon that carries information a text alternative that says what it tells the person in that place, never a file name or a word that only names the kind of picture. Hide one that only decorates from assistive technology, with `alt=""` on an `img` or `aria-hidden="true"` on an icon. Requirement, proposed. [Full rule](#str-005)
- **STR-006** Put a `lang` attribute on the `html` element whose value is a valid language tag for the language most of the page is written in. When the interface switches to another language without loading a new page, change the attribute to that language at the same time. Requirement, proposed. [Full rule](#str-006)
- **STR-006a** When a passage, phrase or word is in another language than the text around it, put `lang` with that language's tag on the element that holds it, such as language picker entries written in their own languages. Proper names, technical terms, words of unclear language and words the surrounding language has taken in need none. Requirement, proposed. [Full rule](#str-006a)
- **TBL-001** When values are shown in rows and columns under headings, build them as a table in code. Mark each heading cell as the header of its column or row, so assistive technology can tell which headings every value belongs to. Requirement, proposed. [Full rule](#tbl-001)
- **TBL-002** When a column's header sorts the table, make the sort a button or link inside the header cell that works from the keyboard. Expose the sorted column's order in code, ascending or descending, so the direction is never shown by an arrow icon alone. Requirement, proposed. [Full rule](#tbl-002)
- **TBL-003** Give every action a table row offers its own control the keyboard reaches, such as a link, a button or a menu item. A click on the row may be a shortcut, never the only way. An action hidden until the pointer hovers the row is visible whenever it has focus. Requirement, proposed. [Full rule](#tbl-003)
- **TXT-002a** Content that appears on hover or keyboard focus can be closed without moving the pointer or focus, usually with Escape. If hover opens it, the pointer can move onto it without it closing. It stays until the hover or focus that opened it ends, the person closes it, or it is no longer true. Requirement. [Full rule](#txt-002a)
- **TXT-003** Let people tell where each link goes or what it opens from its visible text, its accessible name, or its text with the list item, table cell, paragraph or sentence around it; an added name keeps the visible words. A vague phrase with nothing around it naming the destination is not enough. Requirement. [Full rule](#txt-003)
- **VIS-001** Text people need to read reaches 4.5:1 against the colour it is drawn on, or 3:1 when it is large. Measure after opacity, tints, overlays and images have done their work, in every state. Text in an inactive control, decoration and logos are exempt; see Exceptions. Requirement, proposed. [Full rule](#vis-001)
- **VIS-003a** Never let colour be the only sign of what something means or which state it is in, such as a status, an error or a selection. Add text, an icon, a shape or a pattern. A lightness difference of 3:1 counts too, except where people must know what a particular colour means. Requirement, proposed. [Full rule](#vis-003a)
- **VIS-003b** A link in running text stands out from the words around it at rest, not only on hover or focus: by a cue that is not colour, such as an underline, or by 3:1 lightness against the surrounding text. Justified's tokens close the 3:1 route, so a cue is needed; our own choice is an underline. Requirement, proposed. [Full rule](#vis-003b)
- **VIS-004** The parts people need to see to find a control and tell its state, and the parts of a graphic they need to understand it, reach 3:1 against the colours next to them. Inactive controls, decoration and graphics whose information is also given in text are exempt. Requirement, proposed. [Full rule](#vis-004)
- **VIS-005** When something starts by itself and shares the screen with other content, give a way to pause, stop or hide it if it moves, blinks or scrolls for more than five seconds. If it updates by itself, such as an auto-playing carousel, give that way, or a way to set how often, at any length. Essential motion is exempt. Requirement, proposed. [Full rule](#vis-005)
- **VIS-008a** When a control shows a state, such as on or off, selected, checked, expanded or unavailable, that state is also set in code on the control itself. Whenever the look changes, the state in code changes with it. Requirement, proposed. [Full rule](#vis-008a)

## Rules the judges decide

No WCAG criterion requires these. Most or all of the design systems that addressed the question support them.

- **ACT-001a** Start the label of every button that performs, confirms or commits an action with a verb naming that action. Add the object unless the verb and its context say what it acts on; where the verb repeats or space is tight, it may go in the accessible name instead (ACT-001b). Never use OK, Yes, No, Submit or a noun alone. Unanimous (3 of 3). [Full rule](#act-001a)
- **ACT-002a** Among the buttons shown together for one task or decision, such as the action row of a form, dialog, sheet or card, give at most one the most emphasised style, for the action most people want there, and give every other button a less emphasised style; a group may have no emphasised button at all. Unanimous (3 of 3). [Full rule](#act-002a)
- **ACT-002b** Give a page at most one button in the most emphasised style, `default` or `destructive`, for the main task of the page; a dialog, sheet or side panel counts as its own page while it is open, and the actions of other sections, cards and smaller tasks use less emphasised styles. Majority (2 of 3). [Full rule](#act-002b)
- **ACT-003a** When a dialog's action buttons sit side by side, put the confirming or primary button last, at the trailing end of the row (the right in left-to-right languages, the left in right-to-left), with Cancel or the other dismissive action before it and no action button after it. Unanimous (3 of 3). [Full rule](#act-003a)
- **ACT-003b** On a page, put a button that acts on one part inside that part, and a button that acts on the whole page in the page's own header, action bar or floating button. Give the same task the same area and position on every page at a given window size. Unanimous (3 of 3). [Full rule](#act-003b)
- **ACT-005** When a button that submits or continues a form is unavailable because required input is missing, show visible text directly before the button in reading order that says what the person must still do to make it work, and make that text readable without focusing the button. A required value that is filled in but not valid counts as missing. Unanimous (2 of 2). [Full rule](#act-005)
- **ACT-008** While something is being dragged, mark on screen the place that would receive it if it were let go now. Remove the mark as soon as the dragged thing leaves that place, is dropped or the drag is cancelled. Unanimous (2 of 2), proposed. [Full rule](#act-008)
- **DLG-001** In a dialog that has a dismissive action, which is Cancel, Close, a close icon or, where none of those exists, the button that leaves everything as it is, pressing Escape does exactly what that action does, including any check before unsaved input is thrown away, and never confirms, submits or runs the destructive or default action. Unanimous (3 of 3). [Full rule](#dlg-001)
- **DLG-002** Never open a dialog on top of another dialog. Show any further step, including a question about discarding typed input, by replacing the open dialog's content, and a failed main action as a notice inside it, or close the dialog and move the work to a page. Only a full-screen dialog may have a short confirmation or alert on top. Unanimous (2 of 2). [Full rule](#dlg-002)
- **DLG-003** In a dialog that asks the person to confirm a destructive action, label the button that performs it with a verb that names that action, never "OK", "Yes" or another word that does not say what will happen, and always include a button labelled Cancel that is enabled and closes the dialog with nothing changed. Unanimous (3 of 3). [Full rule](#dlg-003)
- **DLG-007** While a modal dialog is open, Tab and Shift+Tab stay within it, and nothing behind it can be used until it closes. Unanimous (2 of 2), proposed. [Full rule](#dlg-007)
- **DST-001a** Make destructive and other significant actions reversible wherever the product can, and when an action can be fully reversed, carry it out at once and offer Undo right after it. DST-001b decides when a question is still needed; it never is for a routine action that Undo fully reverses. Unanimous (2 of 2). [Full rule](#dst-001a)
- **DST-001b** Ask the person to confirm a step only when it cannot be reversed and destroys, spends or commits something of value, or when a mistake would cost a lot and be hard to put right, such as a charge to a card; never ask before any other step. Unanimous (3 of 3). [Full rule](#dst-001b)
- **FBK-002** When an action fails for a reason not tied to one field or group of inputs, show the failure as text in the area where it started. Keep it there until the person closes it, a retry succeeds or they leave the view, and never let a self-closing message carry it alone. Unanimous (3 of 3). [Full rule](#fbk-002)
- **FBK-003** After an action succeeds, the item or value it changed shows its new state in the view. If the result has no place in the view, leave a lasting sign near the control or somewhere the person can return to. A toast that closes by itself is never the only sign. Unanimous (3 of 3). [Full rule](#fbk-003)
- **FBK-005** A toast or snackbar holds at most one action button besides its close control. While it holds one, it stays until the person uses it, closes it or leaves the view, or a newer message makes it moot. Its action can also be done from a place that lasts. Unanimous (2 of 2). [Full rule](#fbk-005)
- **FRM-001** Give every form control a label that people can see at the control, beside it, above it or on its border, before, while and after they fill it in, and never let placeholder text stand in for that label. Majority (2 of 3). [Full rule](#frm-001)
- **FRM-002a** When a field or a group of inputs has an invalid value, show the error as visible text at that field, and never only in a banner, a dialog or a tooltip somewhere else. Unanimous (2 of 2). [Full rule](#frm-002a)
- **FRM-002b** Show a new error on a field only when the person leaves it after changing it or sends the form, never while they type; recheck an error that is already shown on every change and remove it as soon as the value is valid. Unanimous (2 of 2). [Full rule](#frm-002b)
- **FRM-003** Every form in a dialog, sheet or other modal view has a visible Cancel button that is always enabled, is never blocked by field errors, sends nothing and leaves everything as it was before the form opened. Unanimous (3 of 3). [Full rule](#frm-003)
- **FRM-004a** When closing a full-screen dialog would throw away changes the person has not saved, ask first, whichever way they close it, with *Cancel* to keep everything and a button that names the discard; when nothing would be lost, close at once. Unanimous (2 of 2). [Full rule](#frm-004a)
- **FRM-005** When a form marks required or optional fields, give every field of the same status the same marker, put it in the visible label or the group's legend as part of the accessible name, and explain a symbol in visible text no later than the first marked field. Unanimous (2 of 2). [Full rule](#frm-005)
- **FRM-012b** A control that holds a choice, such as a select, radio group, checkbox, switch or filter chip, only records it and may update the view in place. Going to another page or step, sending a form or running a command takes a button, a link or a menu of actions, even with a notice. Majority (2 of 3), proposed. [Full rule](#frm-012b)
- **FRM-015** In a form, pressing Enter in a single-line field, such as a text, email, number or search input, sends the form, the same as pressing its main button. Unanimous (3 of 3), proposed. [Full rule](#frm-015)
- **FRM-016a** When a checkbox or a radio button shows its own text beside it, a click, tap or pen press on that text checks or unchecks the checkbox, or selects the radio button, exactly as a press on the box or circle does. Unanimous (2 of 2), proposed. [Full rule](#frm-016a)
- **KBD-003a** Every keyboard shortcut the product adds can be found inside the product: shown beside the command it triggers, such as in a menu item or tooltip, or listed with the others in one place, such as a shortcuts dialog or help page. Unanimous (2 of 2), proposed. [Full rule](#kbd-003a)
- **KBD-003b** A keyboard shortcut the product adds includes a modifier key (Ctrl, Alt or Cmd) or Shift by default. A single key, such as `n` or `/`, works as a shortcut only after the person turns such shortcuts on, or only while its own control has focus. Unanimous (2 of 2), proposed. [Full rule](#kbd-003b)
- **NAV-002b** A navigation menu that repeats across pages marks the item for the page or section the person is in, and only that item. The mark does not rest on colour alone: use heavier text, a filled icon, a shape behind the item or a bar beside it. Unanimous (2 of 2), proposed. [Full rule](#nav-002b)
- **STA-001** When content in one part of a view loads, show the wait in that part, at the control that started it or as a small indicator where the content will appear, never as a layer over the whole page, and keep the rest of the view usable. Unanimous (3 of 3). [Full rule](#sta-001)
- **STA-002a** When a list, table, panel or page has finished loading and holds nothing yet, show a short message in that space that says what will appear there. When the person can add the first item, offer that action as one button or link with the message. Unanimous (2 of 2), proposed. [Full rule](#sta-002a)
- **STA-002b** While a list, table or panel is still fetching its content, show that it is loading, never that it is empty. Show the message that there is nothing only after the fetch has finished and returned no items. Unanimous (2 of 2), proposed. [Full rule](#sta-002b)
- **STA-005a** When a button sends, saves or deletes something and the reply does not come at once, show that the action is under way until the reply comes. Unanimous (3 of 3), proposed. [Full rule](#sta-005a)
- **STR-004** Build the page's regions from landmark elements: the main content in `main`, the top bar in `header`, each group of navigation links in `nav` and the bottom bar in `footer`. When a page has more than one `nav`, give each a name that tells them apart. Unanimous (2 of 2), proposed. [Full rule](#str-004)
- **TXT-001a** Every message about a problem says in plain words what went wrong, names the thing it concerns by the name the person sees, and gives a next step: the fix when it is known, otherwise a retry, a wait or where to get help. Unanimous (3 of 3). [Full rule](#txt-001a)
- **TXT-002b** A tooltip opens when its trigger gets keyboard focus, not only when the pointer rests on it. It holds only extra help. Anything the person needs to finish the task is visible on the page without hovering or focusing. Unanimous (2 of 2). [Full rule](#txt-002b)
- **VIS-002** Use a `*-foreground` token only on its own fill, `border-input` for the edges of controls, and a state colour such as `ring`, `destructive` or `accent` only for its state. Never use raw palette classes such as `text-gray-500` for something that carries meaning. Unanimous (3 of 3), proposed. [Full rule](#vis-002)
- **VIS-006** When the person's device or browser asks for reduced motion, replace movement across the screen, such as sliding, zooming, scaling, parallax and bouncing, with a short fade or an instant change. Stop motion that only decorates and show its final state. Keep motion that is essential. Unanimous (3 of 3), proposed. [Full rule](#vis-006)
- **VIS-007** Never let an animation be the only way the interface says something. Whatever it means, such as an error, a change, a new item or that something is live, is also shown in text, an icon or a state that stays on screen when the motion has ended or is turned off. Unanimous (2 of 2), proposed. [Full rule](#vis-007)
- **VIS-008** Everything that does something when pressed, including a clickable card, row or list item, changes its look while it is pressed and, where the pointer can hover, while the pointer is over it. A control that is off shows neither change. Unanimous (3 of 3), proposed. [Full rule](#vis-008)
- **VIS-008b** A state that lasts, such as selected, checked, on or current, stays visible while the same item is also hovered, focused or pressed. The look of hover, focus or press is never the same as the look of a state that lasts. Unanimous (3 of 3), proposed. [Full rule](#vis-008b)

## Guidelines, our choice

The design systems are divided, or fewer than two have addressed the question. We chose, and each guideline gives our reasons. A product that chooses otherwise is not wrong.

- **ACT-004** On a form that does not fit on one screen at the smallest screen size the product supports, without the on-screen keyboard, keep the submit button enabled until the form is sent. A Next or Continue button on a step of a multi-step form counts as the submit button for that step. Split (1 of 2). [Full rule](#act-004)
- **ACT-007b** When an item can be moved with the keyboard, tell assistive technology in words when it is picked up, where it is after each step, and where it was dropped or that the move was cancelled, using its visible label and positions such as "2 of 5". Insufficient evidence (0 of 3 judges spoke), proposed. [Full rule](#act-007b)
- **ACT-009a** When a control not shown as a link only takes people to another address, such as a page or a spot on a page, build it as a link in code, not as a button that changes the address by script. A control that acts and then moves on stays a button. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#act-009a)
- **ACT-009b** A control that acts where the person is, such as saving, deleting, switching something or opening a dialog or menu, is a button in code, also when it is styled as a link. Do not build it as an `<a>` with `href="#"` or `javascript:void(0)`, or as a link whose click is cancelled by script. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#act-009b)
- **DLG-004** In a dialog that asks the person to confirm a destructive action, put initial focus on the Cancel button, never on the destructive button, and never let Enter run the destructive action unless the person has moved focus to that button. Split (1 of 2). [Full rule](#dlg-004)
- **DLG-005** In a dialog that asks the person to confirm a destructive action, give the destructive button the danger style, even when the person has just asked for that action. Its label still names the action, as DLG-003 says, so colour is never the only sign of danger. Split (1 of 2). [Full rule](#dlg-005)
- **FRM-004b** When closing a dialog or sheet that does not fill the screen would throw away changes the person has not saved, ask first, whichever way they close it. The question offers *Cancel*, which keeps everything, and a button that names the discard. When nothing would be lost, close at once. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-004b)
- **FRM-004c** When leaving a page would throw away unsaved form changes, ask first, by every route out: inside the product with *Cancel* to stay and a button naming the discard, and on closing or reloading the tab with the browser's own prompt. When nothing would be lost, leave at once. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-004c)
- **FRM-004d** On a page form with a multi-line text field, more than one step, or five or more controls, a radio or tick-box group counting as one, keep what the person enters when they leave: save each change or keep a draft to return to. Show near the form that it is kept. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-004d)
- **FRM-011** When a form is sent and problems are found at its fields, in the browser or by the server, move focus to the first field with a problem, or to a summary above the form that links to each problem. This holds for every form: short or long, page or dialog, and each step of a multi-step form. Insufficient evidence (0 of 3 judges spoke), proposed. [Full rule](#frm-011)
- **FRM-014** Give a field that asks only for an email address `type="email"`, a field for a phone number `type="tel"` and a field for a web address `type="url"`. A phone or tablet then shows a keyboard with the keys that value needs. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-014)
- **FRM-014a** When a text field takes a value made of digits only, other than a phone number, give it `inputMode="numeric"`. When it takes an amount or measurement with a decimal part, give it `inputMode="decimal"`. A phone or tablet then shows a digit keypad. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-014a)
- **FRM-014b** Put a string of digits that is not a quantity, such as a one-time code, a card number, an account number, a phone number or a postcode, in a text input: `type="text"`, or `type="tel"` for a phone number. Never put it in `type="number"`. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-014b)
- **FRM-016b** When a switch shows its own text beside it, a click, tap or pen press on that text turns the switch on or off exactly as a press on the switch does. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-016b)
- **FRM-017** Outside sign-in, which FRM-008 covers, let every text field and text area take a pasted value. Never block a paste, and never cut or drop pasted characters without saying so. Removing separators from the value that is checked, as FRM-017a describes, is not such a change. Insufficient evidence (0 of 3 judges spoke), proposed. [Full rule](#frm-017)
- **FRM-017a** When a field takes a number or code people write in several ways, such as a phone or card number, accept the spaces, hyphens, brackets, dots and letter case they type or paste, and remove them before checking. Insufficient evidence (0 of 3 judges spoke), proposed. [Full rule](#frm-017a)
- **FRM-017b** When a free-text field limits how many characters or words it takes, state the limit in its label or hint and show how much is used in a count that is tied to the field in code. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-017b)
- **FRM-017c** When a free-text field limits how many characters or words it takes, say in words when people reach or pass the limit. Never stop or cut typed or pasted text without saying so. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#frm-017c)
- **NAV-004** When a header or sidebar with links comes before a page's main content, make a skip link the first thing Tab reaches. It is visible while it has focus, and it moves focus to the start of the main content. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#nav-004)
- **STA-003** When a search or filter matches nothing, say in the results space that nothing matched, and offer a way to change or clear the search or the filters. Our own choice: name what was searched for or filtered by, and keep the query and the filters in place, ready to edit. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#sta-003)
- **STA-005b** While an action is being sent, another press on the same button does not send it again, whether it comes as a click, a tap, Enter or Space. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#sta-005b)
- **STR-003** Give each view one `h1` that names its main content. Give every other heading the level its place in the outline gives it: one below the heading it belongs under. Going down never skips a level; going back up may skip as many as needed. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#str-003)
- **TBL-004** Give every data table a visible title that says what its rows have in common. Tie that title to the table in code, as its `caption` or through `aria-labelledby`. Insufficient evidence (1 of 3 judges spoke), proposed. [Full rule](#tbl-004)

<a id="act-001a"></a>

## ACT-001a Start an action button with a verb that names the action

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/act-001a/

### Rule

Start the label of every button that performs, confirms or commits an action with a verb naming that action. Add the object unless the verb and its context say what it acts on; where the verb repeats or space is tight, it may go in the accessible name instead (ACT-001b). Never use OK, Yes, No, Submit or a noun alone.

### Why

A button is a promise about what happens next. When its text names the action, the person can decide from the button alone, without reading the question again and working out what "Yes" would mean. People who move fast, people who read a second language and people who jump between buttons with a screen reader all depend on that. A verb up front says it is something you do. The object says what it is done to, which matters when the same screen holds several actions. Clear labels help meet [WCAG 2.2, 2.4.6 Headings and Labels](https://www.w3.org/TR/WCAG22/#headings-and-labels). That criterion asks that labels describe their purpose. It does not ask for a verb or rule out any word, so the verb-first form is our own choice. What the button's accessible name must contain is covered by ACT-001b.

### Do

- A dialog titled "Book a dentist appointment?" has *Cancel* and *Book appointment*.
- A report page has *Export report* next to *Print summary*. Each says what it does and to what.
- The context is what the verb is read with: the dialog title, a nearby heading, or the row, card or toolbar the button sits in. When that does not say what the verb acts on, add the object.
- A dialog titled "Invite people to the Spring Fair project" has a field for an email address and the button *Invite*. The title gives the object, so the verb is enough.
- A settings page has *Publish changes* at the bottom, not *Submit*.
- Where the same short verb repeats on a page, such as *Archive* on each row of a list, keep the visible word and add the row's name to the accessible name, as ACT-001b describes: "Archive Invoice 1042".
- A toggle on a project page names what pressing it will do now: *Follow project* while the person does not follow it, *Unfollow project* while they do.
- Keep the verb on a destructive button that DLG-003 and DLG-005 already ask for, and keep the same verb in the dialog's title.

### Don't

- Ask "Do you want to book this time?" with *Yes* and *No*.
- Close a form for a new invoice with *Submit* or *OK* when *Create invoice* would say what happens.
- Put a noun alone on an action, such as *Report* for a button that exports the report, or *Settings* for one that applies new settings.
- Use a vague verb such as *Manage* where *Connect bank account* says what will happen.
- Label the confirming button of a dialog *Confirm*, or put *Continue* on a button that commits something, such as placing an order. Name the action, as DLG-003 does: *Place order*.

### Exceptions

- **Cancel.** *Cancel* stays the word for backing out, as FRM-003 and DLG-003 require.
- **Fixed single verbs.** *Close*, *Done*, *Next*, *Continue*, *Back* and *Undo* need no object when the context gives it, such as *Next* on a step of a form (see ACT-004) or *Undo* in the message after an action (see DST-001a). Prefer a more specific label where it fits. These words never replace the verb on a button that saves, sends, creates or removes something. *Done* and *Close* only end a flow whose work is already kept, or close a view where nothing new is committed. *Close* is never the way out when input is thrown away; that is *Cancel*, as FRM-003 says.
- **A message that asks nothing.** The lone button of a message that only informs may read *OK* or, better, *Done*. A failure the person can act on is not such a message; FBK-002 covers it.
- **Date and time pickers.** The button that confirms the chosen date or time in a picker may read *OK*.
- **Links that look like buttons.** A link styled as a button, such as `Button asChild` around a `Link`, names where it goes, as TXT-003 asks, and needs no verb (ACT-009a).

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Button` or `AlertDialogAction` whose visible text is only "OK", "Yes", "No" or "Submit". Leave alone the lone button of a message that only informs, and the button that confirms a date or time picker (see Exceptions).
- A button labelled with a noun alone, such as "Report" or "Settings", or a vague verb such as "Manage" or "Confirm", on an action that does something. Leave alone a `Button asChild` around a link (see Exceptions).
- A button that saves, sends, creates or removes something labelled "Continue", "Done", "Close" or "Next". Those words are fine only where nothing new is committed or the work is already kept (see Exceptions).
- Read each action button with its dialog title, heading, row or card: does the label start with a verb, and does the label or that context say what it acts on? On repeated row buttons the object may sit in the accessible name.

<a id="act-001b"></a>

## ACT-001b Give every button an accessible name that says what it does and contains its visible text

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/act-001b/

### Rule

Give a button that shows no text an accessible name that says what pressing it does, not what its icon pictures. Give a button that shows text an accessible name that contains the visible words in the same order; case and punctuation may differ. Starting the name with the visible text is our advice, not a requirement.

### Why

A screen reader reads the name, not the picture. An icon of a bin, a gear or three dots means nothing unless the name says what happens: "Remove attachment" tells the person what they are about to do, while "Bin" only describes a drawing. People who use speech control do the opposite. They say the word they see on the screen, and the button only answers if its name contains that word. A name that differs from the visible text breaks this, which often happens when an `aria-label` replaces the text on screen.

These are requirements. [WCAG 2.2, 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG22/#non-text-content) asks that a control shown without text gets a name telling what it is for. [2.5.3 Label in Name](https://www.w3.org/TR/WCAG22/#label-in-name) asks that a control whose label includes text has that text in its name. Case and most punctuation do not count. [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that every button has a name that software can read. Putting the visible text first is advice: it makes speech commands and the screen reader's version match from the first word.

### Do

- An icon button with a bin on an attachment row has the name "Remove attachment".
- An icon button with three dots on a project card has the name "More actions for Spring Fair".
- A button that shows *Archive* on each row of an invoice list has the name "Archive Invoice 1042". The visible word comes first, and the name adds the row.
- A button that shows *Try again* after a failed upload keeps that text as its name, or starts with it: "Try again, upload contract.pdf".
- A button that shows the letters *A+* to make the text larger has the name "Larger text", because the letters stand for a function, not a word.
- In shadcn, give an icon-only `Button` an `aria-label`, or put the name in a visually hidden `span` inside it. Leave the visible text as the name for a button that has one.

### Don't

- Name an icon button after its picture, such as "Gear" for a button that opens account settings.
- Leave an icon button with no name, so a screen reader says only "button".
- Give a button that shows *Continue* the `aria-label` "Go to payment", so the word on screen is not in the name and a speech command for it does nothing.
- Count on a tooltip to give the name. A tooltip may help sighted users, but whether it is read as the name depends on how it is built. Set the name on the button itself.
- Add the role to the name, such as "Remove attachment button". The screen reader already says it is a button.

### Exceptions

- **Text used as a symbol.** When the visible characters stand for a function rather than spell a word, such as *A+* or an *@* that is named "Mention a colleague", name the function. 2.5.3 does not treat such text as a label.
- **Decorative icons beside text.** An icon next to a visible word adds nothing to the name. Hide it from assistive technology, and let the word be the name.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Button size="icon"`, or a `button` whose only child is an icon such as a lucide-react component, with no `aria-label`, `aria-labelledby` or `title` and no visually hidden text such as `<span className="sr-only">` inside it.
- A button with visible text and an `aria-label` that does not contain that text in the same order, such as `aria-label="Go to payment"` on a button showing "Continue". Leave alone text that stands for a function, such as "A+" (see Exceptions).
- An icon button named after its picture, such as "Gear", "Bin" or "Three dots", or with the role in its name, such as "Remove attachment button", instead of what pressing it does.
- An icon button whose only name comes from a wrapping `Tooltip` or its `TooltipContent`, with nothing set on the button itself.
- An icon beside visible text that carries its own `aria-label` or `<title>` and has no `aria-hidden="true"`, so its words join the button's name.

<a id="act-002a"></a>

## ACT-002a Give at most one button in a group the most emphasised style

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/act-002a/

### Rule

Among the buttons shown together for one task or decision, such as the action row of a form, dialog, sheet or card, give at most one the most emphasised style, for the action most people want there, and give every other button a less emphasised style; a group may have no emphasised button at all.

### Why

A filled button tells the eye where to go first. When two buttons in the same row are both filled, that signal cancels out, and the person has to read every label and weigh them before they can act. One strong button and quieter ones around it make the likely next step plain at a glance, while the other choices stay easy to find. This rule is about how buttons look. It does not decide which button has focus or what Enter does; for destructive confirmations DLG-004 decides that. No WCAG criterion asks for one emphasised button, so this rule is our choice.

### Do

- A form *Book an appointment* ends with *Book appointment* in `variant="default"` and *Cancel* in `variant="outline"`.
- A dialog *Rename folder* has *Save name* in `variant="default"` and *Cancel* in `variant="ghost"`.
- A card *Monthly report, October* has *Open report* in `variant="secondary"` and *Download PDF* in `variant="ghost"`. Neither uses the most emphasised style.
- A confirmation "Delete the project Autumn 2026?" has *Delete project* in `variant="destructive"` and *Cancel* in `variant="outline"`. The red button is that dialog's one emphasised button, as DLG-005 says.
- A form *Edit contact* has *Save contact* in `variant="default"`. *Delete contact* sits in the same row in `variant="outline"`, with a label that names what it removes. Pressing it removes the contact at once and offers *Undo*, with no question, as DST-001a says.
- A sheet asks "Which copy do you want to keep?" with *Keep the new one* and *Keep the old one*. Neither is clearly the main choice, so both use `variant="outline"`.

### Don't

- Put *Save contact* in `variant="default"` and *Delete contact* in `variant="destructive"` side by side. Justified's `Button` has no quieter danger variant, so pick a less emphasised style for the delete action or move it out of the group.
- Fill *Cancel* as well as *Delete project* in a confirmation, or fill *Cancel* instead, to steer people away from deleting.
- Force a filled button onto a group where no action is clearly the main one.
- End the form *Book an appointment* with both *Book appointment* and *Book and pay now* in `variant="default"`.

### Exceptions

- **No clear main action.** A group may have no emphasised button. This rule sets a limit, never a minimum.
- **Focus and Enter.** Which button takes focus first and what Enter does are outside this rule. DLG-004 covers destructive confirmations, and FRM-015 what Enter does in a form.
- **The whole page.** How many primary buttons a page may hold is covered by ACT-002b. That rule is the stricter one: a page that follows it also follows this rule, except in the product's top bar. They are two rules because their verdicts differ.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Two or more `Button`s or `AlertDialogAction`s in one action row, such as a `DialogFooter`, `AlertDialogFooter`, `CardFooter` or a form's button `div`, with `variant="default"` or `variant="destructive"`. No `variant` counts as `default`. Skip buttons in branches of a condition that never show together.
- `variant="destructive"` on a remove action beside a `variant="default"` save action in the same row, such as "Delete contact" next to "Save contact".
- A "Cancel" button that is the one filled button in a confirmation, such as a `Button` with no `variant` inside `DialogClose`, while the main action is quieter. Ask whether backing out is really what most people want there. A row with no emphasised button is fine.

<a id="act-002b"></a>

## ACT-002b Use at most one primary button on a page

Rule. Verdict: Majority (2 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/act-002b/

### Rule

Give a page at most one button in the most emphasised style, `default` or `destructive`, for the main task of the page; a dialog, sheet or side panel counts as its own page while it is open, and the actions of other sections, cards and smaller tasks use less emphasised styles.

### Why

A page usually exists for one main task. When that task's button is the only filled one, people find the way forward without reading the whole page. Each extra filled button pulls the eye away from it, and with three or four the page no longer says what comes next. Quieter styles for the smaller tasks keep them available without competing. This rule is about how buttons look, not about focus or Enter. No WCAG criterion asks for one primary button per page, so this rule is our choice.

### Our reasons

Most of the judges back this rule, and one disagrees. We keep the limit at one, for three reasons.

- **The signal stays sharp.** Two filled buttons on a page already ask the person to compare them. One leaves no doubt about the main task.
- **A second task often means a second page.** When two actions both feel like the main one, the page is often doing two jobs. Splitting it, or moving one task into a dialog, usually helps more than a second filled button.
- **Dialogs and panels have their own.** A dialog, sheet or side panel gets its own primary button, so the limit does not stop a focused sub-task from having a clear way forward.

### Do

- A page *My profile* has *Save profile* in `variant="default"`. The section *Change password* below has *Change password* in `variant="outline"`, and a card *Export your data* has *Export* in `variant="ghost"`.
- A list page *Members* has *Invite member* in `variant="default"`. Each row's *Edit* uses `variant="ghost"`.
- Pressing *Invite member* opens a dialog. Its *Send invitation* is filled, because the dialog counts as its own page while it is open.
- A side panel *Filter* has *Show results* in `variant="default"` while the page behind it keeps its own primary button.
- A settings page where no task is the main one has no button in the most emphasised style. Each section uses `variant="outline"` or `variant="secondary"`.

### Don't

- Give every section of *Settings* its own filled *Save* button.
- Put a filled *Try it free* in a banner above a page whose main task is *Place order*, which is also filled.
- Give every card in a grid of offers a filled *Choose* button. Use a quieter style, or make the cards themselves the choice.
- Put a filled `variant="destructive"` *Delete list* beside the page's filled *Save list*. A destructive button counts toward the limit. Only a page made for the deletion, such as *Clear old logs*, may use it as its one emphasised button.

### Exceptions

- **Dialogs, sheets and side panels.** Each one counts as its own page while it is open.
- **The product's top bar.** A bar shown on every page, such as one with *Sign in*, counts on its own and does not take the page's one most emphasised button.
- **No main task.** A page may have no button in the most emphasised style. This rule sets a limit, never a minimum.
- **Within a group.** How the buttons shown together for one task or decision relate to each other is covered by ACT-002a. A page that follows this rule also follows ACT-002a, except in the product's top bar. They are two rules because their verdicts differ.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Count the `Button`s with `variant="default"`, `variant="destructive"` or no `variant` on a whole route's page, leaving out the product's top bar and anything inside a `Dialog`, `AlertDialog`, `Sheet`, `Drawer` or side panel. More than one may break the rule.
- A `Button` with no `variant`, or `variant="default"`, inside a `.map()` over cards, rows or sections, such as a filled "Choose" on every offer card or a filled "Save" in every settings section.
- A filled `variant="destructive"` button on a page that already has a filled main button, unless the page exists for that deletion.
- Read the page: does its one filled button serve the page's main task, while banners, sections, cards and rows use `outline`, `secondary` or `ghost`? A page with no filled button is fine.

<a id="act-003a"></a>

## ACT-003a Put the confirming button last in a dialog's row of buttons

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/act-003a/

### Rule

When a dialog's action buttons sit side by side, put the confirming or primary button last, at the trailing end of the row (the right in left-to-right languages, the left in right-to-left), with Cancel or the other dismissive action before it and no action button after it.

### Why

People learn where the answer to a dialog lives. After a few dialogs, the hand and the eye go to the trailing end of the row for "yes, do it" and look just before it for the way out. If one dialog swaps the two, someone who reads fast presses the wrong button, and in a confirmation that can be the costly one. A fixed order also gives Cancel a fixed place, which FRM-003 asks for. No WCAG criterion asks for any button order, so this rule rests on a convention that the judges share, not on the law. We follow the order all three judges use.

### Do

- A dialog titled "Renew your library loan for two more weeks?" shows *Cancel* and then *Renew loan* at the trailing end.
- A dialog for ordering photo prints has *Cancel* and *Order prints*, packed together at the right edge of the footer.
- The same dialog on a narrow screen lets the two buttons fill the width of the footer, *Cancel* on the left half and *Order prints* on the right half. The order is the same, so both layouts are fine.
- A dialog with a single button, such as *Done* after a short notice, places it at the trailing end.
- In an Arabic or Hebrew interface the whole row mirrors: *Cancel* on the right, the confirming button on the left. Use logical alignment, such as `justify-content: flex-end` in a row that follows the page direction, so the mirroring happens without extra code.
- Write *Cancel* before the confirming button in the code too, so the order screen readers and the keyboard follow matches the order on screen, as LAY-002 asks. Focus in a destructive confirmation still starts on *Cancel*, as DLG-004 says; being last does not make the confirming button the default.
- If one button is emphasised, it is the trailing one, as ACT-002a allows. In a destructive confirmation the destructive button takes that trailing place, styled as DLG-005 describes.
- If you use shadcn's `DialogFooter` or `AlertDialogFooter`, write *Cancel* before the confirming button, and check in your own build that the buttons are not shown in reverse when they stack on a narrow screen, since that would break LAY-002 and DLG-004.

### Don't

- Put *Join waitlist* first and *Cancel* after it.
- Add a third button such as *Remind me later* after the confirming button, so the action people came for is no longer at the end.
- Reverse the buttons with the CSS `order` property or `row-reverse` so the screen shows one order and the code another. That breaks LAY-002.
- Apply this rule to a full-page form. A page form is a different layout, and this rule does not decide where its main button goes.

### Exceptions

- **Stacked buttons.** When the buttons no longer fit in a row and stack, this rule does not apply. Keep the order of the code on screen, as LAY-002 and DLG-004 say, so *Cancel* stays first.
- **A help control on the Mac.** In a dialog styled for the Mac, a help button that explains the dialog may sit apart in the leading corner of the footer, on the same line as the action buttons.
- **Multi-step dialogs.** In a dialog that walks through several steps, the way out may stand alone at the leading edge, while the buttons that move between steps stay together at the trailing end with the forward one last. A three-step dialog for booking a bike service could have *Cancel* on its own at the leading edge, and *Change bike* (back to the first step) and *Choose a time* at the trailing end.
- **A top bar instead of a footer.** A sheet or full-screen dialog that puts *Cancel* at the start of its top bar and the confirming action at the end keeps the confirming action trailing, so it fits the rule.
- **Not an exception: a link that leaves the dialog.** A link to another page is not a reason to break the row or to place it at the leading edge.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `AlertDialogAction` written before `AlertDialogCancel` inside `AlertDialogFooter`, or inside `DialogFooter` a confirming `Button` written before the "Cancel" button or the `DialogClose` that wraps it.
- A `Button` written after the confirming button in a dialog footer, such as "Remind me later", so the confirming one is no longer last.
- A dialog footer, or a row inside it, with `flex-row-reverse`, `sm:flex-row-reverse` or `order-*` classes that show the confirming button before Cancel, or `justify-start` on a side-by-side row that leaves it away from the trailing end. Leave alone stacked buttons and buttons that fill the row (see Exceptions).
- In a multi-step dialog, step buttons such as "Back" and "Next" that are split apart, or with the forward one not last. Leave alone a way out that stands alone at the leading edge (see Exceptions).

<a id="act-003b"></a>

## ACT-003b Put a page's buttons in the part they act on and keep them in the same place

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/act-003b/

### Rule

On a page, put a button that acts on one part inside that part, and a button that acts on the whole page in the page's own header, action bar or floating button. Give the same task the same area and position on every page at a given window size.

### Why

People read a button through what surrounds it. A button inside a card is taken to act on that card, and one beside the page title is taken to act on the page. When a button sits somewhere else, people have to guess what it will change, and a wrong guess can save, send or remove the wrong thing. Keeping a task in one place also lets people stop searching: after a few pages, they reach for it without looking. The same holds for keyboard and screen reader users, as long as a button that looks inside a part is also inside it in the code, which LAY-002 asks for. [WCAG 2.2, 3.2.3 Consistent Navigation](https://www.w3.org/TR/WCAG22/#consistent-navigation) and [WCAG 2.2, 3.2.4 Consistent Identification](https://www.w3.org/TR/WCAG22/#consistent-identification) point the same way, but they cover repeated navigation and how components are named, not where ordinary buttons sit. This rule covers more than either and is our choice, not something WCAG requires.

### Do

- A recipe page shows a card for each recipe. *Save recipe* and *Print* sit inside each card, so it is plain which recipe they act on.
- A bike repair shop's booking page has *Book a repair* in the page header, next to the title *Repairs*, because it starts something for the whole page.
- A school timetable page has a table of lessons. *Add lesson* sits in the table's own toolbar, and *Swap lesson* sits in the row of the lesson it changes.
- When a teacher ticks several lessons, *Cancel lessons* appears with the selection and acts only on the ticked rows.
- An account page holds two small forms, *Delivery address* and *Newsletter*. Each has its own *Save address* or *Save preferences* at the end of its own fields.
- *Add stop* sits in the header beside the title on every route page of a delivery planner. On a phone it moves into a bar at the bottom of the screen, and it is in that same bar on every route page.
- At 320 pixels, a route page puts *Optimise route*, *Reverse order* and *Clear stops* in a menu button labelled *Route actions* in its header. All three are still there, as LAY-001 asks, and the menu holds them in the same order on every route page.
- A page bar that stays on screen while the page scrolls never completely covers the focused field or button, as KBD-002 asks.

### Don't

- Put *Delete photo* in the page header of a gallery, far from the photo it removes. Put it on the photo's card or in its row.
- Place a single *Save* at the top of a page with three separate forms, so no one knows which one it saves.
- Put *New booking*, which acts on the whole page, inside the first card of a list of bookings.
- Put *Order parts* in the header on one product page and at the bottom of the description on the next.
- Put the language picker or *Contact support* in one page's own header. They belong to the product's top bar, which is shown on every page.
- Show *Swap lesson* inside a row on screen while the code places it after the table. LAY-002 does not allow that.

### Exceptions

- **Dialogs, sheets and side panels.** This rule does not apply to them. ACT-003a covers the order of a dialog's action buttons.
- **A page that is one whole form.** This rule does not decide whether its sending button comes after the last field or sits in the page's header or bar.
- **Different window sizes.** A task may move to another area when the window gets much smaller or larger, as long as it is in the same place on every page at that size.
- **Sides.** This rule says nothing about left, right, leading or trailing on a page.
- **The product's top bar.** Controls for the whole product, such as the language picker and *Contact support*, sit in the bar that is shown on every page, not in one page's header. There they follow the last part of this rule: the same place on every page.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A button that acts on one card, row, photo or form placed outside that part, such as "Delete photo" in the page header, or a single "Save" on a page with several separate forms. Dialogs, sheets and side panels are outside the rule.
- A button that acts on the whole page, such as "New booking", rendered inside the first card or row of a list instead of the page header, action bar or floating button.
- Compare pages of the same kind at the same window size: does each task, such as "Add stop", sit in the same area and position on every one? A move at a very different window size is fine.
- Product-wide controls, such as a language picker or "Contact support", rendered in one page's own header instead of the top bar shown on every page.

<a id="act-004"></a>

## ACT-004 Keep the submit button enabled on a form that does not fit on one screen

Guideline, our choice. Verdict: Split (1 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/act-004/

### Rule

On a form that does not fit on one screen at the smallest screen size the product supports, without the on-screen keyboard, keep the submit button enabled until the form is sent. A Next or Continue button on a step of a multi-step form counts as the submit button for that step.

### Why

On a form that does not fit on one screen, the button and the field that is holding things up are often not visible at the same time. If the button is switched off, the person sees a faint control that does nothing and has to hunt for the reason. If the button stays on, pressing it answers the question at once: the form shows what is missing. No WCAG criterion asks for the button to stay enabled, and none forbids switching it off. WCAG does let an inactive control fall below the contrast levels in [WCAG 2.2, 1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum) and [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast), which is one of our reasons below. What the form does when the button is pressed while there are problems is covered by FRM-011. Where a message goes is covered by FRM-002a, and when it appears by FRM-002b.

### Our reasons

The judges are split on this, so we chose. We side with keeping the button enabled on forms that do not fit on one screen, for four reasons. Apple, the judge on the other side, writes for its own platforms. The point below about focus on a disabled button is our own observation about the web.

- **The person may not see what is missing.** On a form that does not fit on one screen, the empty field can be far above the button. A switched-off button tells them something is wrong but not what or where.
- **A switched-off button gives no feedback.** Pressing it does nothing. There is no message, no movement and nothing for a screen reader to announce. It can look like a broken page.
- **It can be hard to see and hard to reach.** WCAG lets an inactive control fall below the contrast levels in [1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum) and [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast), and on the web a disabled button usually cannot take focus. That is allowed, but it means the button is the hardest thing on the page to notice at the moment it matters most.
- **It keeps FRM-002b intact.** FRM-002b holds back an error on a field the person has not changed until they send the form. Sending is the safety net that reveals every skipped field. A button that cannot be pressed removes that net, and the skipped fields never get their messages.

The other approach, keeping the button off until every required field is filled, has real merit when the whole form fits on screen and the required fields are clear. That is why this guideline leaves short forms out of its scope and does not rule against them.

### Do

- A long sign-up form has *First name*, *Last name*, *Email*, *Phone*, four address fields and three consent choices, and it scrolls on a phone. *Create account* at the bottom can be pressed from the moment the form opens, also while *Phone* is still empty.
- The person scrolls to the bottom and presses *Create account* with *Phone* empty. The press is taken, and the form answers it as FRM-011 describes.
- Step 2 of 4 in an insurance claim does not fit on a phone screen. Its *Continue* button stays enabled while *Date of incident* is empty.
- Measure the form at the smallest screen size the product supports, with the on-screen keyboard closed. A form that fits on a laptop but scrolls on a phone is a form that does not fit on one screen.
- After a valid press, what the button does until the reply comes back follows STA-005a and STA-005b, not this guideline.

### Don't

- Grey out *Send* on a form that does not fit on one screen until every required field is filled, so a person at the bottom of the page cannot tell which field above is still empty.
- Keep *Continue* off on a long step of a multi-step form because "it is only a step".
- Leave the button looking enabled but let a press with problems do nothing, or only shake the button. That is a switched-off button in disguise. FRM-002b says what the press shows, and FRM-011 where focus goes.
- Judge the form's length on a large screen only, and switch the button off for everyone because it fits there.

### Exceptions

- **Short forms.** A form that fits on one screen at the smallest screen size the product supports, without the on-screen keyboard, is outside this guideline. A team may switch the button off there.
- **Steps of a multi-step form.** A Next or Continue button counts as the submit button for its step. Each step is measured on its own against the short-forms test above.
- **While sending.** Once a valid form is sent, the button shows that it is working, as STA-005a says, and does not send again on a second press, as STA-005b says. This guideline covers only the time before sending.
- **If a submit button is switched off.** What it must say about why it is off is covered by ACT-005. It also stops Enter in the form's fields, as FRM-015 notes.
- **When the form is sent with problems.** Where focus goes is covered by FRM-011, for short forms too.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Open the form at the smallest width the product supports, with the on-screen keyboard closed. If it scrolls, see whether the submit, "Next" or "Continue" button is disabled before every field is filled. A form that fits is outside the rule.
- A submit `Button` with `disabled` or `aria-disabled` tied to validity, such as `disabled={!isValid}` or `disabled={!form.formState.isValid}`, on a form or step that may not fit on one screen at the smallest supported width. Leave alone `disabled={isSubmitting}` after a valid press (see Exceptions).
- On a long form, press a submit button that looks enabled with a required field empty. A press that does nothing visible, or only shakes the button, is a switched-off button in disguise.

<a id="act-005"></a>

## ACT-005 Say next to an unavailable submit button what is still needed

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/act-005/

### Rule

When a button that submits or continues a form is unavailable because required input is missing, show visible text directly before the button in reading order that says what the person must still do to make it work, and make that text readable without focusing the button. A required value that is filled in but not valid counts as missing.

### Why

A faded button tells people that they cannot go on, but not why. It is also easy to miss. WCAG lets an inactive control fall below the contrast levels in [1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum) and [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast), and on the web a disabled button usually cannot take focus, so a keyboard or screen reader user may never reach it. Plain text beside the button closes that gap: it is ordinary text with normal contrast, it sits in the reading order, and it turns a dead end into a next step. No WCAG criterion asks for this text. It helps meet [WCAG 2.2, 3.3.2 Labels or Instructions](https://www.w3.org/TR/WCAG22/#labels-or-instructions), and the off state itself must still be exposed in code under [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value), as VIS-008a says.

This rule does not say a submit button may be switched off. On a form that does not fit on one screen, as ACT-004 defines it, ACT-004 keeps the button enabled. This rule is the least a form owes the person once a team has switched the button off.

### Do

- A short form to join a newsletter has *Email* and a consent checkbox. While either is missing, a line just above *Subscribe* reads "Enter your email and accept the terms to continue."
- Step 2 of 4 in a booking flow asks only for a time slot, and the whole step fits on one screen. Until a slot is picked, the text "Choose a time slot to continue" sits right before *Next*.
- Name what is still missing when you can, and update the line as the person fills things in: "Still needed: phone number" after *Name* and *Email* are done. Remove the line once the button works.
- Update the line when the person leaves a field or makes a choice, not on every key press, so it does not flicker or repeat itself to a screen reader.
- Keep the text close to the button on screen as well as directly before it in the reading order, so a screen reader user hears it on the way to the button.
- If the button stays focusable and is marked as unavailable in code, also tie the text to it as its description, for example with `aria-describedby`.
- When the line changes, announce the change without moving focus, for example from a polite live region.
- A switched-off submit button also stops Enter in the form's fields (FRM-015). The line tells a person who pressed Enter why nothing happened.
- Keep the line neutral. "Enter your date of birth to continue" states what remains; it is not an error.
- A required value that is filled in but not valid, such as a four-digit *ZIP code*, keeps the button off and the note at the button names it in neutral words: "Check the ZIP code to continue." The field's own error still waits until the person leaves the changed field, as FRM-002b says.

### Don't

- Grey out *Continue* with no text near it, so the person has to guess what is missing.
- Put the reason only in a tooltip that appears when the button is hovered or focused. A disabled button often cannot be focused, and touch screens have no hover.
- Place the explanation at the top of the page, far from the button and out of view.
- Write the line in the button's faded colour, so it is as hard to read as the button.
- Paint every empty field red or show "Required field" under fields the person has not touched yet. That is an error, and FRM-002b holds errors back until the person leaves a changed field or sends the form.
- Read this rule as permission to switch off the submit button on a form that does not fit on one screen, as ACT-004 defines it. ACT-004 still applies.

### Exceptions

- **While sending.** After a valid press, the button may be unavailable to a new press while the form is sent, as the guideline STA-005b describes. The sign that it is working, which STA-005a asks for, is the explanation. Nothing is missing, so no note about what is needed is shown.
- **No permission.** A control the person is never allowed to use is outside this rule.
- **Other reasons.** A button that is off for a reason other than missing input, such as a closed booking window, is outside this rule.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A submit or "Continue" `Button` with `disabled` or `aria-disabled` tied to missing or invalid input, such as `disabled={!isValid}`, with no visible text right before it in the JSX that says what is still needed. Leave alone `disabled={isSubmitting}`, and buttons off for another reason.
- The reason given only in a `Tooltip`, a `title` attribute or a hover card on the disabled button, or only at the top of the page, far from it.
- The note inside a wrapper that fades with the button, such as `opacity-50` or `group-disabled:opacity-50` on their shared parent, so it is as hard to read as the button.
- Fill the form one field at a time: does the note before the button say what is still missing at each point, including a value that is filled in but not valid?

<a id="act-006"></a>

## ACT-006 Make every pointer target at least 24 by 24 pixels, or pass the 24-pixel spacing test

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/act-006/

### Rule

Make every target that people press with a pointer at least 24 by 24 CSS pixels, or place it so that a circle 24 CSS pixels across, centred on its bounding box, touches no other target and no other small target's circle.

### Why

A small target is hard to hit for anyone with a tremor, stiff fingers, a shaky bus ride or a worn trackpad. A near miss either does nothing or, worse, presses the button next to it. This applies to every kind of pointer, so mouse, pen and touch all count, not only phones. [WCAG 2.2, 2.5.8 Target Size (Minimum)](https://www.w3.org/TR/WCAG22/#target-size-minimum) requires it at Level AA.

The size test is exact. An upright 24 by 24 CSS pixel square must fit entirely inside the area that responds to the pointer. A target that is smaller can still pass on spacing: draw a 24-pixel circle on the centre of its bounding box. If that circle reaches no other target, and does not overlap the circle of any other small target, the target passes. "Leave some room" is not enough; the circle is the test. Measure what can be pressed at the time of testing. While a slide-in *Cart* panel covers half of a product list, the hidden buttons are not measured; the buttons in the panel are, and so is whatever part of the list is still in view.

Our advice goes further than the law, and we mark it as advice only. For touch, aim for 44 CSS pixels or more, and give primary actions extra room, such as 48. The 44 figure is the size in [2.5.5 Target Size (Enhanced)](https://www.w3.org/TR/WCAG22/#target-size-enhanced), which is Level AAA and not part of what WCAG 2.2 AA requires. The 48 figure is our own and does not come from WCAG. Prefer meeting 24 by size over leaning on the spacing test. Size is one measurement per target, with no neighbours to check, and it keeps passing when someone tightens the layout or it reflows on a narrow screen.

### Do

- Give an icon-only button such as *Edit* a hit area of at least 24 by 24, even when the pencil icon is 16. Padding around the icon counts, because it responds to the pointer.
- Measure the area that responds, not the drawing. Justified's Checkbox and RadioGroupItem each get a square target area of 24 by 24, even though the drawn box is smaller. The Switch's area is its 44 by 24 track grown by 2 pixels on every side, a rectangle of 48 by 28. All three meet the size test. Do not shrink them with a `className`, and keep the root font size at 16 pixels or more, or that area falls under 24.
- Check rounded shapes with the square, not the outline. A round *Like* button 24 pixels across fails the size test, because a 24-pixel square does not fit inside the circle. It can still pass on spacing when nothing else you can press is close to it. If something is, give it a square or larger hit area.
- A lone 16-pixel *i* button next to the heading *Delivery address* can pass on spacing. Its circle reaches 4 pixels past each side, so the button passes as long as no other target sits within that reach. If a link is added right beside it later, it fails, so a 24-pixel button is the safer choice.
- Treat a slider such as *Volume* as one target: the whole track responds, so measure the track. A separate drag handle, like the corner that resizes a *Comments* panel, is its own target and must pass on its own, and needs a way without dragging, as ACT-007a says.
- Keep the close icon in a dialog header, *Close*, at 24 or more, or clear of the other header actions by the circle test. DLG-001 ties Escape to that icon; the icon still has to be easy to press.
- When the viewport is narrow, let a button row wrap instead of shrinking its targets or closing their gaps. At 320 CSS pixels, LAY-001 and this rule apply at once.
- Offer a compact layout, such as a denser table for *Invoices*, only as a choice the person turns on, and keep the control that turns it off at full size.

### Don't

- Stack *Increase* and *Decrease* arrows in a quantity field, each 24 wide and 10 tall, directly on top of each other. Each arrow's circle runs into the other arrow.
- Number the pages of a search result *1*, *2*, *3* as 16-pixel links with 2 pixels between them. Their circles overlap.
- Shrink a checkbox's target under 24 and rely on its label to make it pass, unless the label itself meets 24 by 24 or the spacing test. The visible label from FRM-001 counts as the same control only when it passes on its own. That the label responds to a press at all is FRM-016a.
- Argue that a target is fine because it grows when people zoom in. CSS pixel sizes stay the same at any zoom, so zoom never turns a fail into a pass.
- Let two targets overlap and count the shared part toward both, unless they do the same thing.
- Turn on a dense mode by default that pushes buttons under 24.

### Exceptions

- **Inline.** A target that sits in a line of text and takes its size from that text is outside the rule, such as the link *terms* in "I accept the terms".
- **Equivalent.** A small control is excused when another control on the same page does the same job and passes. A compact *Share* icon on each card is fine if a full-size *Share* button for the same item is also on the page.
- **User agent.** A control the browser draws at its default size, such as an unstyled native radio button, is excused while you leave its size alone. Once you restyle it, for example to make it smaller, it must pass.
- **Essential.** When the size or position carries the meaning, or a law sets the layout, the target is excused. Offer a larger alternative where you can.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- In the running page, measure each pressable element's box. If it is under 24 by 24 CSS pixels, check whether a 24-pixel circle on its centre reaches another target or another small target's circle. Leave alone links inside a line of text (see Exceptions).
- Classes that make a target smaller than 24 pixels, such as `size-5`, `h-5` or `size-4` on a `button` or icon trigger, or `size-4` on Justified's `Checkbox` or `RadioGroupItem`, whose 20-pixel box has a 24-pixel area. Size alone is a hint; the spacing test may still pass.
- Small targets packed close together, such as stacked up and down arrows in a number field, page links with `gap-0.5`, or icon buttons in a toolbar with no gap.
- A dense or compact layout turned on by default, or a root font size under 16 pixels, that pushes `rem`-sized targets below 24.

<a id="act-007a"></a>

## ACT-007a Offer a way without dragging for everything people can drag

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/act-007a/

### Rule

Anything people can do by dragging on the page can also be done with a single pointer and no dragging, such as buttons, a menu or a field. A keyboard route alone does not count, and the other way may not be a swipe or another gesture that follows a path.

### Why

A drag asks for a lot: press, hold, move and let go in the right place, all in one steady motion. People with a tremor, weak hands, a head pointer or a mouth stick, and anyone on a crowded train, can miss the spot or fail to hold on. [WCAG 2.2, 2.5.7 Dragging Movements](https://www.w3.org/TR/WCAG22/#dragging-movements) requires that whatever a drag does can also be done with a single pointer without dragging. The [Understanding page for 2.5.7](https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements.html) is clear that keyboard support is judged on its own: a person tapping on a phone or steering a head pointer has no keys to press, so they need something to click. A separate control elsewhere on the page is fine, as long as it gets the same result, and a field people type into counts too. It must not be a swipe or a flick, which [2.5.1 Pointer Gestures](https://www.w3.org/TR/WCAG22/#pointer-gestures) treats as a path. The keyboard route is a separate requirement and sits in KBD-001. Buttons and menus serve both at once, because they also take focus.

### Do

- On a *Sprint board* built with dnd-kit, give each card a `DropdownMenu` labelled *Move card* with *Move to To do*, *Move to In progress* and *Move to Done*. The card can still be dragged; the menu is the way without dragging.
- In a sortable list *Playlist order*, give each row *Move up* and *Move down* buttons, or a *Move to position* field that takes a number. The drag handle stays for those who like it.
- Make sure the drag handle `button` that carries dnd-kit's `{...listeners}` does not swallow the click that should open the row's menu. Test it by clicking without moving.
- Adding dnd-kit's `KeyboardSensor` is needed for KBD-001, but it does not meet this rule. Add the buttons or the menu as well.
- For an upload area built with react-dropzone, keep a real `Button` labelled *Choose file* that calls `open()`, or make the whole zone a button that opens the file picker and say so in its text: "Drop a file here or choose one". Do not set `noClick: true` without that button. Both 2.5.7 and 2.1.1 point to this; the Understanding page does not name file uploads.
- Keep the shadcn `Slider` as it is: a click on the track moves the thumb there. For a custom range picker such as *Budget, £0–£2,000*, put a labelled number `Input` beside each thumb, kept in step with it.
- Give a shadcn `Resizable` panel *Preview* a *Collapse preview* button or a menu with set widths, since the handle can only be dragged or moved with keys.
- Keep `CarouselPrevious` and `CarouselNext` on a shadcn `Carousel` that can be dragged, even when the design looks cleaner without them.
- A Vaul `Drawer` that closes by dragging down keeps a way to close it by pressing, such as a *Close* button or a click on the overlay, which a modal drawer closes on by default. A drawer with `modal={false}` has no overlay, so it needs the button.
- Rows with swipe actions, such as a swipe that marks a row in *Bills* as paid, keep the same actions in a row menu.
- In an image cropper *Crop photo*, offer set ratios such as *Square* and *4:3* and number fields for width and height. A map that pans by dragging gets arrow buttons and *Zoom in* and *Zoom out*.
- The controls may appear only once an item is selected. On a seating plan *Table layout*, a tap on a guest's pin shows *Move to table* with a list of tables. They must then be reachable without dragging and meet ACT-006 as targets.
- Our own advice, beyond the law: keep the other way visible. The law accepts a control that is visually hidden as long as a pointer can operate it, but a visible button is found by more people.
- A long press may start a drag on touch. The move that follows still needs a way without dragging.

### Don't

- Let the order of *Playlist order* change only by dragging rows, and count arrow keys while a row is picked up as the alternative.
- Offer a swipe left on a row as the only other way to delete it.
- Build a volume knob for *Master volume* from `div`s with only `onPointerMove`, so the level can be set only by dragging round the knob.
- Build a two-thumb range where a click on the track does nothing and there are no fields.
- Remove the arrows from a carousel because the slides can be dragged.
- Use a slider puzzle as a check before sign-in. It fails here as well as under FRM-008.

### Exceptions

- **The movement is the point.** When the path of the drag is the content, such as a signature pad or freehand drawing in *Inkhollow*, the drag is exempt. Putting an item in a chosen place is not exempt, because the place can be chosen by pressing. KBD-001 has the matching exception for the keyboard.
- **Scrolling that the browser provides.** Native scrolling, including `overflow` areas and the browser's own pull to refresh, is outside the rule. A custom area that blocks the browser's scrolling and moves its content by dragging is inside it again.
- **Neighbouring rules.** The keyboard route for the same task is KBD-001. What assistive technology hears during a keyboard move is ACT-007b, and the mark on the place where a dragged item will land is ACT-008. Undo after a move that loses something is DST-001a.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A dnd-kit `useSortable` or `useDraggable` item with no buttons, menu or field that makes the same move by pressing, such as "Move up", "Move down" or "Move to Done". A `KeyboardSensor` alone does not count.
- A react-dropzone `useDropzone` with `noClick: true` and no `Button` that calls `open()`, or any file drop area with no way to choose a file by pressing.
- A shadcn `Carousel` without `CarouselPrevious` and `CarouselNext`, a `ResizablePanel` with no button or menu that sets its size, or a Vaul `Drawer` with `modal={false}` and no close button.
- Custom drag code with `onPointerMove` or `onTouchMove` that sets a value or position, such as a knob or a two-thumb range, with no field or buttons beside it. Leave alone drawing and signature pads (see Exceptions).
- A swipe on a row as the only other way to an action, such as deleting or marking as paid, with no row menu or button for it.

<a id="act-007b"></a>

## ACT-007b Tell assistive technology what each step of a keyboard move did

Guideline, our choice. Verdict: Insufficient evidence (0 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/act-007b/

### Rule

When an item can be moved with the keyboard, tell assistive technology in words when it is picked up, where it is after each step, and where it was dropped or that the move was cancelled, using its visible label and positions such as "2 of 5".

### Why

KBD-001 makes sure a sortable list or a board can be rearranged with keys. For a person who cannot see the screen, that is only half the job: they press an arrow key and the row moves, but nothing tells them where it is now, so they cannot know when to stop. A few words at each step turn the keys into something they can steer. WCAG does not ask for this in every case. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that the handle has a name and a role, not a running account of the move. [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) applies when the product shows a line of text about the move, and then FBK-004 says how it is announced; a row that only shifts on screen is not a status message. [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) requires the keyboard route itself, which is KBD-001.

### Our reasons

None of the three judges speaks to telling assistive technology what a move did, so the verdict is Insufficient evidence (0 of 3 judges spoke) and this guideline is our choice. NN/g, an expert witness who does not vote, supports it. We ask for it for three reasons.

- **A keyboard route without words is a route only for sighted people.** KBD-001 requires that the move works with keys. A screen reader user who cannot tell where the item is cannot finish the move, so the requirement does them little good.
- **The tools already do it, badly by default.** dnd-kit speaks during a keyboard move out of the box, but it names items by their `id`. A sentence such as "Picked up draggable item 3f9a" is worse than silence. Writing the four messages takes a few lines.
- **It costs others nothing.** The messages go to a live region that sighted people do not see.

### Do

- In dnd-kit, pass `accessibility.announcements` to `DndContext` with `onDragStart`, `onDragOver`, `onDragEnd` and `onDragCancel`. In a list *Reading list*: "Picked up The Hobbit, position 3 of 6", "The Hobbit, position 2 of 6", "Dropped The Hobbit at position 2 of 6".
- On a board, name the column and the place in it: "Fix login bug, Done, 1 of 3".
- On Escape, say the item is back: "Move cancelled. Fix login bug is back in In progress, 2 of 4".
- Set `screenReaderInstructions` to say which keys pick up, move and drop. Our own choice, not part of the guideline: Space to pick up and drop, the arrow keys to move, Escape to cancel.
- Give each handle a name, as 4.1.2 asks. Putting the item in it, such as "Reorder The Hobbit", is our own choice.
- Keep the live region in the page before the first move, as FBK-004 says. dnd-kit does this for you; a region of your own must sit outside the list that re-renders.
- Our own advice: after the drop, keep focus on the moved item's handle, even when the re-order renders the row again, so focus does not fall to the top of the page. That serves [WCAG 2.2, 2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order). A move the server refuses after the drop goes back as STA-005a describes, focus included.
- When the item is moved through the menu from ACT-007a, such as *Move to Done*, focus returns to the item and a short line "Moved to Done" is shown. That line is a status message, so FBK-004 applies.

### Don't

- Add `KeyboardSensor` and `sortableKeyboardCoordinates` and leave the default messages that read out ids.
- Use `aria-grabbed` or `aria-dropeffect`. Both are deprecated and not supported by screen readers.
- Write a message from a `pointermove` handler of your own, so the live region speaks at every pixel the item moves.
- Give positions in pixels or as an index starting at zero.
- Put the live region inside the sortable list, so it is rebuilt on every move and nothing is read.

### Exceptions

- **Pointer drags.** This guideline asks for words only for keyboard moves. dnd-kit writes its messages for pointer drags too, and that does no harm. The mark on the landing place is ACT-008.
- **A product that chooses otherwise.** This is a guideline. A product that leaves it out still meets KBD-001 and, for any text it shows, FBK-004.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A dnd-kit `DndContext` with `KeyboardSensor` in its `sensors`, or no `sensors` at all, which includes it by default, that passes no `accessibility.announcements` with `onDragStart`, `onDragOver`, `onDragEnd` and `onDragCancel`, so the default messages read out ids.
- Announcement functions that put `active.id` or `over.id` straight into the text, unless the id is the visible label, or give positions in pixels or as a zero-based index, instead of the visible label and a position such as "2 of 5".
- `aria-grabbed` or `aria-dropeffect` used to tell assistive technology about a move. Both are deprecated and not read, so check that words are announced as well.
- A live region of your own inside the `SortableContext` or the list that re-renders on each move, so nothing is read.
- With a screen reader on, pick an item up with the keyboard, move it one step, then press Escape: are the pick-up, the new position and the cancel each read in words?

<a id="act-008"></a>

## ACT-008 Mark where a dragged item would land, and only while it is over that place

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/act-008/

### Rule

While something is being dragged, mark on screen the place that would receive it if it were let go now. Remove the mark as soon as the dragged thing leaves that place, is dropped or the drag is cancelled.

### Why

A drag is a promise made in advance: let go here and this will happen. Without a mark on the landing place, people let go and then look to see what they did, and a row in the wrong slot or a file that missed the zone is found only afterwards, if at all. A mark that stays after the item has moved on is worse, because it points at a place that will not get the drop. No WCAG criterion asks for a drop mark. Once there is one, [WCAG 2.2, 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) asks 3:1 for the part people need to see it, and [1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) rules out a change of hue as the only sign. The mark is for people who can see the screen; what assistive technology hears is ACT-007b.

### Do

- In a sortable list *Reading list* built with dnd-kit, read the sortable `over` id and draw a 2px line in the gap where the row will go. Do not rely on rows shuffling through `transform` alone, which shows nothing when the layout does not move them.
- On a board, read `isOver` from `useDroppable` on each column and give the column under the card a thicker border and a light fill.
- With nested targets, such as a card inside a column, mark only the one that would take the drop.
- In a react-dropzone area, change the zone while a file is over it, using `isDragActive`: a tinted fill with an upload icon and the text "Release to upload".
- Clear the mark in `onDragEnd` and `onDragCancel`, so it is gone after a drop and after Escape.
- Show the same mark during a keyboard move with dnd-kit's `KeyboardSensor`. Sighted keyboard users need it too.
- Keep the drag-over mark distinct from the focus ring on a zone that can also be clicked (ACT-007a). They are different states; KBD-001 owns the ring.
- Our own choice, beyond the rule: give the held item a raised look or a lighter copy that follows the pointer; show no mark, or a "not allowed" sign, over a place that cannot take the item; and on touch, draw the line ahead of the finger rather than under it.
- When saving after a drop fails, FBK-002 applies. Our own choice: do not let the item snap back without a word. The item may sit in its new spot before the save is done, as STA-005a's exception for a change shown at once allows. A placeholder there while it saves, which follows STA-001, also works.

### Don't

- Let a column stay highlighted after the card has been carried on to the next one.
- Mark a column and the card inside it at once, so it is unclear which one takes the drop.
- Change only the hue of the zone's border, from one colour to another of about the same lightness, with no change in weight or fill. Without a 3:1 lightness difference, colour is the only sign (VIS-003a).
- Leave a drop zone looking the same whether or not a file is over it.
- Keep the mark on screen after the person pressed Escape.

### Exceptions

- **No drag.** A place that is chosen by pressing, such as the *Move to* menu in ACT-007a, needs no drop mark.
- **Neighbouring rules.** The way without dragging is ACT-007a, the words for assistive technology are ACT-007b, and the focus ring is KBD-001.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Drag an item across several targets and let go: is the place under it marked, does the mark move with it, and is it gone after the drop? Start again, press Escape mid-drag, and see whether the mark clears.
- A dnd-kit `useDroppable` that never reads `isOver`, a sortable list that reads no `over` id and relies on rows shifting through `transform`, or a `useDropzone` area that ignores `isDragActive`.
- A mark set in `onDragOver` or `onDragEnter` that is cleared in neither `onDragEnd` nor `onDragCancel`, or a native `dragleave` handler that leaves it on.
- Nested drop targets, such as a card inside a column, that both show a mark at the same time.

<a id="act-009"></a>

## ACT-009 Give everything people click to go somewhere or to act the role of a control in code

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/act-009/

### Rule

Everything people click or tap to go somewhere or to act has a control role in code, such as link or button. Something shown as a link whose only job is to take people to another address has the link role.

### Why

A screen reader tells people what each thing is before they use it: "link", "button", "menu item". It also lets them jump through a list of every link or every button on the page. A `div`, `span` or image with a click handler is none of these. It has no control role: it is read as plain text, if it is reached at all, and it is missing from those lists, so the person may never learn that it does anything. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) requires that every control, scripted ones included, has a role software can work out. The Working Group lists a generic element made clickable by script without a role as a failure ([F59](https://www.w3.org/WAI/WCAG22/Techniques/failures/F59)). It also fails anything presented as a link that reaches its target by script while its role is not link ([F42](https://www.w3.org/WAI/WCAG22/Techniques/failures/F42)), even when it works from the keyboard. An anchor with no `href` is not a link in HTML, so it has no control role either. The criterion asks for the role, not for a native element; building with `<button>` and `<a href>` is the Working Group's advice and ours. That every control also works from the keyboard ([2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard)) is KBD-001. [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) supports this rule, since a fake link loses what the page shows about it.

### Do

- In a library's app, *My loans* shows each book as a shadcn `Card`. The book's title is a `Link` to its page and *Renew loan* is a `Button`. A click elsewhere on the card may open the book's page as a shortcut, as KBD-001 allows.
- Under the opening hours, *All branches* looks like a text link and is one: `<Button variant="link" asChild><Link href="/branches">All branches</Link></Button>` renders an `<a href>`.
- The star that adds a book to *Wish list* is a `Button size="icon"` with the lucide `Star` inside, named as ACT-001b says.
- Wrap a real `Button` in `DialogTrigger`, `DropdownMenuTrigger` or `PopoverTrigger` when you use `asChild`. Without `asChild` they render a `<button>` themselves.
- Our advice, which is also the Working Group's: use `<button>` and `<a href>`. The adapter's `Button` renders `<button type="button">`, or the element you give it with `asChild`, and Next.js and React Router `Link` render `<a href>`.
- If a control must be built by hand, it needs all of it: `role="button"` or `role="link"`, `tabIndex={0}`, Enter (and Space for a button), `aria-disabled` when it is off, any other state it has (VIS-008a), and a name (ACT-001b). Enter and Space are our advice; keyboard use is KBD-001. That can meet the criterion, but it is the worse way.
- A link that downloads a file, such as *Download loan history (CSV)*, is still a link: `<a href="/loans.csv" download>`.
- Which of the two to pick for a given job is ACT-009a for going somewhere and ACT-009b for acting in place.

### Don't

- Put `onClick={() => router.push("/books/" + book.id)}` on the `Card` and nothing inside it that is a link.
- Write `<a onClick={renewLoan}>Renew loan</a>` with no `href`. It has no role in HTML and takes no focus.
- Build *All branches* as `<Button variant="link" onClick={() => router.push("/branches")}>`. It looks like a link and goes somewhere, but a screen reader calls it a button and it is not in the list of links.
- Make *Late fees* an underlined `span` with `cursor-pointer` that calls `navigate("/fees")`.
- Put `onClick` straight on the lucide `Star` icon.
- Put a `span` inside `PopoverTrigger asChild`, so the trigger loses the button it would have rendered.

### Exceptions

- **A pointer shortcut.** A click on a card, a row or a backdrop may do what a real control nearby already does. The control carries the role; the shortcut needs none. KBD-001 and TBL-003 say the same.
- **Act, then move.** A control whose job is to save, send, delete or sign out, or send typed input such as *Search*, stays a button when a page follows, also when it looks like a link (see ACT-009a).
- **Table cells and rows.** Do not put `role="button"` or `role="link"` on a `th`, `tr` or `TableRow` to make it clickable. Put the control inside, as TBL-002 and TBL-003 say.
- **Neighbouring rules.** The keyboard half is KBD-001, the name is ACT-001b, and link text is TXT-003.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `div`, `span`, `li`, `img` or icon with `onClick` and no `role`, such as a `Card`, `Badge` or `Avatar` given `onClick`. Leave alone a card, row or backdrop whose click repeats a real control nearby, and a wrapper that only stops propagation or passes on clicks from buttons inside.
- An `<a>` with `onClick` and no `href`. Leave alone an `<a>` that receives `href` through spread props.
- Something shown as a link that navigates by script: `<Button variant="link" onClick={() => router.push(...)}>` without `asChild`, or an `underline` `span` or `button` whose `onClick` calls `navigate()`, `window.location` or `window.open`. Leave alone one whose job is to save, send, delete or sign out, or send typed input such as *Search*.
- A `DialogTrigger`, `AlertDialogTrigger`, `SheetTrigger`, `DropdownMenuTrigger`, `PopoverTrigger` or `CollapsibleTrigger` with `asChild` around a `div` or `span`, or around an `Avatar` or `Badge`.

<a id="act-009a"></a>

## ACT-009a Build a control that only takes people somewhere as a link, also when it looks like a button

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/act-009a/

### Rule

When a control not shown as a link only takes people to another address, such as a page or a spot on a page, build it as a link in code, not as a button that changes the address by script. A control that acts and then moves on stays a button.

### Why

A link and a button are announced differently, and people act on what they hear: a link takes them away, a button does something where they are. A link also brings what the browser gives every link: open in a new tab, copy the address, see where it goes before going, and appear in a screen reader's list of links. A button that calls `router.push` has none of that, though it looks the same. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that a control's role can be read, and its Understanding text says an element made to do something other than its usual job needs extra care. It names no failure for a button that navigates, so this is a guideline. Something shown as a link that navigates is ACT-009, a requirement.

### Our reasons

Fewer than two judges have spoken about which element should take people somewhere, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So do GOV.UK and NN/g, expert witnesses who do not vote. We choose a link for four reasons.

- **The role sets the expectation.** "Button" tells a screen reader user that something will happen here. When the page changes instead, they have to work out where they are.
- **People keep what links give them.** Opening a page in a new tab, copying its address or seeing it in the status bar is how many people work. A scripted button takes it away for no gain.
- **The look stays free.** `Button asChild` gives the link any button style, so the design loses nothing.
- **Our own advice:** search engines and prefetching follow `href`, not click handlers.

### Do

- In a vet clinic's portal for pet owners, the dashboard has *View appointments* styled as a primary button: `<Button asChild><Link href="/appointments">View appointments</Link></Button>`. It renders an `<a href>` with button styling. The adapter's `Button` leaves `type` off when `asChild` is used.
- A link styled as a button names where it goes, as TXT-003 asks for every link. ACT-001a covers buttons that perform, confirm or commit an action, so its verb-first form is not required here. *View appointments* and *Appointments* both work.
- If the page guards unsaved changes, keep the guard on link clicks too once `router.push` becomes a `Link`, as FRM-004c asks.
- *Open pharmacy site* goes to another site: `<Button variant="outline" asChild><a href="https://pharmacy.example.com">`. Whether it opens a new tab is outside this guideline.
- The menu *My pets* lists each pet as `DropdownMenuItem asChild` with a `Link` inside. Inside a menu the item is announced as a menu item, not a link, and that is right; the `<a href>` still keeps the address and open in a new tab.
- Sidebar items are `SidebarMenuButton asChild` with a `Link`, and NAV-002a says how to mark the current one. Pagination with an address per page, breadcrumbs and tabs that are routes are links too.
- *Book appointment* saves the booking and then shows it. Its job is the booking, so it is a button, and the page that follows is the result. The same goes for *Next* on a step of a form that checks or saves the step, and for *Sign out*.
- *Next: aftercare* at the foot of a read-only care guide only shows the next page, so it is a link.
- Our own choice for *Back*: link to the parent page where there is one, such as *Back to Bella's records*. Use a button that calls `router.back()` only when going back in history is truly the job.
- A jump to a part of the same page, such as `href="#vaccinations"`, is a link.
- A download is a link to the file, `<a href download>`. When the file is made by script on request, it is a button.
- Our own choice: a route shown as a dialog, with an address that also opens on its own, is a link. A dialog, sheet or menu with no address of its own opens from a button, as ACT-009b says.

### Don't

- Write `<Button onClick={() => router.push("/appointments")}>View appointments</Button>`.
- Open the pharmacy site with `onClick={() => window.open("https://pharmacy.example.com")}` on a `Button`.
- Fill *My pets* with `DropdownMenuItem onSelect={() => router.push("/pets/bella")}`, so no item can be opened in a new tab.
- Build the page numbers under *Past visits* as buttons that call `router.push("?page=3")`.

### Exceptions

- **Shown as a link.** A control that looks like a link and navigates is ACT-009's requirement, not this guideline.
- **Act, then move.** A control whose job is to save, send, delete or sign out, or send typed input such as *Search*, is a button even when a new page follows, also when the result has an address.
- **Menus and tabs.** A menu item keeps the menu item role and tabs inside one page keep the tab role. What matters here is that a menu item that goes somewhere wraps a real link.
- **A product that chooses otherwise.** This is a guideline. A product that keeps a button for navigation still gives it a role, a name and keyboard use (ACT-009, ACT-001b, KBD-001). FRM-012b's own wording allows a button, a link or a menu for going to another page; this guideline picks the link.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Button` without `asChild` and not `variant="link"`, or a `<button>`, whose `onClick` does nothing but call `router.push`, `navigate()`, `window.open` or set `window.location`. Leave alone one whose job is to save, send, delete or sign out, or send typed input such as *Search*, before it moves on.
- A `DropdownMenuItem` or `SidebarMenuButton` without `asChild` whose `onSelect` or `onClick` only goes to another page.
- Pagination, breadcrumb or route tab controls not shown as links, built as buttons that change the address by script, where each page has an address of its own. Leave alone Radix `Tabs` whose `onValueChange` only mirrors the open tab in a search param of the same page.

<a id="act-009b"></a>

## ACT-009b Build a control that acts where the person is as a button, also when it looks like a link

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/act-009b/

### Rule

A control that acts where the person is, such as saving, deleting, switching something or opening a dialog or menu, is a button in code, also when it is styled as a link. Do not build it as an `<a>` with `href="#"` or `javascript:void(0)`, or as a link whose click is cancelled by script.

### Why

A screen reader says "link" for an `<a href="#">`, so people expect to leave the page, and the control turns up in the list of links though it goes nowhere. A button says what it is, takes Enter and Space, and can carry the states a menu, a toggle or a disclosure needs. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that a control's role can be read, and its Understanding text says an element given a job other than its usual one needs extra care. [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) is met by the anchor's Enter alone; it supports this guideline only in that a button also takes Space, the key people expect, which is our advice. Neither names a failure for a link that acts, so this is a guideline. An `<a>` with no `href` at all is ACT-009, a requirement.

### Our reasons

Fewer than two judges have spoken about links that act, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it, and so does NN/g, an expert witness who does not vote. We choose a button for four reasons.

- **The role sets the expectation.** "Link" promises a new place. A dialog that opens instead surprises the person who heard it.
- **A fake link breaks what links do.** `href="#"` puts `#` in the address and jumps to the top of the page if the script fails or `preventDefault` is missing. A middle click opens a useless tab, and *Copy link* copies nothing worth having.
- **A button carries the state.** `aria-expanded`, `aria-pressed`, `aria-haspopup` and `aria-disabled` belong on buttons; that each state is set and kept in step is VIS-008a. Radix and shadcn triggers render a `<button>` and set them for you, and wrapping an `<a>` in them with `asChild` throws that away.
- **The look stays free.** `Button variant="link"` looks like a link and is a `<button>`.

### Do

- In a podcast app, each episode row has *Mark as played* styled as a text link: `<Button variant="link" onClick={markPlayed}>Mark as played</Button>`. It renders a `<button>`. The adapter's `Button` sets `type="button"` by default, so it never submits a form around it.
- *Show episode notes* opens the notes below the row with `CollapsibleTrigger`, which renders a button and sets `aria-expanded`.
- *Share episode* opens a dialog: `<DialogTrigger asChild><Button variant="link">Share episode</Button></DialogTrigger>`. Focus goes into the dialog and back to the button, as DLG-006 says.
- *Load more episodes* at the end of the list is a button. Page numbers with an address each are links, as ACT-009a says.
- *Copy feed address*, *Print transcript* and *Remove from queue* are buttons.
- Our own advice: a button inside running text may look like the links around it, but people may then expect it to go somewhere, so name the action plainly, as ACT-001a asks.
- The label of each button follows ACT-001a and its name ACT-001b.

### Don't

- Write `<a href="#" onClick={(e) => { e.preventDefault(); setShareOpen(true) }}>Share episode</a>`.
- Use Next.js `<Link href="#" onClick={markPlayed}>` for *Mark as played*.
- Give *Remove from queue* `href="javascript:void(0)"`.
- Put `<a href="#">` inside `DropdownMenuTrigger asChild` for the menu *Episode options*.
- Keep the anchor and add `role="button"` and a Space handler. That can meet 4.1.2, but it is the hand-built way ACT-009 calls worse; use a `<button>`.

### Exceptions

- **A real link that also does something.** A link with a real address that records the click, prefetches its page, or opens another program, such as a `tel:` address, still goes somewhere. Leave it a link.
- **A jump on the same page.** `href="#transcript"` that moves to a part of the page is a link, not the `href="#"` this guideline is about.
- **Form controls.** Switching something with a checkbox, a switch or a select keeps that control's own role; FRM-012b covers them.
- **Menus and tabs.** Items inside a menu keep the menu item role, and Radix `Tabs` keep the tab role. Tabs that are routes are ACT-009a.
- **No `href` at all.** An `<a>` with only a click handler has no role, which ACT-009 requires to fix.
- **A product that chooses otherwise.** This is a guideline. A product that keeps such a link still gives it a name and keyboard use (ACT-001b, KBD-001).

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<a>` or `Link` with `href="#"`, `href=""` or `href="javascript:void(0)"` and an `onClick`. Leave alone `href="#section"` that jumps to a part of the page, and `href="#"` or `href="#top"` whose handler only scrolls to the top.
- An `onClick` on an `<a href>` or `Link` that calls `preventDefault()` and then acts in place instead of going to the address. Leave alone a handler that then goes to the same address, such as `router.push(href)`, a modifier-key check, or a smooth scroll to the `#section` it links to.
- A `DialogTrigger`, `AlertDialogTrigger`, `SheetTrigger`, `DropdownMenuTrigger`, `PopoverTrigger` or `CollapsibleTrigger` with `asChild` around an `<a>` or `Link`.

<a id="dlg-001"></a>

## DLG-001 Let Escape do what Cancel does in a dialog

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/dlg-001/

### Rule

In a dialog that has a dismissive action, which is Cancel, Close, a close icon or, where none of those exists, the button that leaves everything as it is, pressing Escape does exactly what that action does, including any check before unsaved input is thrown away, and never confirms, submits or runs the destructive or default action.

### Why

Escape is the key people press to back out. If it does something other than the visible way out, they lose control: a form is sent, a file is deleted, or a long text is gone without a word. When Escape and Cancel lead to the same place, a keyboard user can leave a dialog without hunting for the button, and anyone can trust that pressing it changes nothing they did not choose. WCAG does not ask for Escape. It does ask that a dialog can be used and left by keyboard, under [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) and [2.1.2 No Keyboard Trap](https://www.w3.org/TR/WCAG22/#no-keyboard-trap), and this rule supports both.

### Do

- In a dialog called "Rename folder" with *Cancel* and *Save*, pressing Escape closes the dialog and the folder keeps its old name, just as *Cancel* would.
- In a dialog called "New customer" where the person has typed a name and an address, *Cancel* first asks "Discard the changes?", as the guideline FRM-004b describes. Escape asks the same question, with *Cancel* and *Discard changes*. If the person picks *Cancel*, the dialog and every typed value stay as they were.
- In a dialog with only *I understand* and a close icon, Escape does what the close icon does. It does not count as pressing *I understand*.
- When a popup is open inside the dialog, such as the list under *Country* or a date picker, the first Escape closes only that popup. The next one closes the dialog.
- When *Cancel* and the close icon do different things, Escape follows the one that loses less of the person's work. FRM-004a has such a case: the close icon keeps a draft and *Cancel* discards, so Escape keeps the draft.
- A warning that the person will soon be signed out has *Stay signed in* and *Sign out*, and no *Cancel*. *Stay signed in* leaves everything as it is, so Escape does that, as STA-004 says.
- If a press on the backdrop closes the dialog, it takes the same path as Escape and *Cancel*, with the same check. This is our own point.
- Send Escape and the dismissive action through the same code, so they cannot drift apart. If you use the native HTML `dialog` element, handle its `cancel` event so Escape runs the same check as *Cancel*.
- Where focus goes when the dialog closes is decided by DLG-006: back to the control that opened it, or to a logical place nearby when that control is gone.

### Don't

- Let Escape press the default button. In "Save changes?" with *Save* highlighted, Escape must not save.
- Let Escape press the focused button. In "Delete the project?", Escape never deletes, even when focus is on *Delete*.
- Close a dialog with unsaved input straight away on Escape, when *Cancel* would have asked first.
- Let Escape do nothing in a dialog that has *Cancel* or a close icon.
- Close the whole dialog on the first Escape while a menu or list inside it is still open.

### Exceptions

- **No way out.** A dialog with no dismissive action at all, where every button commits something, is outside this rule. A dialog that destroys data always has Cancel, as DLG-003 says, so it is always inside this rule. Do not remove a way out only to avoid this rule.
- **While sending.** After the person has confirmed and the dialog shows that it is working, such as "Saving …", this rule does not decide what Escape does. STA-005a covers that moment. Its own choice is that Escape, *Cancel* and the close icon behave alike, and either stop the request or are unavailable until the reply.
- **Non-modal panels.** A side panel or a non-modal dialog that people can work beside is outside this rule.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Open the dialog and press Escape, then open it again and press *Cancel* or the close icon. Both should end the same way: the same close or the same discard question, and nothing saved, sent or deleted.
- An `onEscapeKeyDown` on `DialogContent` or `AlertDialogContent` that calls a save, submit or delete handler, or a native `<dialog>` whose `cancel` event skips the check *Cancel* runs. Leave alone a dialog that holds Escape while it shows progress such as "Saving …" (see Exceptions).
- With input typed, compare the *Cancel* handler with `onOpenChange(false)`: if *Cancel* checks `isDirty` or asks "Discard the changes?" but Escape, which arrives through `onOpenChange`, closes at once, Escape skips the check.
- With a select, combobox, menu or date picker open inside the dialog, press Escape once and see whether only that popup closes while the dialog stays open.
- In a modal dialog that has *Cancel* or a close icon, press Escape and see whether anything happens. Leave alone non-modal side panels and dialogs where every button commits something.

<a id="dlg-002"></a>

## DLG-002 Keep one dialog open at a time

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/dlg-002/

### Rule

Never open a dialog on top of another dialog. Show any further step, including a question about discarding typed input, by replacing the open dialog's content, and a failed main action as a notice inside it, or close the dialog and move the work to a page. Only a full-screen dialog may have a short confirmation or alert on top.

### Why

A dialog already takes the person away from the page and hides part of it. A second dialog on top hides even more, and the person has to keep two unfinished things in mind at once. They also have to close the layers in the right order to get back. On the web, each layer holds focus, so two layers mean two places where focus can get lost when one closes. One dialog at a time keeps the path short: in, do the task, out. No WCAG criterion forbids a second dialog. [WCAG 2.2, 2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order), [2.1.2 No Keyboard Trap](https://www.w3.org/TR/WCAG22/#no-keyboard-trap) and [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) are all easier to meet with one layer than with two. This rule is our design choice.

### Do

- A dialog *Edit profile* has a button *Choose department* that needs a long list. The list replaces the dialog's content, with a *Back* button that brings back the profile fields as the person left them.
- A flow to add a new user has three steps. Each step replaces the last inside the same dialog, and the dialog shows "Step 2 of 3".
- The person has typed in a dialog *New note* and presses *Cancel*. The dialog asks first, as the guideline FRM-004b describes: its content is replaced by the question "Discard this note?" with *Cancel* and *Discard note*. *Discard note* names the action, as DLG-003 says, and uses the danger style, as DLG-005 says. Focus starts on *Cancel*, as DLG-004 says. *Cancel* brings back the note as the person left it and puts focus on the *Cancel* button they pressed.
- *Save* in a dialog *Edit customer* fails because a colleague changed the same customer a minute ago. Add a notice inside the dialog, above the buttons, such as "Someone else changed this customer while you were typing. Copy what you want to keep, then reload." Keep everything the person typed.
- A form that holds a lot of typed input lives on a page, or in a full-screen dialog on a small screen.
- On a phone, the person fills in a damage report for their car in a full-screen dialog *Damage report*, then closes it. One short confirmation opens over it: "Discard the damage report?" with *Cancel* and *Discard report*. *Cancel* closes the confirmation and puts focus back on the control in the full-screen dialog that opened it.
- While that confirmation is open, the dialog beneath cannot be reached with the keyboard, the mouse or a screen reader. Only the top layer is marked as a modal dialog, and it has its own role and name. Escape does what *Cancel* does, so it closes only the confirmation.
- The main action succeeds. Close the dialog and show the result as a message on the page, such as "Profile saved", not as another dialog.

### Don't

- Open *Choose department* as a second dialog on top of *Edit profile*.
- Open each step of a flow as a new dialog over the one before.
- Open "Discard this note?" as a second dialog on top of an ordinary dialog. Replace the dialog's content instead.
- Show "Someone else changed this customer" in an alert over an ordinary dialog.
- Show a field's error, such as "Enter a valid phone number", in a dialog over a form dialog. It belongs at the field, as FRM-002a says.
- Label the choices in a discard question *Yes* and *No*, or *Keep writing* in place of *Cancel*.
- Let a confirmation over a full-screen dialog offer a new task, such as *Save as template …* that opens a further dialog.
- Show two confirmations over a full-screen dialog at the same time.

### Exceptions

- **One short confirmation over a full-screen dialog.** A full-screen dialog covers the whole screen and is meant for small screens. One short confirmation or alert about it may open on top, but only when closing it would throw away what the person entered, or when its main action failed for a reason not tied to a field, such as a clash with someone else's change. It holds no task of its own, opens nothing further, and returns focus to the full-screen dialog when it closes. Never show two at once. Field errors are never covered by this exception. A discard confirmation follows DLG-003, DLG-004 and DLG-005.
- **Menus, pickers and popovers.** A dropdown menu, a date picker, a tooltip or a popover that opens from a control inside a dialog is not a dialog, and this rule does not cover it.
- **Non-modal panels.** A side panel that leaves the page usable is not a modal dialog and is outside this rule.
- **What Escape does.** Escape does what Cancel does, as DLG-001 says. In a discard question that replaced the dialog's content, it brings back the content. In a confirmation over a full-screen dialog, it closes only the confirmation.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- With a dialog open, press each of its buttons, including *Cancel* after typing, and see whether a second `role="dialog"` or `role="alertdialog"` opens on top instead of the content being replaced. Menus, selects, date pickers and popovers do not count.
- A `<Dialog>` or `<AlertDialog>` rendered inside another `DialogContent` or opened from a handler in it, such as a discard question over a form dialog. Leave alone one short confirmation over a full-screen dialog.
- A field error or a failed save shown in an alert dialog over a form dialog, where it belongs at the field or as a notice inside the same dialog.
- Over a full-screen dialog: a confirmation that offers a new task or opens a further dialog, or two confirmations open at the same time.

<a id="dlg-003"></a>

## DLG-003 Name the action on the destructive button and always offer Cancel

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/dlg-003/

### Rule

In a dialog that asks the person to confirm a destructive action, label the button that performs it with a verb that names that action, never "OK", "Yes" or another word that does not say what will happen, and always include a button labelled Cancel that is enabled and closes the dialog with nothing changed.

### Why

A destructive action deletes, overwrites or takes away something the person cannot easily get back. A dialog that checks before such a step only helps if each button says plainly what it will do. "OK" and "Yes" make the person read the question again and work out what the answer means, and people in a hurry skip that step. A button that reads *Delete project* states the result on its face, and a screen reader user hears the same words. A Cancel button that always works is the other half: there has to be a plain, safe way back, with no doubt about whether leaving will run the action. No WCAG criterion asks for these labels. They help meet [WCAG 2.2, 2.4.6 Headings and Labels](https://www.w3.org/TR/WCAG22/#headings-and-labels), and a visible label that is also the button's accessible name supports [2.5.3 Label in Name](https://www.w3.org/TR/WCAG22/#label-in-name) and [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value). A chance to check before a final step is one of the safeguards that [3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) accepts where it applies. Being able to undo the action is another, and it is often kinder than asking.

### Do

- A dialog titled "Delete the project Autumn 2026?" has the buttons *Cancel* and *Delete project*.
- Use the same verb in the title and on the button: "Remove Jordan Lee from the team?" with *Remove*. A short verb is enough when the title says what it acts on. Adding the object, as in *Remove member*, is clearer still.
- Name the real result: *Revoke access*, *Reset settings*, *Delete all receipts*.
- Label the safe button *Cancel* in every such dialog, so people always find the way back under the same word, and let it close the dialog with nothing changed. Escape does the same, as DLG-001 says.
- If *Delete project* stays unavailable until the person types the project's name, keep *Cancel* usable the whole time, and show the text before the button that ACT-005 asks for.
- Use the visible text as the button's accessible name, so a voice control user can say "Delete project" and a screen reader reads the same words.

### Don't

- Ask "Do you want to delete the project?" with *OK* and *Cancel*, or with *Yes* and *No*.
- Put *Confirm* or *Continue* on the button that deletes. Neither word says what will be lost.
- Offer only *Delete* and a close icon, with no *Cancel*.
- Grey out *Cancel* until something else is done, or let it run any part of the action.
- Give *Delete project* an `aria-label` such as "Confirm" that differs from its visible text.

### Exceptions

- **Actions that can be undone.** Archiving a project that stays one click away under *Archive* needs no dialog. Show a message with *Undo* instead. DST-001b decides when a dialog is needed at all, and DST-001a how *Undo* is offered. When no dialog is shown, this rule does not apply.
- **While the action runs.** After the person has pressed the destructive button and the dialog shows progress, such as "Deleting …", STA-005a covers what Cancel, Escape and the close icon do. Its own choice is that Cancel stops the request only when it can truly be withdrawn, and that otherwise all three are unavailable until the reply.
- **Focus and style.** Where focus lands when the dialog opens is covered by DLG-004, and how the destructive button looks by DLG-005.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- In a destructive confirmation, an `AlertDialogAction` or button with `variant="destructive"` whose text is "OK", "Yes", "Confirm", "Continue" or "Proceed" rather than a verb that names the action, such as "Delete project".
- An `AlertDialogContent` with a destructive action but no `AlertDialogCancel` or *Cancel* button, for example only *Delete* and a close icon.
- An `AlertDialogCancel` or *Cancel* button in a destructive confirmation that is `disabled`, says something other than "Cancel" such as "No" or "Keep", or runs part of the action. Leave alone `disabled` set only while the action runs and shows progress (see Exceptions).
- A destructive action button whose `aria-label` differs from its visible text, such as `aria-label="Confirm"` on *Delete project*.

<a id="dlg-004"></a>

## DLG-004 Never make the destructive button the default in a confirmation dialog

Guideline, our choice. Verdict: Split (1 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/dlg-004/

### Rule

In a dialog that asks the person to confirm a destructive action, put initial focus on the Cancel button, never on the destructive button, and never let Enter run the destructive action unless the person has moved focus to that button.

### Why

The moment a dialog opens is the moment people are most likely to act without reading. Their hands are already on the keyboard, and Enter is the reflex that clears the way. If focus starts on the destructive button, or Enter fires it from anywhere in the dialog, that reflex deletes the project the person meant to keep. Starting on Cancel turns the dialog into a real pause: the person has to pick the destructive button on purpose, with Tab or a click, before anything is lost. [WCAG 2.2, 2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order) asks that focus moves in an order that keeps meaning and use intact. It does not say which element in a dialog gets focus first, so this rule is our choice. The pause it gives also supports [3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) where that criterion applies.

### Our reasons

The judges are split on this, so we chose. We start focus on Cancel in every destructive confirmation, also when the person asked for the action, for three reasons.

- **A stray key press must not destroy data.** People press Enter out of habit, to clear whatever box is in the way, and sometimes by accident. A habit that saves a second must never cost a project, a customer list or a year of photos.
- **On the web, first focus decides what Enter does.** A web page has no system default button that Enter presses from anywhere. Enter acts on the element that has focus. Choosing where focus lands is therefore the same as choosing what Enter will do, and we choose the answer that changes nothing.
- **The cost is one key press.** A person who meant to delete presses Tab once and then Enter, or clicks the button. That small step is the price of the pause, and it falls only on people who have already decided.

### Do

- "Delete the project Autumn 2026?" opens with focus on *Cancel*. Enter now closes the dialog with nothing changed. To delete, the person moves to *Delete project* with Tab and presses Enter, or clicks it.
- Set initial focus on *Cancel* in code, for example with `autofocus`, rather than leaving it to whichever element comes first.
- Keep the buttons in the same order in every layout. If *Cancel* comes before *Delete project* in a row, it also comes first when the buttons stack on a small screen, in the code and on screen alike, as LAY-002 says.
- Give the dialog its title as its name and its question as its description, for example with `aria-labelledby` and `aria-describedby`, so a screen reader can read them when focus lands on *Cancel*.
- A dialog asks the person to type the project's name before *Delete project* works. Focus starts on *Cancel* as usual. Enter in the name field does nothing or moves focus on. It never runs the deletion, so the person still has to reach the button.
- Once the person has moved focus to *Delete project*, Enter and Space press it, as with any button.

### Don't

- Open the dialog with focus on *Delete project*, even when the person has just chosen *Delete* in a menu.
- Wrap the dialog in a form whose submit button is *Delete project*, so Enter in the name field deletes the project.
- Listen for Enter anywhere in the dialog and run the deletion, whatever has focus.
- Reverse the buttons when they stack, so *Delete project* comes first on a small screen. That breaks LAY-002, and focus left to the first button lands on the wrong one.
- Mark *Delete project* as the button Enter will press, with a ring or a hint, before the person has moved to it.

### Exceptions

- **Escape.** Escape does what Cancel does wherever focus is, as DLG-001 says.
- **Actions that can be undone.** When an action can be undone at once and no dialog is shown, this rule does not apply.
- **Labels and style.** What the buttons say is covered by DLG-003, and how the destructive button looks by DLG-005.
- **Enter in a form.** FRM-015 lets Enter send a form, but leaves destructive confirmations to this rule.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Open a destructive confirmation and see where focus lands. It should be on *Cancel*, not on the destructive button, the close icon or the dialog itself. Then press Enter at once and see that nothing is destroyed.
- `autoFocus` or `data-autofocus` on the destructive button, or an `onOpenAutoFocus` that focuses it.
- A destructive confirmation wrapped in a `<form>` whose submit button is the destructive action, so Enter in a field such as "Type the project name" runs it.
- An `onKeyDown` on the dialog content, or a `keydown` listener on `document`, that runs the destructive action on Enter whatever has focus.
- A destructive confirmation built on `Dialog` instead of `AlertDialog`, where first focus falls on the first control and that control is not *Cancel*.

<a id="dlg-005"></a>

## DLG-005 Give the destructive button the danger style, also when the person asked for the action

Guideline, our choice. Verdict: Split (1 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/dlg-005/

### Rule

In a dialog that asks the person to confirm a destructive action, give the destructive button the danger style, even when the person has just asked for that action. Its label still names the action, as DLG-003 says, so colour is never the only sign of danger.

### Why

A red button says "stop and look" before the words are read. In a confirmation dialog that is the last chance to notice that the wrong project, the wrong person or the wrong file is about to go. Colour alone is not enough, though. Some people cannot tell red from other colours, some use a high contrast mode that replaces it, and a screen reader does not announce it. The label has to carry the same meaning, which is why this rule leans on the naming in DLG-003. [WCAG 2.2, 1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) does not ask for a red button. It does mean that if the red signals danger, something else must signal it too, and the label is that something. The text on a red button must also be easy to read against it, under [1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum).

### Our reasons

The judges are split on this, so we chose. We use the danger style on every destructive confirmation, also when the person asked for the action, for three reasons.

- **A last warning before a loss.** Asking for something and seeing what it will do are not the same. The person chose *Delete* a moment ago, perhaps on the wrong row. The colour is one more cue at the only point left where that slip can be caught. Once the action has run, there is nothing left to warn about.
- **One colour, one meaning.** Justified's `Button` has a `destructive` variant for actions that destroy something. The confirmation dialog is where that action finally runs. Leaving the variant out there would weaken its meaning in the one place it matters most.
- **The label carries the meaning anyway.** The colour is an extra for those who can see it. People who cannot get the same warning from the words *Delete project*, so nobody depends on the red alone.

### Do

- In "Delete the project Autumn 2026?", *Delete project* uses `variant="destructive"` and *Cancel* uses `variant="outline"`.
- The person picks *Delete* on a row in a list of invoices, and a dialog asks "Delete invoice 2026-0412?". *Delete invoice* is red, even though they asked for it.
- Let the title and the button name the same action, so the warning is in the words as well as the colour.
- Use Justified's destructive tokens as they are. The contrast of the button's text against its red is tested in the light and the dark theme. If you change the colours, check the text again against 1.4.3, as VIS-001 describes, and keep each token on the fill it was made for, as VIS-002 asks.
- Add an icon such as a bin next to the label if you like. The text still carries the meaning; the icon is an extra.

### Don't

- Show a red button labelled *OK* or *Yes*. The colour warns, but the words do not say of what.
- Draw *Delete project* in the same style as *Save* because the person asked for it.
- Make *Cancel* red, or use red for an action that destroys nothing, such as *Send*. Red that shows up everywhere stops warning.
- Style *Cancel* as the main, filled button to steer people away from deleting. Focus starts on it, as DLG-004 says, but that is a safe place to start, not an answer chosen for them.
- Signal the danger only with a red border or a red icon, with no words that say what will be lost.
- Fade or tint the red button while it can be pressed, so its text no longer reaches the contrast the tokens are tested for. While it is unavailable, for example until the project's name is typed as DLG-003 describes, the faded look of a disabled `Button` is fine, and ACT-005 says what text goes before it.

### Exceptions

- **Actions the person asked for.** These are not an exception. They are the case this rule is written for.
- **Actions that can be undone.** When an action can be undone at once and no dialog is shown, this rule does not apply.
- **Labels and focus.** What the buttons say is covered by DLG-003. The red button never takes focus when the dialog opens, as DLG-004 says.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- In an `AlertDialogFooter` or other confirmation, an `AlertDialogAction` or button labelled with a destructive verb, such as "Delete", "Remove", "Erase" or "Revoke", that has no `variant="destructive"`. Leave alone a delete button in an edit form that runs at once and offers Undo.
- `variant="destructive"` on *Cancel*, or on an action that destroys nothing, such as *Send* or *Save*.
- *Cancel* styled as the filled main button, with `variant="default"`, while the destructive action uses `outline`, `secondary` or `ghost`.
- Classes such as `opacity-*` or `bg-destructive/60`, or a custom red, on a destructive button that can be pressed, which may lower its text contrast. Leave alone the faded look of a `disabled` button.
- Danger shown only by a red border, red text or a red icon, or a red button whose label does not name the action, such as a red *OK*.

<a id="dlg-006"></a>

## DLG-006 Move focus into a modal dialog when it opens and back to its opener when it closes

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/dlg-006/

### Rule

When a modal dialog opens, keyboard focus moves into it. When it closes, focus returns to the control that opened it, or to a logical place nearby if that control is gone.

### Why

A keyboard or screen reader user is wherever focus is. If a dialog opens and focus stays on the button behind it, they are still on the page: they may not know that anything opened, and they must hunt for the dialog with Tab, if they can reach it at all. If the dialog closes and focus drops to the start of the page, they have lost their place and must travel back to it key by key. [WCAG 2.2, 2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order) requires that focus moves in an order that keeps meaning and use intact. The criterion does not mention dialogs. This rule rests on how the Working Group reads it for them: it lists as a failure a dialog that the keyboard cannot get to at once when it opens, or that leaves focus somewhere senseless when it closes (see [F85](https://www.w3.org/WAI/WCAG22/Techniques/failures/F85)). That failure passes a dialog in two ways when it opens: focus is put in it, or it is simply the next stop in the tab order after its opener. It allows both for any dialog, modal or not. For a modal dialog this rule takes the first way. That is our reading of the criterion, not something the failure says: the Working Group's own modal example and technique move focus in, and the opener cannot keep focus once the page behind is out of use. LAY-002 describes the second way for panels that are not modal. On closing, the Working Group's modal example also accepts the control right after the opener, while this rule follows the failure's test and asks for the opener whenever it still exists. Staying inside while the dialog is open is DLG-007.

### Do

- On the page *Expenses*, the person presses *Add expense*. The dialog *Add expense* opens, with *Amount*, *Category*, *Cancel* and *Add expense*, and focus is inside it at once. Here it lands in *Amount*. When the dialog closes, focus is on the page's *Add expense* button again, and the next Tab goes on from there.
- Return focus the same way whichever route closed the dialog: *Cancel*, the close icon, Escape, a press on the backdrop if that closes it, or the main action once it has succeeded.
- A manager presses *Send back* on a claim under *Waiting for approval*. The dialog *Send back claim* has the field *Reason*, then *Cancel* and *Send back claim*. Once the claim is sent back it leaves the list, and the button that opened the dialog goes with it. Focus goes to the claim that took its place in the list, or to the one before it if it was the last.
- If that was the only claim, focus goes to the heading *Waiting for approval*, which can take focus from script (`tabindex="-1"`) and now sits above the text "No claims are waiting." That text is the empty state STA-002a describes.
- The dialog *Change category* is opened from an item in a claim's *More actions* menu. The menu has closed by the time the dialog does, so focus goes to the *More actions* button of that claim.
- Which place is "nearby" when the opener is gone is for the product to decide, case by case. The order above, the neighbouring item first and then the heading of the list, is our own choice.
- A list or date picker opened inside the dialog, such as the one under *Category*, returns focus to its own control inside the dialog when it closes.
- This rule does not say which element in the dialog gets focus first, and neither does the criterion: the dialog itself, its heading or a control inside it are all acceptable. DLG-004 decides it for a destructive confirmation, where focus starts on *Cancel*.
- A dialog the product opens itself, such as the sign-out warning in STA-004, has no opener. Focus still moves into it, and when it closes it goes back to the element that had focus just before, or to a logical place if that element is gone. The documented failure is about dialogs opened from a control, so this case is our own choice, made in the spirit of the same criterion. Keep such dialogs rare; they move focus when the person did nothing.
- When a question replaces a dialog's content, as DLG-002 and FRM-004b describe, no dialog opens or closes, but the control that had focus disappears. We treat it as an opening and a closing inside the same layer, which is our own application of this rule. The person presses Escape in *Send back claim* after typing in the text area *Reason*. "Discard this reason?" takes the form's place with *Cancel* and *Discard reason*, and focus moves to *Cancel*, as DLG-004 says. *Cancel* brings the form back with focus in *Reason*, where it was.
- When the one short confirmation that DLG-002 allows over a full-screen dialog closes, focus returns to the control in the full-screen dialog that opened it.
- The adapter's `Dialog` starts focus on the element marked `data-autofocus`, or without one on the first control after the close icon, so a form starts in its first field. `AlertDialog` starts on *Cancel*. Those starting points are our own choice.
- On closing, both put focus back on the element that had it when the dialog opened, also when the dialog was opened without a trigger. If that element is no longer in the page, the adapter does nothing, and focus is then lost until the product sets it. Set the fallback yourself in `onCloseAutoFocus`.
- The native HTML `dialog` element opened with `showModal()` moves focus in and returns it to the opener if the opener still exists. The fallback is still yours to write.
- Moving focus in, and not leaving the dialog as the next Tab stop, is our reading of the criterion for modal dialogs; see Why.

### Don't

- Open *Add expense* and leave focus on the button behind it, so a keyboard user must pass every link and field on the page before *Amount*, or never gets there.
- Let focus fall to the start of the page when the dialog closes, so the person tabs from the top to get back to *Add expense*.
- Return focus after *Cancel* but not after Escape, or not after the main action succeeded.
- Leave focus on nothing after *Send back claim* removed the claim, on the grounds that the opener no longer exists.
- Send focus to the first link on the page when the next claim in the list is right there.
- Move focus into the dialog only after its content has loaded, so the first key presses land on the page behind.

### Exceptions

- **Non-modal panels, menus and popovers.** This rule covers dialogs and sheets that are modal. For a panel that people work beside, LAY-002 says how the keyboard reaches it and comes back.
- **The closing action leaves the page.** When the dialog's main action ends on another page, such as *Create report* that opens the new report, there is no opener to go back to. Where focus starts on the new page is outside this rule.
- **While sending.** What focus does between the press on the main action and the reply is covered by STA-005a. Its own choice is to keep focus on the pressed button.
- **Neighbouring rules.** Keeping focus in the dialog while it is open is DLG-007. Escape is DLG-001, the order of the controls inside the dialog is LAY-002, and the visible focus indicator is KBD-001. First focus in a destructive confirmation is DLG-004.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Open the dialog from its button and see whether focus is inside it at once. Close it by *Cancel*, the close icon, Escape, the backdrop and a successful main action, and see whether focus is back on the opener each time.
- Run an action that removes the opener, such as sending back or deleting its row, and see where focus goes: to a neighbouring item or the list heading, never to `<body>` or the start of the page.
- An `onCloseAutoFocus` that calls `preventDefault()` and sets no focus, or a dialog opened from a `DropdownMenuItem` that leaves focus nowhere on close. Leave alone a main action that moves to a new page (see Exceptions).
- A modal that gets focus only after its content has loaded, or a custom modal built from a `div` with no code that moves focus in on open and back on close.

<a id="dlg-007"></a>

## DLG-007 Keep Tab inside a modal dialog and the page behind it out of use

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/dlg-007/

### Rule

While a modal dialog is open, Tab and Shift+Tab stay within it, and nothing behind it can be used until it closes.

### Why

A modal dialog says: answer this first. A sighted mouse user gets that message from the dimmed page. A keyboard user gets it only if Tab stays in the dialog. If Tab walks on into the page behind, focus disappears under the dialog or its backdrop, and the person may change something they cannot see while the question is still waiting. No WCAG criterion requires a modal dialog to hold focus, so the judges decide this rule. The law permits it and is easier to meet with it. Holding focus is not a trap under [WCAG 2.2, 2.1.2 No Keyboard Trap](https://www.w3.org/TR/WCAG22/#no-keyboard-trap) as long as the dialog can be closed from the keyboard, which DLG-001 and KBD-001 see to. Focus that never goes behind the dialog cannot be hidden by it, which helps meet [2.4.11 Focus Not Obscured (Minimum)](https://www.w3.org/TR/WCAG22/#focus-not-obscured-minimum), and a focus order that stops at the dialog's edge supports [2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order). What a dialog tells assistive technology about itself should be true, as [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks of every state, and a dialog announced as modal is only truthful when the page behind is out of use, so the rule supports that criterion too. How focus gets in and where it goes afterwards is DLG-006.

### Do

- In a meal planner, the dialog *Plan a meal* has a close icon, *Day*, *Recipe*, *Servings*, *Cancel* and *Add to plan*. Tab on *Add to plan* goes to the close icon, the first control in the dialog. Shift+Tab on the close icon goes to *Add to plan*.
- Behind the dialog, the week's grid, the shopping list and the navigation cannot be clicked, tapped or tabbed to until the dialog closes.
- Keep a screen reader in the dialog too. Its own reading keys do not use Tab, so a Tab loop alone does not stop it from wandering into the week's grid. This is our own technical point, and it supports 4.1.2: what is announced as modal should be modal.
- Our own choice of technique: make the page behind inert, with the `inert` attribute or with the native `dialog` element opened with `showModal()` (see [H102](https://www.w3.org/WAI/WCAG22/Techniques/html/H102)), rather than rely on a script that catches Tab. Inert stops the keyboard, the pointer and assistive technology in one step.
- Mark the dialog as modal in code, with `aria-modal="true"` or the native element, only when the page behind really is out of use.
- Hold focus only in a dialog that can be closed from the keyboard. Escape does what *Cancel* does, as DLG-001 says, and *Cancel* is always there in a form, as FRM-003 says.
- The list of recipes under *Recipe* and the calendar under *Day* belong to the dialog, even if the code draws them elsewhere in the page. Focus may move into them and comes back to their control.
- The browser's own controls, such as the address bar, are not the page behind. With the native `dialog` element Tab may pass through them before it returns to the dialog, and that is fine.
- When one short confirmation sits over a full-screen dialog, as DLG-002 allows, the full-screen dialog counts as the page behind for as long as the confirmation is open.
- A press on the backdrop either takes the dismissive path in DLG-001 or does nothing. It never reaches a control underneath. In the adapter's `AlertDialog` the press does nothing, and focus stays where it was in the dialog. In `Dialog` the press closes the dialog, and focus goes back to the opener as DLG-006 says. If something holds the close, such as a discard question, the dialog stays open and focus stays where it was in it. Keeping focus in place on a press that does not close is our own choice.
- The adapter's `Dialog` and `AlertDialog` are modal: Radix, which they are built on, keeps Tab inside, and the content is marked `aria-modal="true"`. A dialog opened over another makes the one beneath inert. Do not pass `modal={false}` to `Dialog`: it turns the hold off while the content is still marked as modal. Check in your own build, with a screen reader, that nothing behind the dialog is read.

### Don't

- Let Tab leave *Plan a meal* after *Add to plan* and move through the week's grid behind the backdrop.
- Dim the page but leave its links open to a click, or the other way round: block the pointer and let Tab through.
- Catch Tab in a script and stop there, so a screen reader still reads the page behind and can press its buttons.
- Set `aria-modal="true"` on a panel that people are meant to work beside.
- Hold focus in a dialog that has no way out from the keyboard. That is the trap 2.1.2 forbids.
- Hold the keyboard in a layer that still lets the pointer use the page, and call it non-modal. Choose one: modal and closed off, or non-modal and free. An overlay panel that keeps focus inside until it is closed, as KBD-002 allows, counts as modal here, so the page behind it is out of use too.

### Exceptions

- **While sending.** Between the press on the main action and the reply, STA-005a may make *Cancel*, Escape and the close icon unavailable. That wait ends with the reply or with a failure the person can act on, so the dialog is not one without a way out.
- **Non-modal panels, toasts and tooltips.** A panel people work beside, a toast or a tooltip never holds focus. LAY-002 covers how the keyboard reaches a panel, and KBD-002 what a layer may cover.
- **A busy layer.** Content under a loading layer is made unreachable in the same way, but that moment belongs to STA-001.
- **Neighbouring rules.** Moving focus in and back is DLG-006. Leaving the dialog by keyboard is DLG-001 and KBD-001. One dialog at a time is DLG-002.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- With the modal open, press Tab past the last control and Shift+Tab past the first, and see whether focus wraps inside the dialog and never reaches the page behind. Browser controls such as the address bar do not count.
- With the modal open, click the page behind and use a screen reader's reading keys, and see whether anything behind can be reached, read or pressed.
- `modal={false}` on a `Dialog`, or on a `Sheet` that should hold the person until it closes, or `aria-modal="true"` on a panel people are meant to work beside. A non-modal side panel that is not marked modal is fine.
- A custom overlay that catches Tab in a `keydown` handler but leaves the page behind without `inert`, or that blocks the pointer and lets Tab through.

<a id="dst-001a"></a>

## DST-001a Make destructive actions reversible, and offer Undo instead of asking first

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/dst-001a/

### Rule

Make destructive and other significant actions reversible wherever the product can, and when an action can be fully reversed, carry it out at once and offer Undo right after it. DST-001b decides when a question is still needed; it never is for a routine action that Undo fully reverses.

### Why

People slip. They pick the wrong row, tap a moment too early or change their mind a second later. A question before every such step does not stop that for long: when it comes every time, people answer it without reading, and then it protects nothing. An Undo works the other way round. The person gets what they asked for at once, and a mistake costs one click to put right. That only holds if the reversal is real and easy to reach. It has to bring back everything as it was, and it has to stay long enough to be used. A message that closes after a few seconds can be gone before someone who uses a screen reader, magnification or a switch has reached it. Keeping *Undo* until the person is done with it means no one has to race a timer, which stays clear of the time limits that [WCAG 2.2, 2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable) is about. On the web, as we read it, a visible Undo is needed: the browser's own undo reaches text being typed, not what an app does with its own data, so without a control on the page there is no way back at all. Where [3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) applies, a way to reverse the action is one of the safeguards it accepts. Checking the input or a chance to confirm are the others, so the criterion does not ask for Undo. Choosing Undo over a question is our design choice.

### Do

- The person archives the project *Autumn 2026*. It leaves the list at once, and a message near the list says "Project Autumn 2026 archived" with the button *Undo*. *Undo* puts it back in the same place, and the project also stays under *Archive*.
- The person removes the tag *Receipt* from twelve files at once. The tags disappear, and the message "Tag Receipt removed from 12 files" offers *Undo*, which puts the tag back on exactly those twelve files.
- Build the reversal before choosing not to ask. Move a deleted item to *Deleted items* for 30 days instead of erasing it, or keep the previous values of a settings page under *History*, so *Undo* can restore them all and the person can still do so later.
- Let *Undo* bring back the whole previous state: the item, its contents, its comments, its tags, its place in the list and who could see it.
- Say in the message what happened, so *Undo* is clear without guessing. If the button needs a longer accessible name, start it with the visible word, such as "Undo archiving Autumn 2026".
- Keep *Undo* on screen for as long as FBK-005 says: until the person uses it, closes it or leaves the view, or a newer message makes it moot. Nobody has to catch it in time. After that, a lasting way back such as *Deleted items*, *Archive* or *History* remains.
- Show the new state in the view itself, as FBK-003 says. The message is an addition, never the only sign. Announce the message without moving focus, as FBK-004 says.
- Make *Undo* reachable with the keyboard in the normal tab order. A shortcut such as Ctrl+Z may also work, but never as the only route.
- If the server refuses a delete that has already left the list, the item comes back in its place, the message with *Undo* is withdrawn, and the failure shows where FBK-002 says (STA-005a).
- After *Undo*, show the project back in its place. If focus was on *Undo* and the message closes, move focus to the restored project.
- The person presses *Delete* in the dialog *Edit contact*. The action closes the dialog, the contact leaves the list, and *Undo* is offered on the page. No confirmation question is added. If one were, DLG-002 would have it replace the dialog's content.

### Don't

- Put a question such as "Archive this project?" in place of *Undo*. Whether to ask is for DST-001b, and an archive that *Undo* or *Archive* reverses in one click is the kind of step it lets run at once.
- Let the message with *Undo* close by itself after five seconds while the person is still in the view.
- Offer *Undo* that brings back the project but not its files, or the tag on some files but not all of them.
- Hide the reversal behind Ctrl+Z alone, with nothing on the screen.
- Move focus into the message when it appears, so the person is pulled away from what they were doing.
- Erase a record for good because a soft delete was more work to build. "Where the product can" means what is possible, not what is convenient.
- Show *Undo* for something that has already left the product, such as an email sent to a customer, as if it could call it back.

### Exceptions

- **Actions that cannot be fully reversed.** A payment that has gone through, a message delivered to other people or a legal step has no full Undo, so this rule's second half does not apply. DST-001b decides whether to ask first, also for a step that can be reversed but would cost a lot if it went wrong. How that question looks and behaves is covered by DLG-003, DLG-004 and DLG-005.
- **Unsaved input in a dialog, a sheet or on a page.** FRM-004a decides what closing a full-screen dialog does, and the guideline FRM-004b what closing a smaller dialog or a sheet does. The guideline FRM-004c decides what leaving a page does, and the guideline FRM-004d prefers keeping the work there. If closing or leaving keeps a draft the person can get back, nothing is thrown away and no question is asked.
- **Typing in a field.** Changing text the person is still typing is not an action in this rule. The browser's own undo covers it.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- For each delete, archive, remove or bulk change, ask whether the product can bring back the whole previous state. If it can, the step should run at once and offer *Undo*, with no confirmation question first.
- Code that erases a record for good, such as a hard `DELETE`, and ask whether a soft delete to *Deleted items*, an archive or a kept history could make it reversible.
- A sonner `toast` with an *Undo* `action` that closes by itself while the person is still in the view, because neither it nor the `Toaster` sets `duration: Infinity`.
- An *Undo* that restores only part, such as the item without its files, comments or place in the list, or an *Undo* shown for something that has left the product, such as a sent email.
- An *Undo* reachable only by Ctrl+Z with nothing on screen, or a message with *Undo* that takes focus when it appears.

<a id="dst-001b"></a>

## DST-001b Ask before an action only when it cannot be reversed or a mistake would cost a lot

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/dst-001b/

### Rule

Ask the person to confirm a step only when it cannot be reversed and destroys, spends or commits something of value, or when a mistake would cost a lot and be hard to put right, such as a charge to a card; never ask before any other step.

### Why

A question before a step is a small wall. Put up rarely, it makes people stop and read. Put up for everything, it becomes a click people make without looking, and then it fails on the one day it matters. So the question is kept for the two cases in the rule, where there is no way back from a real loss, or where the way back is long, costly or uncertain. Inside those cases, choosing the step on purpose is no reason to skip the question. For every other step, the safeguard is to let it happen and make it easy to take back, as DST-001a describes. That includes routine steps, and it includes rare steps that cost little and can be fully reversed. A routine step is one people take often in their normal work, and that costs little if it goes wrong. "Fully reversed" means the whole previous state comes back, for the person who acted, right after they acted. "Never ask" is our firm reading: outside those two cases, a question costs more attention than it saves. For pages that make payments or legal commitments, or that change or delete data the person has stored in the product, [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) accepts a chance to review and confirm as one safeguard and a way to reverse as another. It requires neither one in particular. Asking only rarely, and preferring Undo where it is possible, is our design choice on top of that.

The rule as a test, taken in order:

1. Can the whole previous state be brought back, by the person who acted, right after they acted? Then never ask. Run the step and offer *Undo*.
2. If not, does the step erase stored data, move money or commit the person to something, such as an invoice or a legal step? Then ask.
3. Otherwise, do not ask.

A way back that is slow, costly or uncertain counts as no way back in the first step.

### Do

- Ask before *Delete March readings* when the readings are stored nowhere else.
- Ask before *Pay $4,800*. Money that has left the account is slow and uncertain to get back.
- Ask before *Cancel booking* when the $500 fee is not refunded.
- Ask before *Send invoice to customer*. Once it is in someone else's inbox, the product cannot pull it back, and the customer now owes money.
- Ask before *Delete 2024 receipts* when it erases 340 receipts for good. DLG-003 covers how the question names what is lost.
- Archive a project at once when *Archive* brings it back with one click. Show a message with *Undo* instead of a question, as DST-001a says.
- Remove the tag *Draft* from twelve files at once when *Undo* puts it back on all twelve.
- Reset a dashboard to its default layout without a question, even though people seldom do it, when *Undo* brings back the old layout.
- When you do ask, word the question and the buttons as DLG-003 says, place focus as DLG-004 says, and style the action as DLG-005 says. If the step is started inside a dialog, the question follows DLG-002.

### Don't

- Ask "Hide the Price column?" when the column can be shown again with one click.
- Ask before every change to a setting that can simply be switched back.
- Show the same warning style and the same question for archiving a project as for erasing a year of bookkeeping. When every step gets a question, people stop reading them.
- Skip the question before *Delete March readings* because the person picked it from a menu on purpose.
- Count a payment as reversible because an *Undo* link shows for five seconds. A short-lived Undo is not a full way back for money or a legal step.

### Exceptions

- **Routine sends.** A chat message, a comment or a reaction cannot be called back once others have seen it, but it is a routine step that spends or commits nothing of value. Send it without a question.
- **Undo that covers only part.** When a step on many items has an Undo that brings back only some of what changed, and what is lost has value, treat the rest as something that cannot be reversed and ask. When Undo brings back everything, as with the tag on twelve files, do not ask.
- **Unsaved input in a dialog, a sheet or on a page.** Closing a view or leaving a page that would throw away unsaved input is not decided by this rule. FRM-004a covers full-screen dialogs, the guideline FRM-004b covers dialogs and sheets that do not fill the screen, and the guideline FRM-004c covers pages, with FRM-004d for keeping the work instead.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- For each confirmation question, ask whether the whole previous state can come back right after, for the person who acted. If it can, the question should go and *Undo* take its place.
- For each step without a question, ask whether it erases stored data with no way back, moves money or commits the person, such as *Pay*, *Send invoice* or a permanent delete. Those need a question.
- A question before a routine step that can be switched back, such as hiding a column, changing a setting or archiving, or before a chat message, comment or reaction.
- A payment or legal step treated as reversible because a short-lived *Undo* shows, or a bulk step whose *Undo* brings back only part of what has value. Leave alone closing a dialog with unsaved input.

<a id="fbk-002"></a>

## FBK-002 Show a failed action where it started and keep it there

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/fbk-002/

### Rule

When an action fails for a reason not tied to one field or group of inputs, show the failure as text in the area where it started. Keep it there until the person closes it, a retry succeeds or they leave the view, and never let a self-closing message carry it alone.

### Why

The person who pressed the button is looking at the button, the row or the panel they were working in. That is where they need to learn that it did not work. A message in a corner of the screen is easy to miss, and one that fades after a few seconds may be gone before a slow reader, a screen magnifier user or someone who looked away has seen it. Then they believe the work is saved, sent or deleted when it is not, and they find out later, when it costs more. A failure that stays in place also shows what it is about, so the person does not have to guess which of several actions went wrong. No WCAG criterion requires this placement or says how long a message stays. The rule rests on the judges. A notice added in place while focus stays where it is counts as a status message under [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), so it needs a role that lets assistive technology present it; FBK-004 covers how. A failure that disappears on a timer works like a time limit on reading it, and keeping it in place stays clear of that, in the spirit of [2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable). When the failure is an input error that is not tied to one field, [3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) asks that the item which is wrong is pointed out and that the fault is described in text, so the notice names that item as well as the fault. An error at one field or one group of inputs follows FRM-002a instead.

### Do

- A side panel *Delivery address* has *Save*. The server does not answer. Inside the panel, just above the buttons, a notice reads "The address could not be saved. The server did not respond. Try again in a moment." with a *Try again* button. Everything the person typed is still in the fields. The notice stays until a new attempt succeeds, the person closes it or they close the panel.
- The person presses *Delete* on the row *Contract – Hartley Ltd* in a table. The removal is refused. The row stays where it was and says, in the row, "Could not be deleted: the contract belongs to an open invoice. Close the invoice and try again."
- The person ticks the task *Order toner*, and the box shows ticked at once. The server then refuses the change. The box goes back to unticked, and the row says "Could not be marked as done." with *Try again*. The view never keeps showing a change that did not happen. Showing a change before the reply is STA-005a's exception for a change shown at once.
- A card *Recent orders* on a start page cannot load its content. The card itself shows "Your orders could not be loaded." with *Try again*. The rest of the page works as usual.
- A page form *Request leave* is sent, and the whole submission fails for a server reason. A notice near *Send request* reads "Your request could not be sent because the leave system is not responding. Everything you entered is still here. Try again in a moment." with a *Try again* button.
- A toast "The address could not be saved" may appear as well, as long as the notice in the panel says the same thing and stays.
- When the person must read or act on the failure before going on, the notice in place has no close button. It leaves when the problem is solved.
- Our own choice: when the person has left the view before the refusal comes, put the earlier state back and tell them where they are now, in a message that stays until closed and names the item, such as "Order toner could not be marked as done." The area is gone, so that message carries the failure.
- *Save* fails inside an ordinary dialog. The notice goes inside the dialog, as DLG-002 says.

### Don't

- Show only a toast "That didn't work" that fades by itself, while the panel looks as if the address was saved.
- Show the failure only in a toast that stays until closed, even one with *Try again*. The notice in the area is still needed. FBK-003's exception for lasting toasts covers successes only.
- Remove the row *Contract – Hartley Ltd* as soon as *Delete* is pressed and leave it gone after the server refused, with a toast as the only sign.
- Report that one card failed to load in a banner at the top of the page, far from the card.
- Clear the notice on a timer while the problem is still there.
- Open an alert dialog with only *OK* for a failure the person can deal with in the area, such as a save they can simply try again. The notice belongs in the area. The short alert that DLG-002 allows over a full-screen dialog is a separate case.
- Let a failure notice in a dialog cover or turn off *Cancel*. Cancel in a modal form keeps working, as FRM-003 says.
- Put a server answer about one field or one group of inputs, such as "This company number is already registered", in the area's notice instead of at the field. It belongs at the field, as FRM-002a says.

### Exceptions

- **When the person must choose how to go on.** If the failure blocks the task and the person has to decide before doing anything else, a modal alert dialog about that action may carry it instead of a notice in the area. For example, on the page *Price lists*, *Publish price list* fails because Sarah Ellis published a newer version while the person was editing, and the person chooses between *Keep Sarah's version* and *Replace with my version*. The alert dialog stays until the person answers. Inside an ordinary dialog, DLG-002 applies: the failure becomes a notice inside the dialog, and only over a full-screen dialog may a short alert sit on top.
- **Problems that affect the whole product.** When the person has been signed out, or the whole service stops answering, the problem is not about one action. It may be shown page-wide, or as a quiet sign in the part of the screen it affects. It still never appears only in a message that closes by itself.
- **Other rules.** Errors about one field or one group of inputs follow FRM-002a. Where focus goes when a form is sent with problems at its fields follows the guideline FRM-011. The time between the press and the reply follows STA-005a, and so does a change shown before the reply. How messages in place are announced follows FBK-004. A successful result and the new state follow FBK-003.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `catch` or `onError` branch whose only output is a sonner `toast.error(...)` or `toast(...)`, with no notice rendered in the panel, row, card or form where the action started.
- An optimistic change, such as a row removed or a box ticked in `onMutate`, that is not rolled back in `onError`, so the view keeps showing a change the server refused.
- A failure notice in the area removed by a `setTimeout` while the problem is still there, instead of when the person closes it, a retry succeeds or they leave the view.
- A failure of one row, card or panel reported only in a banner at the top of the page, or in an `AlertDialog` with only *OK*. Leave it alone when the person must choose how to go on, or the whole product is affected (see Exceptions).

<a id="fbk-003"></a>

## FBK-003 Show a successful result in the view, not only in a toast that disappears

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/fbk-003/

### Rule

After an action succeeds, the item or value it changed shows its new state in the view. If the result has no place in the view, leave a lasting sign near the control or somewhere the person can return to. A toast that closes by itself is never the only sign.

### Why

People need to know that what they did worked. A toast or snackbar that fades after a few seconds is easy to miss: the person looked at the field they were typing in, read slowly, zoomed in on another part of the screen or turned away for a moment. When they miss it, they either do the same thing again, and send the message twice, or stop to check whether it worked. A view that shows the change itself answers the question for as long as the person needs: the row is gone, the switch is on, the new name is in the heading. A toast can still say so as well; it just cannot carry the news alone. No WCAG criterion asks the view itself to change, and none asks for a success message at all, so this rule rests on the judges. It does help with [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages): it concerns blind and low vision people who use screen readers, and they are among those a passing toast fails most often. How a message reaches assistive technology is covered by FBK-004. A toast that vanishes on a timer can also work like a time limit, most clearly when it holds a button, and showing the result in the view keeps people clear of that, in the spirit of [2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable).

### Do

- The person renames a folder to *Receipts 2026*. The folder's name in the list and in the heading changes at once. A toast saying "Folder renamed" is a fine extra.
- The person turns on *Show week numbers* in the calendar settings. The switch shows on, and week numbers appear in the calendar. Nothing more is needed.
- The person deletes the row *Invoice 2026-0412*. The row leaves the list at once, and a toast offers *Undo*. The toast stays until the person uses *Undo*, closes it or leaves the view, as DST-001a says. If they undo, the row comes back in the same place and in view. The invoice can also be restored from *Deleted items*, which lasts after the toast is gone.
- The person sends a message from a form that stays on screen. Next to *Send* a lasting line reads "Sent at 14:02 to Anna Brooks", and the message is listed under *Sent*.
- The person exports a report that is built in the background. The export button area says "Creating export …" and then "Ready: report-november.csv" with a link, and the file is also listed under *Exports*, where it stays.
- The main action in a dialog succeeds and the dialog closes. The page behind it shows the saved values, and a message on the page such as "Profile updated" may say so too, as DLG-002 describes.

### Don't

- Save a setting and show only "Settings updated!" in a toast that fades after four seconds, while the form still looks exactly as before.
- Move a card to *Done* on a board and leave it in the old column until the page is reloaded, with a toast as the only sign it moved.
- Send an invitation and show only a toast "Invitation sent", with no lasting trace near the button and no list of sent invitations to check later.
- Run a long import in the background and report that it finished only in a toast that may close before the person comes back to the tab.

### Exceptions

- **Toasts that stay until closed.** The last sentence of the rule is about toasts that close by themselves. A toast that stays until the person uses it, closes it or leaves the view, such as the message with *Undo* in DST-001a, is not limited by it. The first two sentences still apply: the changed item shows its new state, and a result with no place in the view still gets its lasting sign.
- **When the view is the confirmation.** If the action takes the person to a page that shows the result, such as the new item's own page, that page is the lasting sign and no extra message is needed. The same goes for a page that opens with a lasting message about the result, such as "Your application has been sent" at the top, kept until the person leaves the page.
- **Failures and announcements.** This rule covers success only. Where failures are shown is covered by FBK-002, and how messages reach assistive technology by FBK-004.
- **Actions that can be undone.** DST-001b sets when an action that can be undone runs at once instead of after a question, and DST-001a how *Undo* is offered and how long it stays. DLG-003, DLG-004 and DLG-005 let such an action skip the confirmation dialog. The message with *Undo* follows this rule: the change still shows in the view, for example the archived project leaves the list.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A success branch, such as `onSuccess`, whose only output is a sonner `toast.success(...)` or `toast(...)`, with no `invalidateQueries`, state update or refetch of the changed item. Leave it alone when the action then opens a page that shows the result (see Exceptions).
- Rename, move or delete an item and see whether the view shows its new state at once, without a reload.
- A result with no place in the view, such as a sent invitation or a background export, signalled only by a toast that closes by itself, with no lasting line near the control or list to return to.

<a id="fbk-004"></a>

## FBK-004 Announce a status message without moving focus

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/fbk-004/

### Rule

When a message about a result, a wait, progress or an error appears while focus stays where it is, give it a role or property that lets assistive technology announce it without it taking focus. Our own way, which WCAG does not prescribe, is a polite live region, with role="alert" kept for an error or warning that needs attention now.

### Why

A sighted person notices when a line on the screen changes. A screen reader user hears only what is at focus, so a new line somewhere else on the page passes in silence unless the code marks it as something to announce. [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) requires that such a message can be found by assistive technology through its role or properties, without the message taking focus. WCAG accepts any programmatic way to do that. A polite live region and the role alert are common ways, not the only ones. Choosing between polite and alert is our rule, in line with common practice; WCAG does not require it. A polite status waits until the screen reader has finished what it is saying. An alert breaks in at once, and a page that breaks in too often teaches people to stop listening. What the view itself shows after a change is covered by FBK-003, and where a failed action is shown by FBK-002. This rule covers how the message reaches assistive technology.

### Do

- Our own choice, as the rule says: make the polite live region with role="status" or aria-live="polite".
- A person books a meeting and picks another room in a list. The line below changes from "Room Oak is free all afternoon" to "Room Linden is free all afternoon", and focus stays in the list. The whole line is read, so the person hears the sentence and not a bare "Linden". role="status" reads the whole region by default; with aria-live="polite" alone, add aria-atomic="true".
- A document saves on its own. A role="status" line shows "Saving draft …" and then "Draft saved at 14:05". When a wait ends, replace the busy text with a short result instead of only removing it, so a screen reader user learns that the wait is over.
- Our own point, not a claim from WCAG or the sources: put the empty live region in the page with the page or the component, well before any message, and write the text into it later. Many pairs of browser and screen reader only announce changes inside a live region they already know about. To announce the same text twice, clear the region first.
- A person ticks *In stock only* in a filter, and the line above the list says "3 items match" from a polite live region while focus stays on the checkbox.
- Our own list of what needs attention now: work that is about to be lost, a lost connection and a time limit that is about to pass (STA-004). Other messages are polite. A field's error may use either, as described below.
- The connection drops while the person is editing. A role="alert" line says "Connection lost. Your changes will not be saved until you are back online." This is a warning that needs attention now, so it may break in.
- A person leaves *Email* with an address that has no @ and the field's error appears, as FRM-002b describes. Focus stays on the next field and the error is announced from the live region tied to the field. Polite and alert both fit this rule. Our components use a polite region, so the error waits until the next field's label has been read instead of talking over it. That is our reasoning, not a source's.
- An upload of 12 files says "Uploading 12 files" when it starts, gives a short update at sensible steps such as "6 of 12 files uploaded", and ends with "12 files uploaded". Announce once per real change. For a running sequence of updates, role="log" also fits.
- Five filters are cleared with one press. Announce one message, "Filters cleared, 120 items match", not five.
- *Watch* changes to *Stop watching* when the person presses it on a listing, so the label names what the next press does, as ACT-001a says. Also write "You are now watching this listing" into a polite live region. Some screen readers do not announce a change to the name of the control that has focus. That is our own point.
- A status shown as an icon, such as a green tick next to a row, has a text alternative such as "Synced" as well as the live region, as [WCAG 2.2, 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG22/#non-text-content) asks.
- When a form moves focus to a field after sending, turn off that field's live announcement for that moment, so the error is not read twice.

### Don't

- Add a live region to the page at the same moment as its text, for example a box reading "Thank you, your application has arrived" put in place of a form. The region did not exist before the message, so the announcement is often lost (our point, see above). Keep the region in the page from the start instead. If the control that had focus disappears, as a send button does when the form is replaced, move focus to the result, as the first exception allows.
- Put role="alert" on "Draft saved", "3 items match" or "Loading …". Routine news should not break in.
- Announce every percent of an upload, or a character count such as "73 characters to go" on every key press.
- Move focus to a "Draft saved" message just to make it heard.
- Remove "Loading …" with nothing in its place.
- Show a status only as a colour or an icon, with no text for assistive technology.

### Exceptions

- **Messages shown by moving focus or by loading a new page.** These are not status messages, so this rule does not apply. When a form is sent with problems and focus moves to the first problem or to a summary, as the guideline FRM-011 describes, the message is reached by focus. That message needs no live region. The same holds for a dialog that takes focus and for a new page that shows a result.
- **Messages with an action.** Where focus goes for a message that carries an action is not decided by this rule. For a message with *Undo*, DST-001a decides it. If focus stays where it is, the message's text is still announced.
- **Content that is not a message.** A menu, an accordion or a tab that opens is not a status message; its changed state is covered by [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value). New questions added after an answer and the list of search results itself are not status messages either. Only the short line about the results, such as "3 items match", is a status message.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Do the action while focus stays put, such as a save, a filter or an upload, and see whether the new message sits in an element, or under an ancestor, with `role="status"`, `role="alert"`, `role="log"` or `aria-live`.
- A message about a result, a wait or an error rendered with no live role or property on it or around it, such as `{saved && <p>Draft saved</p>}` or a spinner with no text.
- `role="alert"` or `aria-live="assertive"` on routine news such as "Draft saved", "3 items match" or "Loading …". Keep alert for work about to be lost, a lost connection or a time limit about to pass. A field's error may use either.
- A `.focus()` call on a status message, such as "Draft saved", made only so it is heard. Leave alone messages reached by moving focus on purpose, such as after a form is sent with problems, a dialog or a new page (see Exceptions).

<a id="fbk-005"></a>

## FBK-005 Give a toast at most one action, keep it until it is used, and offer that action elsewhere too

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/fbk-005/

### Rule

A toast or snackbar holds at most one action button besides its close control. While it holds one, it stays until the person uses it, closes it or leaves the view, or a newer message makes it moot. Its action can also be done from a place that lasts.

### Why

A toast is small and sits away from where the person is working. One button in it is quick to read and hard to miss; two or three turn a passing note into a small dialog that nobody asked for. A button is also only useful while it is there. If the toast closes on a timer, someone who reads slowly, uses a screen reader, magnifies the screen or moves with a switch can lose the chance before they reach it. And a toast can still be gone for other reasons: the person closes it by mistake or leaves the view. So what its button does must not depend on the toast alone. As the W3C reads [WCAG 2.2, 2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable), a message that vanishes on a timer while it holds a button sets a time limit, unless the same thing can be done another way. Keeping the toast, offering a lasting route or giving a setting such as "keep messages until I close them" each meets that, so WCAG requires none of them on its own. Asking for the first two together is the judges' guidance and our choice. A lasting route also helps [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) when a toast is awkward to reach with Tab, though the toast's own button must still work from the keyboard. How the toast's text is announced, under [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), is covered by FBK-004.

### Do

- The person merges two contacts. A toast says "Anna Brooks and A. Brooks were merged" with *Undo* and a close button. It stays until they use *Undo*, close it or leave the view. The contact's *History* can split them again later.
- An image fails to upload. A toast offers *Try again*, and the upload area keeps the lasting notice FBK-002 asks for, with its own *Try again*.
- The person moves a meeting to Thursday. The toast "Meeting moved to Thursday" offers *Undo*. Shortly after, they move the same meeting to Friday. A new toast "Meeting moved to Friday" with *Undo* replaces the first one, which no longer applies.
- Put the facts in the message and the single next step in the button. If the text needs a link to a help page, leave it in the text; this rule counts buttons only.
- Keep *Undo* in the toast while it still applies, even when other toasts arrive. They wait, and never remove or cover it.
- Show the change in the view as well, as FBK-003 says, and follow DST-001a for how *Undo* works and where the lasting way back lives.
- When the server refuses a delete that offered *Undo*, the item comes back and the toast with *Undo* is removed or replaced, since nothing is left to undo. The failure shows where FBK-002 says (STA-005a).

### Don't

- Put *Undo*, *View* and *Share* as three buttons in one toast.
- Let a toast with *Undo* close by itself after six seconds while the person is still in the view.
- Let an unrelated toast such as "Draft saved" push off a toast whose *Undo* still applies.
- Offer *Try again* for a failed sync only in a toast, with no way to start the sync again once the toast is gone.
- Make a toast the only place to open the item a background job just created, with no list where it can be found later.

### Exceptions

- **Toasts without an action.** A toast that only reports something is not covered here. FBK-003 says it may never be the only sign of a result, and FBK-002 covers where failures are shown.
- **More than one choice.** If the person has to pick between two or more steps, the message is not a toast. Use an inline notice on the page or a dialog.
- **Links in the text.** A link inside the message text is not an action button in this rule, and the rule neither counts nor forbids it.
- **Focus.** This rule does not say where focus goes when the toast appears or closes. FBK-004 leaves that open for messages with an action, and DST-001a decides it only for *Undo*. A toast that would hide the focused element is covered by KBD-002.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A sonner `toast(...)`, `toast.success(...)` or `toast.error(...)` with an `action` and no `duration: Infinity`, so it closes after the default few seconds. Leave it alone when the `Toaster` sets `duration={Infinity}` for all toasts.
- A sonner toast with both `action` and a `cancel` that does more than close it, or a `toast.custom(...)` or hand-built toast with two or more buttons besides the close control. Links inside the message text do not count.
- An unrelated toast that replaces one whose action still applies, for example by reusing its `id` or calling `toast.dismiss()` before every new toast. A newer message about the same change may replace it.
- An action, such as *Undo* or *Try again*, that exists only in the toast. Ask: once the toast is gone, can the person still do it from a lasting place such as a list, a history or a notice?

<a id="frm-001"></a>

## FRM-001 Give every form control a visible label

Rule. Verdict: Majority (2 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-001/

### Rule

Give every form control a label that people can see at the control, beside it, above it or on its border, before, while and after they fill it in, and never let placeholder text stand in for that label.

### Why

A label is how a person knows what a field wants, and they need to know it at every step: before they start, halfway through a long number, and when they look over their answers before sending. Text inside an empty field is gone at the first keystroke, so it cannot do that job. [WCAG 2.2, 3.3.2 Labels or Instructions](https://www.w3.org/TR/WCAG22/#labels-or-instructions) asks for labels or instructions where people enter something. It supports this rule and does not require all of it. This rule is about the label people see. The name the control carries in code, and how it relates to the label, is FRM-010.

### Do

- Put a short label above each text field. A field for a national identity number gets the label "National ID number" above it.
- Put anything people need to fill a field correctly in visible hint text outside the field, such as "12 digits, YYYYMMDDNNNN" under the label "National ID number".
- Label every kind of control, not only text fields: selects, comboboxes, date and number fields, checkboxes, radio buttons and switches. For a checkbox or a switch, put the label right beside it and name the setting it changes, such as "Email me a receipt".
- Give a group of radio buttons or checkboxes a visible group label, such as "Delivery method" over "Collect in store" and "Home delivery". How the group label is tied to the group in code is FRM-010.
- Prefer a label that sits outside the field and never moves. A floating label that starts inside an empty field and moves to its edge on focus is fine, as long as it stays visible and readable the whole time.
- Give each control a name in code that contains its label's text, as FRM-010 requires. Tying the label to the control in code does that, and the `Field` component does it for you.
- If you add placeholder text, treat it as an optional extra. The field must make sense without it, and the text must still be easy to read.

### Don't

- Build a booking form where "Number of guests" and "Preferred time" exist only as grey text inside the fields.
- Hide the label from view and give the control a name only through `aria-label`.
- Put a required format, such as "NNNNNN-NNNN" for a company registration number, only in the placeholder of the field.
- Label a switch only "On" or "Off", or leave it with no text beside it.
- Let a floating label shrink, get cut off or fade away once a value is entered.

### Exceptions

A single control may go without its own label text when visible text right beside it makes its purpose plain, such as a lone search field next to a button that reads "Search". Even then the control needs a name in code, as FRM-010 requires. Short or familiar forms, such as sign-in, are not an exception.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<Input>`, `<Textarea>`, `<SelectTrigger>` or `<Checkbox>` with a `placeholder` or `aria-label` but no visible `<Label>`, `<FormLabel>` or `Field` label, unless it is a lone search field next to a button that reads "Search" (see Exceptions).
- A `<Label>` or `<FormLabel>` with `sr-only`, `hidden` or `invisible` in its `className`, outside that lone search case.
- A required format, such as "NNNNNN-NNNN", that appears only in the `placeholder` and not in visible hint text outside the field.
- A `<Switch>` or `<Checkbox>` with no text beside it, or whose only text is "On" or "Off".
- A floating label: type a value, leave the field and see whether the label stays visible and readable, not shrunk too small, cut off or faded.

<a id="frm-002a"></a>

## FRM-002a Show a field's error as text at the field

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-002a/

### Rule

When a field or a group of inputs has an invalid value, show the error as visible text at that field, and never only in a banner, a dialog or a tooltip somewhere else.

### Why

People correct a value where the value is. If the message lives in another place, they have to remember it, scroll between the two, or guess which field it means, and the message may be gone by the time they start typing. Placing it at the field and tying it to the control in code means sighted and screen reader users meet the problem and the field together. [WCAG 2.2, 3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) asks that the field in error is named and the problem is described in text, but it leaves the place open (see [Understanding 3.3.1](https://www.w3.org/WAI/WCAG22/Understanding/error-identification.html)). This rule is our design choice for that place.

### Do

- A field labelled "Postcode" holds "1234". Right at the field, the text "Enter a five-digit postcode, for example 11359." appears with an error icon, and stays there while the person edits.
- A bank account entered as a branch code box and an account number box gets one message for the pair. If only the branch code is wrong, the message says so: "The branch code must be four or five digits".
- The server sends the form back because the email address is already registered. The message "This email address already has an account. Sign in or use a different address." is shown at the email field, not only at the top.
- You add a summary at the top of a long form as an extra. Each line in it links to its field and uses the same words as the message at that field.
- The control points to its message with `aria-describedby` and is marked with `aria-invalid`, so the message is read out with the field. Justified's `Field` component does this for you.
- An end date comes before a start date. Show the message at the end date, since that is the field people most often change. This is our own choice for errors that involve two fields.

### Don't

- Show only a banner that says "The form contains errors" and leave the person to find the fields.
- Put the message behind an icon that reveals it on hover or focus.
- Open a dialog with the error that must be closed before the person can fix the value.
- Mark the field with a red outline and nothing else. Always add text, and an icon if you like.
- Place the text visually next to the field but leave it unlinked in code, so a screen reader reads the field without its error.

### Exceptions

- Problems that are not about a value the person entered, such as a service that is down, missing permission or not being eligible, do not belong at a field. Show them as a message for the page or the form instead.
- This rule does not set whether the message goes above or below the input, or whether it replaces the hint text. Both are left to the component. If the message does take the place of the hint, it must repeat whatever the hint said that the person needs to fix the value.
- When the error appears is covered by FRM-002b.
- What a free-text field says when its length limit is reached or passed is the guideline FRM-017c. An error for text that is too long still shows at the field, as this rule asks.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Field errors sent only to `toast.error()`, an `<Alert>` at the top or a `Dialog`, with no message at the field, such as no `<FormMessage />` or `Field` `error`. Problems that belong to no field, such as a service that is down, are fine there (see Exceptions).
- A field marked in error only by colour, such as `aria-invalid:border-destructive` or `border-red-500`, with no error text.
- An error message shown only in a `Tooltip` or `HoverCard` on an icon, instead of as text at the field.
- A control with `aria-invalid="true"` whose `aria-describedby` is missing or does not include the `id` of its visible error message.
- When the server rejects a value, such as an email address already in use, does the message show at that field and not only at the top?

<a id="frm-002b"></a>

## FRM-002b Show a field's error when the person leaves the field or sends the form, and clear it as soon as the value is valid

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-002b/

### Rule

Show a new error on a field only when the person leaves it after changing it or sends the form, never while they type; recheck an error that is already shown on every change and remove it as soon as the value is valid.

### Why

An error that appears halfway through a word scolds people for something they have not finished, and it hits slow typists and screen reader users hardest. Waiting until the person moves on lets them finish first and still hear about a mistake while the field is fresh in their mind. Sending the form is the safety net for every field they skipped. Clearing works the other way round: once the value is right, a lingering error is just noise, so it should go at once. Adding an error early hurts; removing one early helps. Where the error is shown is covered by FRM-002a.

### Do

- A person types "1135" in *Postcode* and moves on to *City*. Only then does *Postcode* show "Enter a five-digit postcode, for example 11359."
- They go back and type the missing "9". The error disappears on that key press, without waiting for them to leave the field.
- They press *Send* without ever visiting *National ID number*. Every field with a problem shows its error at once, *National ID number* included.
- A check that only the server can make, such as whether a delivery address exists, runs when the person leaves the field or sends the form, and its result appears at the field. It never runs while they are still typing.
- When an error appears as the person leaves a field, or a shown error clears while they type, keep focus where it is and announce the change, so screen reader users learn about it without being moved. Where focus goes when the form is sent with problems is the guideline FRM-011: to the first problem or to a summary of them.

### Don't

- Show "Invalid postcode" after the first digit, while the person is still typing.
- Mark *Customer number* as missing just because the person tabbed past it on the way to *Postcode*. A field that is entered and left without a change waits until the form is sent.
- Keep an error on a field after the person has fixed it, until they leave the field or send the form again.
- Send the form and report only the first problem, leaving the rest to appear one round at a time.
- Move focus to an error that appears when the person leaves a field. They have already moved on and should stay where they are.
- Treat a live check on a new password as a reason to check email addresses, postcodes or national ID numbers while people type.

### Exceptions

When a person creates a new value that must meet rules shown next to the field, such as a new password or a new user name, the field shows progress against those rules while they type. List the rules before they start and mark each one as met the moment it is, for example "At least one digit" turning to done after the first digit. This is progress, not an error: no red error state appears on a key press. A rule that is still unmet becomes an error only when the person leaves the field or sends the form. The exception covers new values with stated rules only, never ordinary fields.

When a short form keeps its send button unavailable until required input is in, as ACT-004 allows, sending can no longer reveal skipped fields. ACT-005 then applies: the text next to the button says what is still needed, and those untouched fields are not shown as errors.

Moving from a field to Cancel or the close control in a modal form holds back that field's check until focus moves on to something else, as FRM-003 describes.

A free-text field's count, and the words it shows at its length limit while people type, are not errors under this rule; they are the guidelines FRM-017b and FRM-017c. An error for text that is too long still waits until the person leaves the field or sends the form.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `useForm({ mode: "onChange" })` or `mode: "all"` in react-hook-form, which shows new errors while people type, unless the field creates a new value with its rules listed beside it, such as a new password (see Exceptions).
- `mode: "onBlur"` or `mode: "onTouched"` in react-hook-form. Both check a field on blur even when it was only tabbed past. `onBlur` also keeps a shown error until the field is left again, and `onTouched` shows new errors while typing once a field is touched.
- `reValidateMode: "onBlur"` or `reValidateMode: "onSubmit"`, which, once the form has been sent, keeps a shown error after the value is fixed until the field is left or the form is sent again.
- An `onChange` handler that calls `setError`, `trigger()` or a zod `safeParse` and sets a new error, rather than only clearing an error already shown.
- A check only the server can make, such as an address lookup, called from `onChange` or a debounced effect on the value instead of on blur or send.

<a id="frm-003"></a>

## FRM-003 Give every form in a dialog a Cancel that always works and changes nothing

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-003/

### Rule

Every form in a dialog, sheet or other modal view has a visible Cancel button that is always enabled, is never blocked by field errors, sends nothing and leaves everything as it was before the form opened.

### Why

A modal form blocks the rest of the screen. If the only way out is to finish the task, the person is stuck: they must send something they may not want, or reload and hope. A Cancel that is always there, always works and changes nothing turns opening a form into a safe thing to try. No WCAG criterion asks for a Cancel. A way out that commits nothing shares the aim of [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data), and a Cancel button that can be reached with Tab is the plainest keyboard way out of a modal form, which supports [2.1.2 No Keyboard Trap](https://www.w3.org/TR/WCAG22/#no-keyboard-trap). This rule supports both and is required by neither.

### Do

- A dialog *Change delivery address* has *Cancel* and *Save address*. *Cancel* closes the dialog, and the order keeps the old address.
- A dialog *New category* keeps *Create* unavailable until a name is typed, and the text "Enter a name to create the category." sits just before the button, as ACT-005 asks. *Cancel* works the whole time.
- A dialog *Edit theme* previews the new colour on the page while the person picks it. *Cancel* puts the old colour back, so the page looks just as it did before the dialog opened.
- *Phone* shows the error "Enter a phone number with at least eight digits". The person presses *Cancel*. The error does not stop it. Whether a question about the typed input comes first is decided by FRM-004a in a full-screen dialog and by the guideline FRM-004b in a smaller one.
- The first step of a multi-step dialog *Add user* shows *Cancel* next to *Next*.
- Build Cancel as `<button type="button">`, never as a submit button, so it cannot send the form even by accident. Give it less emphasis than the main action and keep it in the same place in every dialog. The order in code matches the order on screen, as LAY-002 says.
- FRM-004a covers what happens before unsaved changes in a full-screen dialog are thrown away, and the guideline FRM-004b covers dialogs and sheets that do not fill the screen.
- When a form dialog also has a close icon that throws the input away, the icon does what *Cancel* does and has the same accessible name, *Cancel*. *Close* would promise that nothing is lost, as ACT-001a says. This is our own point.
- Escape does what *Cancel* does, as DLG-001 says.
- Our own choice, made to fit FRM-002b and outside the verdict: when the person moves from a field to *Cancel* or the dialog's close control, hold back that field's check. This covers Tab and a pointer press alike. A click on Cancel takes focus off the field before the click lands, and in Safari a clicked button does not take focus, so start the hold-back on the press, not only on focus. If focus then moves on to anything other than closing the dialog or its discard question, such as *Save* or back to a field, run the check at once, as FRM-002b says. The hold-back applies only to Cancel and the close control, never to other buttons. For example, the person types "12" in *Postcode* and tabs to *Cancel*: no error appears. They tab on to *Save*: the error appears on *Postcode*.

### Don't

- Offer only *Save* in a dialog, so the only way out is to save.
- Grey out *Cancel* until the form is valid, or while fields show errors.
- Let *Cancel* save part of the form, such as a file the person already attached.
- Leave a preview or a toggle in place after *Cancel*, so the page no longer looks as it did.
- Show "Enter a valid email address" on *Email*, where the person typed "anna@", because they moved from it to *Cancel*.
- Label the way out *Close* in one dialog and *Cancel* in the next, when both throw the input away.

### Exceptions

- **Modal forms only.** This rule covers forms in dialogs, sheets and other modal views. It says nothing about forms on a page. Leaving a page with unsaved changes is the guideline FRM-004c.
- **Later steps of a multi-step dialog.** This rule covers a single-view modal form and the first step of a multi-step one. What later steps offer as a way out is outside this rule.
- **Non-modal panels.** A side panel that leaves the page usable is not a modal view and is outside this rule.
- **Dialogs that are not forms.** A dialog that confirms a destructive action follows DLG-003, which also asks for *Cancel*.
- **While sending.** Once the person has pressed the main action and the dialog shows progress, such as "Saving …", the form has been sent. This rule then no longer decides what Cancel does. STA-005a covers that moment. Its own choice is that Cancel either stops the request, with the input kept and a line that says what happened, or is unavailable until the reply.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `DialogContent`, `SheetContent` or `DrawerContent` holding a `<form>` with no visible Cancel button, only the main action or a close icon. Later steps of a multi-step dialog are outside the rule (see Exceptions).
- A Cancel `<button>`, or a stock shadcn `Button`, inside the `<form>` without `type="button"`, so it defaults to submit and can send the form. Justified's `Button` already defaults to `type="button"`.
- A Cancel button with `disabled={!isValid}`, `disabled={!form.formState.isValid}` or another `disabled` tied to field errors. Being unavailable while the form is sending is left to STA-005a (see Exceptions).
- Open the dialog, type, attach a file or change a preview, press Cancel, and see whether the page and data look exactly as before it opened.
- Type an invalid value, then Tab or click to Cancel, and see whether an error appears on the field before the dialog closes.

<a id="frm-004a"></a>

## FRM-004a Ask before a full-screen dialog throws away unsaved changes, and only when something would be lost

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-004a/

### Rule

When closing a full-screen dialog would throw away changes the person has not saved, ask first, whichever way they close it, with *Cancel* to keep everything and a button that names the discard; when nothing would be lost, close at once.

### Why

A full-screen dialog, one that covers the whole screen and is used on small screens, is where people do longer work, and it is easy to leave by accident. A thumb slips onto the close icon, or a swipe meant for something else takes the person back. If that throws away ten minutes of typing without a word, the loss is real and may not be noticed until later. One short question at that moment gives the work a second chance. The question only helps if it is rare. A product that asks every time, also when nothing was typed, teaches people to tap straight through it, and then it protects nothing. That is why closing at once when nothing would be lost matters as much as the question, and why saving as people go is better still. No WCAG criterion requires this question. [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) asks for a safeguard before stored data is changed or deleted; unsaved input is not stored data, but this rule gives the same kind of safeguard for a loss that is just as hard to undo. The question must be exposed with a role and a name, so a screen reader user knows the view did not simply close, which supports [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value).

### Do

- On a phone, the person writes a review of a hotel stay in a full-screen dialog *Write a review*, then presses the close icon. One short confirmation opens on top: "Discard this review?" with two buttons, *Cancel* and *Discard review*. Over a full-screen dialog, this one confirmation may sit on top, as DLG-002 says. It opens nothing further.
- Ask on every way of closing that would throw the changes away. That is always *Cancel*. It is also the close icon, Escape, a swipe that dismisses the view and the browser back button, if it closes the view, whenever those throw the changes away too. Send every way out that discards through the same code, so none can skip the question.
- *Cancel* in the question means "do not leave". It closes the confirmation, keeps every word of the review, and puts focus back where it was in the full-screen dialog.
- An action that keeps the work and then closes never asks. If the close icon keeps the review as a draft and says so, it closes at once. Keeping a draft happens this way, or by saving as the person goes, never as a third button in the confirmation.
- When the close icon keeps a draft and *Cancel* discards, give the close icon an accessible name that says so, such as "Save draft and close". Escape, a swipe and the browser back button do what the close icon does: they keep the draft and close at once. Only *Cancel* leads to "Discard this review?". Escape still matches a visible way out, as DLG-001 asks.
- Focus starts on *Cancel* when the confirmation opens, as DLG-004 says. *Discard review* is never the default, so a stray Enter changes nothing. Escape inside the confirmation does what *Cancel* does, as DLG-001 says.
- Give *Discard review* the danger style and a label that names what is lost, as DLG-003 and DLG-005 say.
- Mark only the confirmation as the modal layer while it is open, with the question as its name, so a screen reader announces it and the review beneath cannot be reached.
- Count a change only when a value differs from what the view started with. Typing a word and deleting it again is no change. A value the product filled in by default is not a change by the person, but a value the browser or a password manager filled in at the person's request is.
- The person opens *Write a review*, reads the hotel's questions, types nothing and closes it. It closes at once.
- A full-screen *Packing list* saves each item as it is ticked or typed and shows "Saved". Closing it never asks, because nothing is at risk. Prefer this wherever the product can do it.
- The close icon tries to keep the review as a draft and the save fails. Keep the review open with everything kept, and do not close. Show the problem at the field if it belongs to one, as FRM-002a says, or as a notice inside the dialog if it does not, as DLG-002 says.
- What *Cancel* must do in the form itself is covered by FRM-003.

### Don't

- Close *Write a review* at once on the close icon after the person has typed three paragraphs.
- Ask on *Cancel* but let a swipe or the browser back button close the view with no question.
- Ask "Discard this review?" when the person opened the dialog and typed nothing.
- Show the question when the close icon keeps the review as a draft, since nothing would be lost.
- Add a third button to the confirmation, such as *Save as draft*. Keep a draft by saving as the person goes or through the close icon instead.
- Label the choices *Yes* and *No*, or put *Keep writing* in place of *Cancel*.
- Start focus on *Discard review*, or let Enter press it before the person has moved there.
- Let *Publish review* close the view without publishing when the review cannot be sent, so the person believes it went out. The main action does its job or keeps the view open and says why.
- Stack a second confirmation on top of the first.

### Exceptions

- **Full-screen dialogs only.** Dialogs and sheets that do not fill the screen are covered by the guideline FRM-004b. Leaving a page with unsaved changes is the guideline FRM-004c, and keeping the work on a page form the guideline FRM-004d.
- **While sending.** Once the person has pressed the main action and the view shows progress, such as "Publishing …", the input is on its way. STA-005a covers what closing does then. Its own choice is that no discard question is asked during the wait.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- In a full-screen dialog, type in a field, then try Cancel, the close icon, Escape, a swipe and the browser back button, and see whether every way that discards asks first.
- Open the full-screen dialog and close it with nothing typed, or after typing and deleting, and see whether it closes at once with no question.
- When the question opens, see whether focus starts on Cancel, whether Escape and Cancel keep every value, and whether focus returns to where it was.
- An `onOpenChange`, `onEscapeKeyDown` or `popstate` handler that closes the full-screen dialog without the same unsaved-changes check that Cancel uses.
- A question with a third button such as "Save as draft", choices named "Yes" and "No", or a question shown when the way out keeps a draft.

<a id="frm-004b"></a>

## FRM-004b Ask before a dialog or sheet that does not fill the screen throws away unsaved changes, and only when something would be lost

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-004b/

### Rule

When closing a dialog or sheet that does not fill the screen would throw away changes the person has not saved, ask first, whichever way they close it. The question offers *Cancel*, which keeps everything, and a button that names the discard. When nothing would be lost, close at once.

### Why

An ordinary dialog is the easiest view in a product to close without meaning to. Escape is pressed to clear the screen, a click lands just outside the box, a sheet is pulled down by a thumb that was scrolling. If the dialog held a half-written form, all of it is gone, and nothing on the page shows that anything was there. One short question at that moment lets the person take the slip back. When nothing was typed, there is nothing to take back, so the view just closes. No WCAG criterion requires the question. [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) covers legal and financial steps and data already stored in the product, and unsaved input is none of those. The guideline only shares its aim, a pause before a loss that is hard to put right. When the question takes the form's place, it needs a name that assistive technology can read, so the change is announced, which supports [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value).

### Our reasons

Fewer than two judges have spoken about ordinary dialogs and sheets, so the verdict is Insufficient evidence and this guideline is our choice. Apple supports it. So does NN/g, an expert witness who does not vote. Apple writes for its own platforms; which ways of closing count on the web is our own reading. We ask in ordinary dialogs too, for four reasons.

- **The loss does not depend on the size of the view.** FRM-004a already asks in a full-screen dialog. The same form is often a full-screen dialog on a phone and an ordinary dialog on a laptop. Twenty typed fields are worth the same in both, and a person should not lose them on one screen and keep them on the other.
- **These views have the most ways out.** Escape, a press on the backdrop and a swipe all close an ordinary dialog or sheet, and each can happen by accident. The more ways out a view has, the more it needs a check on the ones that destroy work.
- **Closing cannot be taken back.** Once the dialog is gone, no *Undo* can return what was typed in it. That is a loss of the same kind as the ones DST-001b keeps questions for, when the work has some size. DST-001b does not decide this case itself: its exception hands unsaved input in a dialog or sheet that does not fill the screen to this guideline.
- **The question must stay rare.** A question that shows on every close becomes a click people make without reading, and then it fails when it matters. So we ask only when a value really differs from what the view started with, and not for a single small change that takes a moment to make again (see Exceptions). We prefer saving as people go, which removes the question altogether. The cost is then one extra press, paid only by someone who did real work and still wants to leave.

### Do

- A volunteer coordinator opens the dialog *New shift* and fills in *Task*, *Date* and *Volunteers needed*, then presses Escape. The dialog's content is replaced by "Discard this shift?" with *Cancel* and *Discard shift*. No second dialog opens on top, as DLG-002 says.
- *Cancel* in the question means "do not leave". It brings back the three fields as the person left them. Focus returns to the form's *Cancel* button if that was pressed, as DLG-002 says, and otherwise to where it was.
- Ask on every way of closing that would throw the changes away: *Cancel*, the close icon, Escape, a press on the backdrop if the product closes dialogs that way, a swipe that dismisses a sheet, and the browser back button if it closes the view. Send them all through the same code, as DLG-001 asks for Escape, so none can skip the question.
- On a phone, a volunteer writes why they cannot come in a sheet *Report an absence* and swipes it down. The sheet stays open and its content is replaced by "Discard this absence report?" with *Cancel* and *Discard absence report*. Treat a modal sheet as a dialog when you apply DLG-002. That is our reading.
- The question is a destructive confirmation. Word its title and buttons as DLG-003 and ACT-001a say, put *Cancel* before *Discard shift* as ACT-003a says, start focus on *Cancel* as DLG-004 says, and give *Discard shift* the danger style as DLG-005 says. Escape inside the question does what *Cancel* does, as DLG-001 says.
- When the question replaces the content, let its heading become the dialog's name, for example with `aria-labelledby`, so a screen reader announces the question when focus moves to *Cancel*.
- Count a change only when a value differs from what the view started with. Typing in *Task* and deleting it again is no change. A value the product filled in, such as today's date in *Date*, is not a change by the person. A value the browser filled in at the person's request is. One small change alone does not bring the question; Exceptions says where the line goes.
- A dialog *Rename rota* has one field, *Name*. The person types a new name and presses Escape. The dialog closes at once and the rota keeps its old name, because one short field is quick to fill in again.
- The person opens *Edit shift*, checks the time, changes nothing and presses the close icon. The dialog closes at once.
- A sheet *Handover notes* saves each change as it is typed and shows "Saved". Closing it never asks, because nothing is at risk. Prefer this wherever the product can do it.
- Keep the question to two buttons. This is our choice. If the product can keep unfinished work, it does so as the person goes or through a way out that says it keeps a draft, as FRM-004a describes, and then no question is needed.
- What *Cancel* must do in the form itself is covered by FRM-003.

### Don't

- Close *New shift* at once on Escape after the person has filled in every field.
- Ask on *Cancel* but let a press on the backdrop or a swipe close the view with no question.
- Ask "Discard your changes?" when the person opened *Edit shift* and changed nothing.
- Ask after one field was touched and put back, because the product counts key presses instead of comparing values.
- Open the question as a second dialog over *New shift*.
- Add a third button to the question, such as *Save draft*.
- Ask "Discard your changes?" when the only change in *Edit shift* is a new pick in *Task*.
- Label the choices *Yes* and *No*, or put *Keep editing* in place of *Cancel*.
- Ask when the way out keeps the work, such as closing *Handover notes*.

### Exceptions

- **One small change.** Our own choice: do not ask when the only change is to one control that is not a multi-line text field, such as one short text field, one pick in a list or one switch. A change to a multi-line text field asks, and so do changes to two or more controls. A full-screen dialog asks after one small change too, because FRM-004a has no such exception.
- **Full-screen dialogs.** They are covered by FRM-004a, which is a rule. Leaving a page with unsaved changes is the guideline FRM-004c, and keeping the work on a page form the guideline FRM-004d.
- **Non-modal panels.** A side panel that leaves the page usable is not a modal view and is outside this guideline.
- **While sending.** Once the person has pressed the main action, such as *Add shift*, and the view shows progress, the input is on its way. STA-005a decides what closing does then.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- In a dialog or sheet that does not fill the screen, fill in two fields or a multi-line field, then try Cancel, the close icon, Escape, a backdrop press and a swipe, and see whether every way that discards asks first.
- Change nothing, or only one short field, one pick or one switch, then close the dialog, and see whether it closes at once with no question (see Exceptions).
- See whether the question replaces the dialog's content instead of opening a second dialog on top, and whether its heading becomes the dialog's name through `aria-labelledby`.
- An `onOpenChange`, `onEscapeKeyDown`, `onPointerDownOutside` or `onInteractOutside` handler that closes the dialog without the unsaved-changes check that Cancel uses.
- A change check that counts key presses or touched fields instead of comparing values with what the view started with, such as `touchedFields` in place of `isDirty`.

<a id="frm-004c"></a>

## FRM-004c Ask before leaving a page throws away unsaved changes, and only when something would be lost

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-004c/

### Rule

When leaving a page would throw away unsaved form changes, ask first, by every route out: inside the product with *Cancel* to stay and a button naming the discard, and on closing or reloading the tab with the browser's own prompt. When nothing would be lost, leave at once.

### Why

An edit page is where people spend the longest on one form: a profile, a listing, a record with a dozen fields. On the web it is also full of ways out. A menu item, a breadcrumb, the back button and the tab's close button all sit a few pixels from the work, and none of them says that it throws anything away. When the person finds out, the page is gone and so is what they wrote. One short question at that moment gives the work a second chance. The question only helps if it is rare, so a page that has nothing to lose lets the person go at once, and a page that keeps the work as the person goes, as FRM-004d prefers, never asks at all. FRM-004a and FRM-004b do the same for dialogs; this guideline covers pages, with the same buttons and the same way of counting changes. No WCAG criterion requires this question. [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) asks for a safeguard before stored data is changed or deleted; unsaved input is not stored data, but this guideline gives the same kind of safeguard for a loss that is just as hard to undo. The product's question must be exposed as a dialog with a role and a name, so a screen reader user knows the page did not simply change, which supports [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value).

### Our reasons

Fewer than two judges have spoken about leaving a page with unsaved changes, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So does NN/g, an expert witness who does not vote. Applying it to every way out of a page, and counting the browser's prompt as the question, is our own reading. We ask on pages for four reasons.

- **A page has more ways out than a dialog.** Every link in the sidebar, every breadcrumb and the browser's own buttons leave the form behind, and none of them looks like it throws anything away. A check on one of them alone protects nothing.
- **The loss is the same as in a dialog.** FRM-004a and FRM-004b already ask before a dialog throws work away. The same form often lives in a dialog on one screen and on a page on another, and the person should keep their work on both.
- **Leaving cannot be taken back.** Once the page is gone, no *Undo* returns what was typed. Only the moment before leaving can save it.
- **The question must stay rare.** So we ask only when a value really differs from what the page loaded with, and never when the work is kept, as FRM-004d prefers. Unlike FRM-004b, we make no exception for one small change. A page form is often long and leaves no trace of what was typed, so we keep the line simple: any change that would be lost asks.

### Do

- A holiday-rental host opens the page *Edit listing* for *Harbour Cottage*, with *Title*, *Description*, *Nightly price*, *Cancel* and *Save listing*. The page keeps no draft. The host rewrites the description, then clicks *Bookings* in the sidebar. A confirmation opens over the page: "Discard changes to Harbour Cottage?" with *Cancel* and *Discard changes*.
- *Cancel* in the question means "do not leave". It closes the confirmation, keeps every value on the page, and puts focus back on *Bookings*, the link that was clicked, as DLG-006 says. When the question came from the browser back button, there is no opener: focus goes back to where it was before the press, the logical place nearby that DLG-006 asks for.
- *Discard changes* goes where the person was heading, here to *Bookings*. Never trap the person on the page.
- Ask on every way of leaving inside the product that would throw the changes away: links and menu items, breadcrumbs, the page's own *Cancel* and back button, and the browser back and forward buttons when the router handles them. Send them all through one guard, such as React Router's `useBlocker`, so none can skip the question.
- The host presses the browser back button and then *Cancel* in the question. The page stays, and the address and the browser history are as they were before the press.
- Build the product's question as a destructive confirmation, such as shadcn `AlertDialog`. Word its title and buttons as DLG-003 and ACT-001a say, put *Cancel* before *Discard changes* as ACT-003a says, start focus on *Cancel* as DLG-004 says, and give *Discard changes* the danger style as DLG-005 says. Escape does what *Cancel* does, as DLG-001 says. It opens over the page, not over another dialog, so DLG-002 does not stand in its way.
- Leaving the document is the browser's to show: closing the tab, reloading, typing a new address or following a link to another site. For these, handle `beforeunload` and call `preventDefault()`, so the browser shows its own prompt. Add the handler only while the form has unsaved changes and remove it when they are saved or undone. The browser words the prompt; a custom text in `returnValue` is not shown. That this prompt counts as the question is our own reading for the web (see Our reasons).
- Count a change only when a value differs from what the page loaded with, such as `formState.isDirty` in react-hook-form. Typing in *Title* and deleting it again is no change. A value the product filled in by default is not a change by the person, but a value the browser or a password manager filled in at the person's request is.
- The host opens *Edit listing*, reads it, changes nothing and clicks *Bookings*. The page changes at once.
- *Save listing* succeeds and the product moves on to *Listings*. That move never asks. Reset the form's starting values to the saved ones, such as `reset(values)`, before the redirect, so the guard sees nothing unsaved.
- *Save listing* fails because the server does not answer. The page stays with every value kept and shows the failure as FBK-002 says. The changes are still unsaved, so leaving still asks.
- The page has tabs *Details* and *Photos*, and switching tab removes the *Details* fields with their values. Treat the switch as leaving and ask, or better, keep the values when the tab changes.
- Prefer keeping the work wherever the product can, by saving as the person goes or keeping a draft, as FRM-004d describes. Then leaving never asks.

### Don't

- Move to *Bookings* at once after the host has rewritten the description, with no word.
- Ask on the page's *Cancel* but let a sidebar link or the browser back button leave with no question.
- Use `window.confirm()` for a move inside the product, so the choices read *OK* and *Cancel* and none of them names the discard.
- Add a `beforeunload` handler that is always on, so reloading an untouched page brings up the browser's prompt.
- Ask "Discard changes to Harbour Cottage?" right after *Save listing* succeeded, because the form's starting values were never reset.
- Disable the back button, or push extra entries into the history so back stays on the page.
- Add a third button to the question, such as *Save and leave*. Keep the work as FRM-004d describes instead.
- Label the choices *Yes* and *No*, or put *Keep editing* or *Stay on page* in place of *Cancel*.
- Start focus on *Discard changes*, or let Enter press it before the person has moved there.

### Exceptions

- **Dialogs and sheets.** FRM-004a covers full-screen dialogs and the guideline FRM-004b dialogs and sheets that do not fill the screen. A form in a dialog follows them, also when the dialog sits on a page. Unlike FRM-004b, this guideline has no exception for one small change: a page asks after any change that would be lost. That is our own choice.
- **Work that is kept.** When the page saves each change as it is made, or keeps a draft and says so, as FRM-004d describes, nothing would be lost and the page never asks. If a save fails, the work is no longer kept, and this guideline applies until a save succeeds.
- **Moving within one form.** Going to another step of the same form is not leaving when the steps keep their values. If a step change throws values away, it asks like any other way out.
- **Opening a link in a new tab.** Nothing is lost, so nothing is asked.
- **While sending.** Our own choice: once the person has pressed the main action, such as *Save listing*, the changes still count as unsaved until the reply says they are saved, so leaving during the wait asks as before. STA-005a covers how the wait is shown.
- **Time limits.** Being signed out when a session runs out is not the person leaving. STA-004 covers it.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- On a page form, change one field, then try a menu link, a breadcrumb, the page's Cancel, the browser back button, a reload and closing the tab, and see whether every way that discards asks first.
- Leave with nothing changed, after typing and deleting, or after a successful save. See whether it leaves at once with no question, and whether Cancel in a question keeps every value and the address.
- A route guard such as `useBlocker` that also stops the product's own move after a successful save or a time-limit sign-out, so "Discard changes?" shows for a move the person did not make.
- A `beforeunload` listener that does not depend on `isDirty`, a `window.confirm()` for a move inside the product, or a guard on `router.push` alone that lets `Link` clicks and the back button through.
- A question with a third button such as "Save and leave", choices named "OK", "Yes" or "No", or any question on a page whose changes are already kept as the person goes.

<a id="frm-004d"></a>

## FRM-004d Keep what people enter in a longer page form when they leave, and show that it is kept

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-004d/

### Rule

On a page form with a multi-line text field, more than one step, or five or more controls, a radio or tick-box group counting as one, keep what the person enters when they leave: save each change or keep a draft to return to. Show near the form that it is kept.

### Why

A question before leaving, as FRM-004c asks, protects the work only at the moment the person leaves on purpose. It cannot help when the browser crashes, the battery runs out or the session ends, and many phone browsers never show the prompt when a tab is closed. Work that is kept as the person goes survives all of those, and leaving then needs no question at all. Keeping it quietly is not enough: on a form, people tend to assume nothing is stored until they press a button, so they need to see that it is. No WCAG criterion asks for this. [WCAG 2.2, 3.3.4 Error Prevention (Legal, Financial, Data)](https://www.w3.org/TR/WCAG22/#error-prevention-legal-financial-data) covers stored data, not unsaved input; this guideline only shares its aim of avoiding a loss that is hard to put right. The line that says the work is kept is a status message, so it must reach assistive technology without taking focus, which supports [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages).

### Our reasons

Fewer than two judges have spoken about keeping work on pages, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Apple supports keeping the work; showing that it is kept rests on NN/g, not on Apple. GOV.UK and NN/g support the guideline as expert witnesses who do not vote. That Apple's stance carries to the web is our own reading. We keep the work for four reasons.

- **A question does not cover every way out.** The browser decides whether its leave prompt shows, and a crash or a lost connection shows nothing. Only work that is already kept is safe in all those cases.
- **It costs the person nothing.** A question costs a step each time someone leaves with changes. A kept draft costs no step, and the person who comes back finds their work.
- **Seeing it matters as much as keeping it.** A person who cannot tell whether their work is kept either worries or saves it twice by hand. A short line near the form settles it.
- **The line has to be drawn somewhere.** A short form is quick to fill in again, and a plain *Save* can be clearer there. Where the line goes is our own choice: a multi-line text field, more than one step, or five or more controls the person fills in or sets, with a group of radio buttons or tick boxes counting as one.

### Do

- A hiking club has a page *Write a trip report* with *Route*, *Date*, *Report* and *Photos*. While the member writes, the product keeps a draft on the server a moment after typing stops. A line under the heading reads "Saving …" and then "Draft kept at 14:05". It is a polite status that does not move focus, as FBK-004 says. *Publish report* still publishes; keeping the draft never does.
- The member closes the tab and comes back on Thursday. *Write a trip report* opens with the draft and a line "Your draft from Tuesday is back." with *Discard draft*, so old values never appear without a word.
- *Discard draft* removes something the person stored, so it follows DST-001a, or DST-001b if the draft cannot be brought back.
- While every change is kept, leaving asks nothing and no guard from FRM-004c is active. While a save is still waiting or has failed, the work is not kept: send the waiting save at once when the person leaves, or let FRM-004c's guard ask until a save succeeds.
- Also write a draft in the browser's storage on `pagehide` or `visibilitychange`, not only after a pause, so closing the tab right after typing keeps the last words.
- A member who is not signed in fills in *Join the club*. The draft is kept in the browser's storage, and the page says so, with *Discard draft* for a shared computer. The draft belongs to this form, and to this person where the product knows who it is, and it is removed once *Join the club* has succeeded, so it never comes back on a later visit.
- *Join the club* has three steps. Going back a step shows every answer as it was, so the browser back button loses nothing.
- The page *Hike leader profile* has *Phone*, *First aid course date*, *Areas you lead in* (a group of tick boxes, which counts as one control), *Longest hike you lead* and *About you*. Each value is saved when the person moves on from its control, and one line at the top of the form reads "All changes saved" once the server has answered.
- Keep values as typed, also when they are not valid yet. Sending still checks them, and errors show as FRM-002a says.
- When a save fails, say so in the same line, such as "Not saved. Check your connection.", as FBK-002 asks. Until a save succeeds the work is not kept, so FRM-004c applies again.
- After each save, reset the form's starting values to the saved ones, such as `reset(values)` in react-hook-form, so a guard from FRM-004c does not think the work is unsaved.
- Our own choice: wait until typing pauses before saving, rather than sending every key press.
- When a change takes effect for other people at once, such as the club's public event page or a membership fee, do not save each change as it is made. Keep a draft, and let a deliberate *Publish* or *Save* apply it.

### Don't

- Hold a half-written trip report only in `useState`, so a reload or a closed tab throws it away.
- Save in the background with no line near the form, so the member cannot tell whether the report is kept.
- Show a toast for every save. The line near the form is enough, and FBK-003 asks for results in the view.
- Show "Saved" before the server has answered, or keep showing it after a save failed.
- Keep a draft and still ask "Discard changes?" when the person leaves.
- Show an unsaved-changes marker on a page whose work is kept as the person goes.
- Bring back an old draft without saying so, or with no way to throw it away.
- Keep a card number, a password or a one-time code in a draft in the browser's storage.

### Exceptions

- **Shorter forms.** Our own choice: a page form with one to four controls, none of them a multi-line text field, in one step, is outside this guideline. A plain *Save* is fine there, and FRM-004c asks before leaving throws its changes away.
- **Committing steps.** Keeping a draft never sends, pays, publishes or commits anything. The final action keeps any question DST-001b asks for it.
- **Sensitive values.** Our own choice: never keep passwords, card numbers or one-time codes in a draft in the browser's storage. Keep the rest of the form.
- **Dialogs and sheets.** FRM-004a and FRM-004b already prefer keeping the work in dialogs. This guideline is about pages.
- **Time limits.** A kept draft lets the person carry on after signing in again, but it does not replace what STA-004 asks for a time limit.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- On a page form with a multi-line text field, more than one step or five or more controls, fill it in, reload or close the tab, come back, and see whether everything entered is still there.
- After a change, see whether a short line near the form says it is kept, and whether that line stops saying so when a save fails.
- Such a form whose values live only in `useState` or react-hook-form, with no save on change and no draft kept on the server or in the browser.
- A save with no status shown near the form, a "Saved" that shows before the server has answered, or a delayed save that is dropped when the route changes or the tab closes.
- A draft in the browser's storage that holds a password, a card number or a one-time code.

<a id="frm-005"></a>

## FRM-005 Mark required or optional fields one way, in the label, with any symbol explained

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/frm-005/

### Rule

When a form marks required or optional fields, give every field of the same status the same marker, put it in the visible label or the group's legend as part of the accessible name, and explain a symbol in visible text no later than the first marked field.

### Why

People decide how to spend their effort on a form by what each field asks of them. If one field says "*", the next says "(required)" and a third says nothing, they cannot tell which fields they may skip, and they guess. A marker in the label is seen with the field's name, before anything is typed and after, and a screen reader reads it with that name. A star means nothing until someone says what it means, while a word explains itself. The rule helps meet [WCAG 2.2, 3.3.2 Labels or Instructions](https://www.w3.org/TR/WCAG22/#labels-or-instructions) and [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships). No WCAG criterion says which fields to mark or that a symbol needs a note.

### Do

- Put the marker right after the label text: "Email *" or "Phone (optional)". The marker is part of the label, so it is visible before, while and after the person fills in the field, as FRM-001 asks of the label itself.
- Pick one marker for each status the form marks and use it on every field and group of that status. If *Name* reads "Name *", so does *Email*, and so does every other field that must be filled in.
- Mark a group of radio buttons or checkboxes once, on its legend, such as "Delivery method *" over "Collect in store" and "Home delivery", not on each option.
- Explain a symbol in plain text the person meets no later than the first marked field. A line above the form, "Fields with * must be filled in", works. So does hint text at the first marked field, such as "* means the field must be filled in" under "Name *".
- Let a written marker such as "(optional)" or "(required)" stand on its own. A word needs no note.
- Keep the marker inside the label or legend, so it is part of the accessible name and a screen reader reads it with the field's name. A required state in code, such as `aria-required="true"`, is a good extra on top of that, never a stand-in for it. The `Field` component puts the written mark inside the label and sets `aria-required` when a field is required.
- Give the marker text contrast and the label's normal look, or a quiet one that still meets [1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum). How to measure it is VIS-001.
- Use the same marker across forms of the same kind in a product, so a person who learned it on one sign-up form can read the next.

### Don't

- Mix markers in one form: "Name *" next to "Email (required)", or a star on some required fields and nothing on others.
- Put the marker only in the placeholder, as in an empty field reading "Required". It disappears at the first keystroke, and FRM-001 keeps essential information out of placeholders.
- Show a field's status only by colour, such as a red label for required fields, or only by an icon with no text and no accessible name.
- Rely on a note alone, such as a line above a booking form that names the fields to fill in while the fields themselves carry no marker. A note never replaces the marker at each field.
- Use a symbol and explain it only at the end of the form, in a tooltip, or not at all.
- Put the HTML `required` attribute on a field in a form that does not set `novalidate`. The browser then shows its own error bubbles on send and takes over the error timing in FRM-002b. If you use the attribute, set `novalidate` on the form, as FRM-007 asks for fields with built-in browser checks.
- Hide the marker from screen readers, for example with `aria-hidden` on the star, even when the field also sets `aria-required`.
- Make the marker look like an error. An untouched required field gets no error border, no error icon and no "Required field" message under it. ACT-005 and FRM-002b keep errors for later.
- Draw the star in a pale grey that is hard to see against the background.

### Exceptions

This rule does not decide which fields carry a marker: the required ones, the optional ones or both groups. The judges differ on that, and it is settled separately. Whichever choice a form makes, this rule covers how the marking works.

A form that marks no fields at all is outside this rule.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Compare the markers in every `<Label>` and `<legend>` of one form: does every required field, or every optional one, carry the same marker, such as `*` on all or "(optional)" on all?
- A `*` marker with no visible text explaining it before or at the first marked field, such as a note only at the end or in a `Tooltip`.
- A marker with `aria-hidden="true"`, or placed outside the `<Label>` or `<legend>`, so it is not part of the accessible name.
- A status shown only by `placeholder="Required"`, by a label colour such as `text-destructive`, or by an icon with no text and no accessible name, instead of a marker in the label.

<a id="frm-007"></a>

## FRM-007 Give fields for the person's own details the matching autocomplete value

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/frm-007/

### Rule

When a field asks for the person's own details and WCAG 2.2 lists a matching input purpose, give the field the exact `autocomplete` value for that purpose and never remove it. Our own addition, which 1.3.5 does not ask for: never stop the browser or a password manager from filling the field in.

### Why

Typing a name, an address or a card number again and again is slow for everyone and hard for people with motor, memory or reading difficulties. When each field says in code what it holds, the browser and the password manager can offer the right stored value, and other tools can add a familiar icon or word to the field. [WCAG 2.2, 1.3.5 Identify Input Purpose](https://www.w3.org/TR/WCAG22/#identify-input-purpose) requires that purpose to be exposed for fields about the person filling in the form, when the purpose is in the [list of input purposes](https://www.w3.org/TR/WCAG22/#input-purposes) (see [Understanding 1.3.5](https://www.w3.org/WAI/WCAG22/Understanding/identify-input-purpose.html)). What counts is the value in the code, not whether a given browser fills the field. On sign-in, a form that lets the password manager do its job also supports [WCAG 2.2, 3.3.8 Accessible Authentication (Minimum)](https://www.w3.org/TR/WCAG22/#accessible-authentication-minimum), and a correct accessible name under [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) helps the password manager find the fields. Not blocking filling on other fields is our own choice, so that the value in the code is never wasted.

### Do

- Split name fields get one value each: *First name* gets `given-name` and *Last name* gets `family-name`. A single field for the whole name gets `name`.
- *Email* gets `email` and *Mobile number* gets `tel`. If the phone number is split into a country code and a number, the parts get `tel-country-code` and `tel-national`.
- A delivery address split into fields gets `address-line1` for *Street address*, `address-line2` for *Flat number or c/o*, `postal-code` for *Postcode* and `address-level2` for *City*. A single address box, a `<textarea>`, gets `street-address`.
- A select for *Country* gets `country-name` when its options are country names, or `country` when the values are country codes. The rule covers selects and text areas, not only text inputs.
- *Date of birth* as one field gets `bday`. As three fields for day, month and year, they get `bday-day`, `bday-month` and `bday-year`.
- On sign-in, *Username* gets `username` and *Password* gets `current-password`. On sign-up and when the password is changed, the new password field gets `new-password`, so the password manager can suggest and save a strong one.
- A field that accepts either a user name or an email address may carry either `username` or `email`.
- Card fields get `cc-name` for *Name on card*, `cc-number` for *Card number*, `cc-exp` for a single expiry field, or `cc-exp-month` and `cc-exp-year` for two, and `cc-csc` for *CVC*.
- A field for a one-time code from an SMS gets `one-time-code`. That value is not in WCAG's list, so this is good practice, not part of the requirement.
- If a field uses a type with built-in browser checks, such as the `type="email"` that the guideline FRM-014 asks for, turn off the browser's own validation on the form with `novalidate` and show errors as FRM-002a, FRM-002b and FRM-011 describe. Otherwise the browser can stop at the first bad field and show its own short-lived bubble.
- Keep the visible label as well. The `autocomplete` value tells the browser what the field holds; it never replaces the label that FRM-001 asks for.

### Don't

- Put `autocomplete="off"` on *First name*, *Postcode* or *Card number*. On a field in scope it removes the purpose.
- Give *First name* the value `name`, which means the whole name. A value that is close but wrong is still wrong.
- Make up values such as `autocomplete="firstname"` or `autocomplete="zip"`. Only the values HTML defines are understood.
- Rely on `type="email"` or `type="tel"` alone (the type picks the keyboard, FRM-014). The type says what kind of value it is, not whose value or which part, so it does not expose the purpose.
- Block paste in *Password*, or run a script that clears or rejects values the browser or the password manager has filled in.
- Give fields about someone else the person's own values. *Recipient's name* on a gift order with `name` invites the browser to fill in the buyer's name.

### Exceptions

- Fields about someone other than the person filling in the form, such as a gift recipient, a child or an emergency contact, are outside this rule. Leave them without the person's own values. If a delivery address may belong to someone else, the `shipping` section word keeps it apart from the person's own address.
- A field whose purpose is not in WCAG's list needs no value. A *National ID number* is one example, and so are a search field and a free-text message.
- An amount to pay or transfer is about the transaction, not the person, so it needs no value even though HTML has one for it.
- Paste is a different route from filling. At sign-in it is FRM-008; elsewhere it is the guideline FRM-017.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<Input>`, `<Textarea>` or `<select>` for the person's own name, email, phone, address, birthday, card or user name with no `autoComplete`. Leave alone fields about someone else, such as a gift recipient or a colleague to invite (see Exceptions).
- `autoComplete="off"` on a field in scope, such as first name, postcode or card number.
- An `autoComplete` value HTML does not define, such as `"firstname"`, `"zip"` or `"phone"`, or a close but wrong one, such as `name` on a first-name field.
- A field about someone else, such as "Recipient's name" or an emergency contact, that carries the person's own value, such as `autoComplete="name"`.
- A script that clears or rejects a value the browser or a password manager filled in.

<a id="frm-008"></a>

## FRM-008 Let people sign in with paste, a password manager or a route with no test

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/frm-008/

### Rule

At every step of signing in, let user name, password and code fields take a pasted value in one go and be filled by the browser or a password manager, ask for selected characters of a secret only if another route needs no such step, and give any other test, such as a CAPTCHA, a route without a test.

### Why

Remembering a password, copying a six-digit code from a phone or reading warped letters is hard for many people, and very hard for people with memory, reading or attention difficulties. A password manager and paste take that work away, but only if the page lets them. When one step in the flow blocks them, the whole account is out of reach, however easy the other steps are. [WCAG 2.2, 3.3.8 Accessible Authentication (Minimum)](https://www.w3.org/TR/WCAG22/#accessible-authentication-minimum) requires that every step offers either a route with no such test or a way through it, such as paste or a password manager. Marking the fields so that browsers know what they are for, as [1.3.5 Identify Input Purpose](https://www.w3.org/TR/WCAG22/#identify-input-purpose) and [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) describe, supports this by letting password managers find the right fields.

### Do

- Give the sign-in fields "Email address" and "Password" visible labels and the tokens `autocomplete="username"` and `autocomplete="current-password"`, so a password manager fills both in one action.
- Ask for a one-time code in a single field labelled "One-time code" with `autocomplete="one-time-code"` and `inputmode="numeric"`. A pasted "482913" goes in whole. The keypad is the guideline FRM-014a, and the field stays a text input, as the guideline FRM-014b says.
- If the design shows six boxes for the code, let a paste or an autofill into any box spread all six digits across them.
- Strip spaces and dashes from a pasted code, so "482 913" from a text message still works.
- Offer a route with nothing to remember or copy where you can: a passkey, a sign-in link sent by email ("Send me a sign-in link"), a QR code scanned with an e-identification app the person already uses, or a prompt to confirm on a phone they are already signed in on.
- Make "Forgotten your password?" lead somewhere that needs no recall. One option: mail a single-use link that stops working after half an hour, and tell the person where it went: "We have sent a link to k•••@example.com. It works for 30 minutes."
- If you need protection against bots, use a check that runs without asking anything of the person, or offer a route past the test, such as the sign-in link.
- If a step asks for something from memory, such as the answer to a security question, let that field take paste and a password manager just like the password field.

### Don't

- Block paste on the password field with `onpaste="return false"`, or use `autocomplete="off"` or a script to keep the browser or a password manager from filling the fields.
- Ask for the last four characters of the password and offer no other route. A password manager cannot fill part of a secret, and a pasted password no longer fits.
- Split a code into six boxes where a paste fills only the first one.
- Ask people to type the letters in a warped image, and offer as the only other choice an audio clip whose letters must also be typed.
- Put a maths question such as "What is 7 + 4?" or a slider puzzle in front of the sign-in button.
- Show a test only after three failed attempts and give no route around it. A test that appears now and then still counts.
- Our own position, beyond what 3.3.8 requires: don't make a security question such as "What was the name of your first pet?" the only way to recover an account, even if its field takes paste. People forget these answers as easily as passwords.

### Exceptions

- **Where the rule applies.** Every step counts: the user name, the password, a second factor and the flow for a lost password or user name. Paste in fields outside sign-in is the guideline FRM-017.
- **The password itself.** Asking for a password is a test of memory, and that is allowed. What makes it pass is the first part of the rule: the field takes paste and a password manager.
- **Creating an account.** This rule covers signing in to an account that already exists. A "Confirm password" field that asks for a new, hidden password twice is allowed; [WCAG 2.2, 3.3.7 Redundant Entry](https://www.w3.org/TR/WCAG22/#redundant-entry) leaves room for it. It still helps to let those fields take paste and a generated password from a password manager, as the guideline FRM-017 asks.
- **Details people know.** Asking for a name, an email address or a phone number is not a memory test.
- **Recognising objects.** At Level AA, a test that only asks people to recognise common objects is allowed without another route.
- **Picking their own content.** At Level AA, a test that asks people to pick out an image, a recording or other non-text content they gave the site, such as the profile photo they uploaded, is allowed without another route. A typed answer about themselves is text and is not covered.
- **Codes sent to another device.** The page has to accept a pasted code. Getting the code from the phone to the clipboard is not the page's job.
- **Clearing and masking.** Emptying the password field after a failed attempt is fine, as long as paste or a password manager can fill it again. A masked field is fine too. Whether to offer a control that shows the password is outside this rule.
- **Related rules.** Every field here still needs a visible label (FRM-001), and a wrong password or code is shown as set out in FRM-002a and FRM-002b. Autocomplete values for fields about the person, such as name and address, are covered by FRM-007.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `onPaste` that calls `preventDefault()` or returns `false` on a user name, password, code or security answer field at any sign-in or recovery step. Leave alone new-password fields when an account is created (see Exceptions).
- `autoComplete="off"` on a sign-in field, or a script that clears a value right after a password manager fills it. Clearing the password after a failed attempt is fine (see Exceptions).
- A code split into boxes, each with `maxLength={1}`, where a paste or autofill fills only the first box. Shadcn `InputOTP` spreads a paste across its slots.
- A field that asks for selected characters of the password, such as "Enter characters 2, 5 and 7", with no other sign-in route.
- A CAPTCHA, puzzle, slider or question such as "What is 7 + 4?" on a sign-in step with no route past it, unless it only asks to recognise common objects or the person's own uploaded content.

<a id="frm-009"></a>

## FRM-009 Fill in or offer what the person already gave earlier in the same process

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/frm-009/

### Rule

Within one process, when a step needs information the person already entered or the service already showed them, either put it in the field or offer it on the same page to pick, and never make them type it again. Our own addition, which 3.3.7 does not ask for: a value put in the field stays editable.

### Why

Every time people type something twice, they spend time and effort on work the service could do, and they get a new chance to make a typo. The cost is highest for people with memory or motor impairments, for people who use voice control or a switch, and for anyone who finds it hard to copy text from one screen to the next. [WCAG 2.2, 3.3.7 Redundant Entry](https://www.w3.org/TR/WCAG22/#redundant-entry) requires this, and the rule holds at that level (see [Understanding 3.3.7](https://www.w3.org/WAI/WCAG22/Understanding/redundant-entry.html)). A process runs from its first step to its last, including a step run by someone else, such as payment. It does not reach across visits, so nothing here asks you to keep data after the person leaves. The browser's own autofill is welcome, and `autocomplete` attributes help it ([WCAG 2.2, 1.3.5 Identify Input Purpose](https://www.w3.org/TR/WCAG22/#identify-input-purpose)), but autofill alone does not meet the rule: the service itself has to bring the value back. Keeping a filled-in value editable is our own addition to the criterion.

### Do

- Booking a laundry slot, the person picks *Flat 1102* on the first page to see their building's laundry room. The next page needs the flat number for the door code, and the field already holds *1102*.
- Reporting a fault in a rented flat, the person gives a phone number for the first fault and then adds a second one. The contact question for the second fault offers *Same number as above, 07700 900123* as one choice and *A different number* as the other.
- Step 1 shows the case number *Case 2026-04417*. When a later step needs it, the field already holds it, or the step does not ask at all because the service knows it.
- Renewing a parking permit, the person uses the back control on the payment page to correct the registration number. The field opens with *ABC 123* still in it, and they change one character.
- Before sending, show the email address back with a way to change it: "We will send the confirmation to anna.berg@example.com. *Change email address*".
- When errors are shown, the values stay in their fields; FRM-002a and FRM-002b cover the errors themselves.
- A filled-in field keeps its visible label, as FRM-001 asks. Take care with personal data you bring back: show it only within the process that collected it.

### Don't

- Ask for *National ID number* in step 1 and again in step 4.
- Ask the person to copy a reference number from an earlier screen into a field.
- Set `autocomplete` on every field and treat the rule as met. Keep the attributes, but bring earlier values back yourself.
- Empty a field when the person goes back to it to change what they gave.
- Use the phone number from the first fault for the second one without showing it, so the person cannot see or change which number will be called.
- Add a second field, *Repeat email address*, to confirm the address. This is our reading of 3.3.7, which W3C does not name: show the address back for checking instead.

### Exceptions

Only three cases allow asking again:

- **Typing it again is the point of the task.** A safety course shows a checklist, then asks the person to write the steps from memory to pass. Filling them in would defeat the test.
- **It is needed for security.** When an account is created, a new password that is hidden as it is typed may be asked for a second time, as FRM-008 allows. A control to show the password is the friendlier way to let people check it, and you can offer both. A password typed in a failed sign-in may be cleared, and the service never puts a password back into a field itself; the person types it or their password manager fills it.
- **The earlier value no longer holds.** The time slot picked in step 1 was taken by someone else while the person filled in step 2, so they pick a new one.

Outside this rule: remembering answers between visits, lifting values out of a document the person uploaded, and a code sent to prove access to an email inbox, which is new information rather than a repeat. That code field should still accept paste and filling by the system, as FRM-008 describes. A field that asks for a value again, such as *Confirm new password*, still takes paste, as the guideline FRM-017 asks.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- List the fields across every step of one flow: does a later step ask again for a value the person gave or was shown earlier, such as a case or ID number?
- Each step's `defaultValues` in `useForm`, or `defaultValue` on its fields: does it come from earlier steps, or start empty for data the flow already has?
- Go back a step with the back control and see whether the fields still hold what the person entered.
- A "Repeat email address" or "Confirm email" field. A second field for a new hidden password is allowed (see Exceptions).
- A value carried forward into a `readOnly` or `disabled` field, so the person cannot change it.

<a id="frm-010"></a>

## FRM-010 Give every form control a name in code that contains its visible label

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-010/

### Rule

Give every form control a name in code that assistive technology can read. When a control has a visible text label, its name contains that text. When a group's options need the group label to make sense, that label can be read in code together with the options.

### Why

A screen reader does not look at the screen. It reads the name the control carries in code, and a control with no name is announced as "edit text" or "checkbox" and nothing more. Speech control works the other way round: the person says the word they see, and the control answers only if its name holds that word. And two options that read "Before school" and "After school" say little until the question above them is read too.

Three criteria make this a requirement, one part each. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that every form control has a name software can work out; a control whose name comes out empty is a documented failure ([F68](https://www.w3.org/WAI/WCAG22/Techniques/failures/F68)). [2.5.3 Label in Name](https://www.w3.org/TR/WCAG22/#label-in-name) asks that a control whose label shows text has that text in its name ([F96](https://www.w3.org/WAI/WCAG22/Techniques/failures/F96)). [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) asks that what the layout shows about what belongs together can also be read from the code. For a label and its control, a control whose name is taken from its visible label has met it, and label text on screen beside a control with no name at all does not meet it. For a group, it covers the group label when the options depend on it (see [H71](https://www.w3.org/WAI/WCAG22/Techniques/html/H71) and [ARIA17](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA17)).

None of the three says which technique to use, and none asks that the label can be seen. Whether a control has a visible label is FRM-001.

### Do

- On the form *Book a swimming course*, the label *Swimmer's school* sits above a text field and is tied to it, for example with `<label for>`. The field's name is then "Swimmer's school", the same words as on screen. Tying the label to the control is the way we advise to give the name, because the name can then never drift from the label. The criteria leave the technique open.
- The text area *Notes for the teacher (optional)* is tied to its label the same way.
- Our own advice, since hint text is outside this rule: keep a hint out of the name. *Pool card number* has the hint "Eight digits, on the back of your card" under it. Tie the hint to the field as a description, for example with `aria-describedby`, so the name stays "Pool card number".
- A select labelled *Pool* offers "Northside" and "Harbour". Its name is "Pool" whichever option is chosen.
- A checkbox with the text *Tell me when a place becomes free* beside it has that text as its name.
- The question *When can the swimmer come?* has the options *Before school* and *After school*. Each radio button is named by its own words, and the question is tied to the group, with a `<fieldset>` and `<legend>` or with `role="radiogroup"` and `aria-labelledby`. A screen reader then reads the question when the person enters the group.
- Our own advice, beyond the requirement: tie every visible group label to its group in code. *Lesson length* over "30 minutes" and "45 minutes" could be understood without it, but tie it anyway, so nobody has to judge each group.
- *Swimmer's age* is typed in two boxes with the small labels *Years* and *Months*. Each box has its own name, and *Swimmer's age* is tied to the pair as its group label. The group label does not name the boxes.
- A switch above the course list has the label *Show full courses*. That is its name when it is on and when it is off. On or off is its state, which the switch reports by itself.
- The course list has a search field that shows no label text, only a magnifying glass. The button right beside it shows the word *Search*, which is the case where FRM-001 lets a field go without label text of its own. The field still has a name in code, such as "Search courses". Our advice is that the name says what the field does. The button is named as ACT-001b says.
- A family booking lists three children, and every row has a select labelled *Level*. The names are "Level for Alma", "Level for Noor" and "Level for Idris": the visible word is in each, and the rest tells the rows apart. Starting the name with the visible text is our advice, not what 2.5.3 asks.
- The marker in *Notes for the teacher (optional)* stays in the name. That is what FRM-005 asks. 2.5.3 on its own does not ask for it.
- Our advice: use the native elements where you can. Whether the label text responds to a click or tap is FRM-016a for checkboxes and radio buttons and the guideline FRM-016b for switches.
- In shadcn, give `Label` an `htmlFor` that matches the control's `id`, or use the `Field` component, which does it for you. Put a `RadioGroup` in the `FieldSet` component, which gives the group a `<legend>`, or point it at its visible group label with `aria-labelledby`.

### Don't

- Build a custom select from a `div` that shows "Choose a pool", give it `role="combobox"` and no name, so a screen reader says only "combo box".
- Put *Notes for the teacher (optional)* in a paragraph above a text area and leave the two untied, so the words are on screen but the text area has no name.
- Give the select that shows *Pool* the `aria-label` "Venue". An `aria-label` replaces the label text as the name, so a speech command for the word on screen does nothing.
- Write *When can the swimmer come?* as a plain paragraph over two radio buttons, so a screen reader user hears only "Before school" and "After school".
- Let the switch's name change to "Full courses hidden" when it is turned off while the screen still reads *Show full courses*.
- Lean on placeholder text to give a field its name. This is our advice, not a reading of 4.1.2: set the name on the control itself.
- Add the role to the name, such as "Pool select". The screen reader already says what kind of control it is. This too is our advice.

### Exceptions

- **The visible label.** This rule is about the name in code. A field named only in code can follow this rule and still break FRM-001, which decides when a label must be seen.
- **Text that is not the control's label.** 2.5.3 counts the text right next to the control as its label (see [Understanding 2.5.3](https://www.w3.org/WAI/WCAG22/Understanding/label-in-name.html)). A heading, a group label or a hint need not be in each control's name. Characters that stand for a function and do not spell a word are not a label either.
- **Buttons.** Names for buttons, icon-only ones too, are ACT-001b.
- **Not covered here.** A control's role, state and value, hint text, and error messages are outside this rule. The one thing said about hints under Do, to keep them out of the name, is our advice. Errors follow FRM-002a.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<Input>`, `<Textarea>`, `<SelectTrigger>`, `<Checkbox>`, `<Switch>` or `role="combobox"` element with no name: no `<Label htmlFor>` matching its `id`, no wrapping `<label>`, no `Field` or shadcn `FormItem` with `FormLabel`, and no `aria-label` or `aria-labelledby`.
- A `<Label>` with no `htmlFor`, or one that matches no control's `id`, that neither wraps the control nor is tied to it, so the text is on screen but not in the name.
- An `aria-label` on a control with visible label text that does not contain that text, such as `aria-label="Venue"` on a select labelled "Pool".
- A `RadioGroup` or set of checkboxes under a question in a plain `<p>` or heading, with no `<fieldset>` and `<legend>`, `FieldSet` or `aria-labelledby`. Leave it if each option makes sense without the question.
- An `aria-label` that changes with the control's state, such as a switch named "Full courses hidden" when off while its visible label reads "Show full courses".

<a id="frm-011"></a>

## FRM-011 When a form is sent with problems, move focus to the first problem or to a summary of them

Guideline, our choice. Verdict: Insufficient evidence (0 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-011/

### Rule

When a form is sent and problems are found at its fields, in the browser or by the server, move focus to the first field with a problem, or to a summary above the form that links to each problem. This holds for every form: short or long, page or dialog, and each step of a multi-step form.

### Why

The person who sends a form is at the button, at the end of the form. The problems are somewhere above. A sighted person may see red text appear, if it is on screen. A screen reader user hears only what has focus, and a keyboard user has to tab backwards through the form to find what went wrong. Moving focus on that press takes them to the problem, or to a list of the problems, so the next step is plain. The press is the person's own request, so the move answers it and does not come as a surprise. Focus moves only when the form is sent. An error that appears when the person leaves a field keeps focus where it is, as FRM-002b says. No WCAG criterion asks for focus to move. [WCAG 2.2, 3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) asks that a detected problem is pointed out and described in text, and leaves the way open. Moving focus is one way to make the problems known. The other is to keep focus still and announce the messages, which [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) then requires and FBK-004 covers. One criterion bears on how the move is made, not on whether it is made: from the place focus lands, Tab goes on in an order that makes sense ([2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order)). That the landing place shows its focus indicator and is not covered is asked by KBD-001 and KBD-002, as for any focused element.

### Our reasons

Fewer than two judges have spoken about where focus goes when a form is sent with problems; in fact none has. The verdict is therefore Insufficient evidence, and this guideline is our choice. One expert witness, GOV.UK, supports it, and a witness does not vote. Its support is for the summary. Moving focus straight to the first field with a problem has no judge or witness behind it; it is our own alternative. We move focus at all, and allow both ways, for five reasons.

- **Silence looks like a broken form.** If the messages appear and focus stays on the button, a screen reader user hears nothing new. They cannot tell a refused form from a slow one or a dead button, and some will press again or give up.
- **The problem may be out of view.** On a long form, or a short one zoomed to 400 percent, the field in error can be off screen when the button is pressed. Focus brings it into view. The person does not have to scroll and search.
- **Landing on the problem is the start of the fix.** In the field, the person can type the correction at once. On the summary, they see how much there is to do and can pick where to begin.
- **One behaviour for every form is easier to learn and to build.** A product whose long forms move focus and whose short forms do not asks people to guess which kind they are in. So we do not make this depend on the form's length.
- **With one problem, a summary is an extra step.** The person lands on a list of one line and follows its link to the field. That is why we also allow focus to go straight to the field. Browsers' own form checking also puts focus in the first field that fails, so many people have met that behaviour. This is our observation about browsers, not a source's advice.

### Do

- A page form *Book a kennel stay* has *Pet's name*, *Arrival date*, *Collection date*, *Feeding notes* and *Vet's phone number*. The person presses *Book stay* with *Arrival date* empty. The field shows "Enter the date your pet arrives, for example 2027-03-14", and focus moves into *Arrival date*. Because the message is tied to the field in code, as FRM-002a says, a screen reader reads the field's name and its message together.
- The same form is sent with three problems. A box above the form has the heading "Check 3 answers before you book" and takes focus. Each line in it is a link to its field, in the words of the message at that field: "Enter the date your pet arrives, for example 2027-03-14" goes to *Arrival date*. Make the box able to take focus from code, for example with `tabindex="-1"`, and let its heading be read when focus lands.
- Every field with a problem still shows its own message, all in the same round. Where the message sits is FRM-002a, and that sending reveals every field's error at once is FRM-002b. What the person entered is still in the fields, as FRM-009 says.
- Our own advice: when there are several problems, prefer the summary. Focus on one field tells a screen reader user about that field's problem only. Focus on the summary tells them about all of them.
- Do not let the messages be read twice. When focus moves to a field, turn off that field's live announcement for that moment, as FBK-004 says. When focus moves to a summary, hold back the fields' live announcements for that round too; the summary has already said the same words. That second point is ours.
- "First" means first in the order of the form. *Arrival date* comes before *Vet's phone number* on the page, so focus goes to *Arrival date*, even if the phone number was checked first.
- Focus, or the summary's link, goes to the input the person has to change. When one answer is made of several inputs and the product cannot tell which of them that is, it goes to the first input of the answer. *Vet's phone number* is a country code list and a number box, and the number box holds four digits: the target is the number box, not the list before it. Applying this to focus that goes straight to the field is our own detail.
- A short form counts too. The dialog *Add a pet* has only *Name* and *Species*. The person presses *Add pet* with *Species* not chosen. The dialog stays open, "Choose a species" shows at the field, and focus moves to the first option of *Species*, inside the dialog. A summary, if the product uses one, also sits inside the dialog.
- Step 2 of 3, *Food and medicine*, has a *Next* button. Pressing it sends that step. With *Meals per day* empty, the step stays, the field shows "Enter how many meals your pet has each day", and focus moves there.
- The server sends the form back because of a voucher. *Voucher code* shows "The code SPRING5 ended on 1 March. Remove it or enter another code." Focus moves to *Voucher code* or to the summary, the same way as when the browser finds the problem.
- When the form comes back as a new page, the page sets focus itself once it has loaded. A reloaded page otherwise starts at the top, and the move is lost.
- Check the landing place. The field or the summary scrolls into view and is not hidden under a sticky header, as KBD-002 requires, and the focus indicator shows on it, as KBD-001 says. From the summary, Tab goes to its links and then on into the form.
- A product may pick one way for all its forms, always the summary or always the first field, or use the first field for one problem and the summary for several.

### Don't

- Show the messages and leave focus on *Book stay*, so a screen reader user hears nothing and has to search the form.
- Skip the move on the two-field dialog *Add a pet* because everything is on screen. A screen reader user does not see the screen.
- Move focus to the top of the page or to the page heading. Neither is a problem nor a summary.
- Move focus to the last field with a problem, or to the one whose check happened to finish first.
- List the problems in the summary as plain text with no links, so the person still has to find each field.
- Let the summary stand in for the messages at the fields. FRM-002a asks for those in every case.
- Close the dialog *Add a pet* when it is sent with problems, or move focus to the page behind it.
- Move focus to *Arrival date* and also announce its message from a live region, so "Enter the date your pet arrives" is read twice.
- Move focus to a field's error when the person leaves that field. Focus moves only when the form is sent.
- Reload the page with the problems marked and leave focus at the top of the document.

### Exceptions

- **A problem that belongs to no field.** When the booking system does not answer, or the person has been signed out while filling in the form, there is no field to go to. Where that failure is shown, and what follows, is left to FBK-002. This guideline covers problems at fields.
- **A button that is unavailable.** When a short form keeps its button off until the required input is in, as ACT-004 leaves open for short forms, with the note ACT-005 asks for, the form cannot be sent with those problems and this guideline has nothing to act on. A problem only the server can find still comes back, and then it applies.
- **Passwords.** A password field may come back empty after a refused send, as FRM-009 allows. Focus still goes to the first problem or to the summary.
- **A product that keeps focus still.** This is a guideline, and a product may choose otherwise. If focus does not move, every message that appeared is a status message and FBK-004 applies to it in full.
- **Other rules.** Whether the button is enabled is ACT-004 and ACT-005. What the button does between the press and the reply is STA-005a and STA-005b. Where a message sits is FRM-002a, when it appears and clears FRM-002b, its words TXT-001a, and how a message is announced when it does not take focus FBK-004.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Send the form with an empty required field and see whether focus moves into the first field with a problem, in form order, or to a summary above the form.
- Send it with several problems: if a summary takes focus, does it have `tabindex="-1"`, a heading that is read, and a link to each field?
- `useForm({ shouldFocusError: false })`, or a check outside react-hook-form, such as zod `safeParse` on submit, that shows messages but never calls `setFocus` or `.focus()`. Leave it if the product keeps focus still and announces every message (see Exceptions).
- Server errors set with `setError` without `{ shouldFocus: true }` or a later `setFocus`, so focus stays on the submit button, or a page that reloads with the problems marked and focus at the top.
- Send a short form in a `Dialog` with a problem, and see whether the dialog stays open and focus moves to the problem inside it.

<a id="frm-012a"></a>

## FRM-012a Changing a value does not send a form, open a page or move focus unless people were told first

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-012a/

### Rule

Changing a control's value, such as choosing an option, ticking a box or typing, does not send a form, open a page, a window or a dialog that takes focus, or move focus, unless text before the control tells people it will. Changes in place, such as a list that filters, are allowed while focus stays put.

### Why

People change a value to say what they want, not to go anywhere. A keyboard user who arrows through a select to read the options, or a screen reader user who ticks a box and expects to hear it checked, is lost when the page sends, reloads or jumps elsewhere. They did not ask for it and may not notice it happened. [WCAG 2.2, 3.2.2 On Input](https://www.w3.org/TR/WCAG22/#on-input) requires that changing the setting of a control does not change the context unless people were told before they use it. A change of context, in WCAG's definition, includes a new page or something that looks like one, a new window, focus sent elsewhere and a large rearrangement of the page. A section that expands, extra fields that appear or a list that updates, with focus left where it is, is a change of content and outside the criterion. The Working Group lists as failures a form that sends itself when a field is filled or left ([F36](https://www.w3.org/WAI/WCAG22/Techniques/failures/F36)) and a window that opens when a radio button, checkbox or select changes, with no warning ([F37](https://www.w3.org/WAI/WCAG22/Techniques/failures/F37)).

It accepts a description placed before the control ([G13](https://www.w3.org/WAI/WCAG22/Techniques/general/G13)). Two of its other ways to pass hand the change to a button ([G80](https://www.w3.org/WAI/WCAG22/Techniques/general/G80), [H84](https://www.w3.org/WAI/WCAG22/Techniques/html/H84)), and another lets a select update something later on the same page without any change of context ([SCR19](https://www.w3.org/WAI/WCAG22/Techniques/client-side-script/SCR19)). The same note in F37 says a radio group that acts on change probably still fails [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) with a warning, because the arrow keys cannot move through it without changing the value. That is why 2.1.1 is listed as support.

This rule holds the law's floor, where a notice is enough. FRM-012b is the judges' stricter rule, which asks for a button or a link even with a notice.

### Do

- In a tool library app, the page *Find a tool* has filter checkboxes under *Category*. Ticking *Garden* filters the list below in place. Focus stays on the checkbox, the page does not scroll, and the line "18 tools match" is announced as FBK-004 asks. The wait for the new list shows in the list itself, as STA-001 asks.
- The select *Sort by* reorders the same list in place when *Nearest first* is chosen, with focus left on the select. That is a change of content, and the rule allows it.
- Choosing *Delivery* under *How do you want to get the tool?* reveals the field *Delivery address* below the radio group, and focus stays on the radio. Choosing *Branch* in a select fills the next select, *Pickup time*, with that branch's slots. The changed part comes after the control that changed it.
- The switch *Return reminders* turns reminders on as soon as it is flipped and the page says "Reminders on" from a polite live region. A setting that applies where it is changes no context.
- The *Confirmation code* field is shadcn's `InputOTP` with an `onComplete` that sends the code. Text above the field, tied to it with `aria-describedby`, says "We check the code as soon as all six digits are in." That notice is what the law asks. Our own advice is to go further and send with Enter or a *Verify code* button, as FRM-012b does for choices.
- Our own advice: do not move focus by itself from *Day* to *Month* to *Year* in *Return date*. People Tab between the parts, as in any other field. The law would accept a notice before the fields; we do not use it.
- A notice counts only when people get it before they use the control: earlier in reading order, or in an earlier step of the same task. A tooltip, a placeholder or text after the control is not enough. Our own advice: tie it to the control with `aria-describedby` so a screen reader reads it on arrival.
- A change of context the person asks for with a button or a link, such as *Apply filters* or *Go to checkout*, is activation and outside this rule.

### Don't

- Give a `Select` or `RadioGroup` an `onValueChange` that calls `router.push`, `navigate()`, `window.location` or `window.open` with no notice before it, such as a *Branch* select that loads that branch's own page.
- Call `form.handleSubmit()`, `form.requestSubmit()` or a server action from a `Select` or `Checkbox` change, such as a *Show returned loans* checkbox that sends the form and reloads the page. The Working Group lists sending on a change as a failure.
- Build a *Plan* radio group whose `onValueChange` opens checkout. Radix `RadioGroup` checks an item as soon as an arrow key moves to it, so `onValueChange` fires on every arrow press and a keyboard user is taken away on the first one. A notice does not fix that; see FRM-012b.
- Assume a select only commits on Enter. A native `select` can change value with arrow keys while closed on some platforms, and typing a letter on a closed Radix `Select` trigger chooses the matching option. Arrow keys, Enter and Space on that closed trigger only open it, so typing is the case that commits there. Check your build before tying anything to the change.
- Send the code from `InputOTP`'s `onComplete`, or move focus from *Day* to *Month* when two digits are in, with no text before the field that says so.
- Give the switch *Automatic payments* an `onCheckedChange` that opens a `Dialog`, which takes focus, with nothing before the switch that warns of it. Use a button such as *Set up automatic payments*, as FRM-012b asks.
- Save and go to the next page from `onBlur` when the person leaves the last field. Leaving a field may check it and show an error in place, as FRM-002b says, but not send.
- Let a filter move focus to the first result when it updates the list. Moving focus is a change of context.
- Our own reading, beyond what the criterion clearly covers: do not let a filter scroll the page back to the top either. People still at the filters lose their place and may tick the wrong one.

### Exceptions

- **Activation.** Pressing a button or a link is not a change of value. A submit button that sends the form, a button that opens a dialog, or a link to another page is outside this rule. So is Enter in a single-line field that sends the form, as FRM-015 says. Where focus goes after a failed send is FRM-011.
- **Saving a setting.** Saving a setting in the background, with the page left as it is, is not sending a form. The *Return reminders* switch under Do may save at once.
- **Changes of content.** Fields that appear, a list that filters or sorts, a setting that applies at once, tabs and accordions, all with focus kept, are allowed. Announcing them is FBK-004; where the wait shows is STA-001.
- **A view that swaps entirely.** A select that turns the whole main area from a list into a board may count as a large rearrangement. Our own advice: use tabs or a toggle group that updates in place and keeps focus.
- **Focus alone.** What may happen when a control merely receives focus is FRM-013, which allows no notice.
- **Neighbouring rules.** Where a language picker sits is ACT-003b. Whether a value control may act at all, even with a notice, is FRM-012b.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `onValueChange`, `onCheckedChange` or `onChange` on a `Select`, `RadioGroup`, `Checkbox`, `Switch` or input that calls `router.push` to another page, `navigate()`, `window.location`, `window.open` or opens a `Dialog`. Leave it if text before the control says so, or if only search params change for the same view.
- A value change or `onBlur` that calls `form.handleSubmit()`, `requestSubmit()` or a server action that sends the form, with no notice before the control. Saving a setting in the background is fine (see Exceptions).
- `InputOTP` with an `onComplete` that sends the code, or a date part that calls `.focus()` on the next part, with no text before the field saying so.
- A notice given only in a `Tooltip`, a `placeholder` or text after the control. It must come before the control in reading order.
- Change a filter, sort or radio with the keyboard and see whether focus stays on the control rather than moving to the first result or elsewhere.

<a id="frm-012b"></a>

## FRM-012b Let a control that holds a choice only record it, and put actions on buttons and links, even with a notice

Rule. Verdict: Majority (2 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-012b/

### Rule

A control that holds a choice, such as a select, radio group, checkbox, switch or filter chip, only records it and may update the view in place. Going to another page or step, sending a form or running a command takes a button, a link or a menu of actions, even with a notice.

### Why

A choice and an action are different promises. A select, a radio button or a checkbox says "choose, and nothing happens yet"; a button or a link says "press me and something happens". When a choice also sends, navigates or runs a command, people cannot look through the options without setting it off, and a keyboard user moving through a radio group with the arrow keys sets it off on the first press. [WCAG 2.2, 3.2.2 On Input](https://www.w3.org/TR/WCAG22/#on-input) allows such a control when a notice before it says what will happen; that floor is FRM-012a. This rule goes further, and the judges decide it, not WCAG: two of the three support it and Carbon opposes. That it holds even with a notice is our own reading.

A notice is easy to miss, and for a radio group it does not help the keyboard at all, which is why the Working Group notes that such a group probably still fails [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) ([F37](https://www.w3.org/WAI/WCAG22/Techniques/failures/F37)). The Working Group's own preferred ways to pass 3.2.2 point the same way: a submit button ([G80](https://www.w3.org/WAI/WCAG22/Techniques/general/G80)) or a button next to the select ([H84](https://www.w3.org/WAI/WCAG22/Techniques/html/H84)). Our own reading adds one point: a screen reader announces a link or a button as something that acts, and a select as something that holds a value, so a control that matches its job is heard for what it does.

### Do

- In a project tool, people move between workspaces with a `DropdownMenu` whose trigger shows the current one, *Workspace: Harbour team*. Each item is a link (`DropdownMenuItem asChild` with a `Link`), so choosing one is activation, and Enter or a click goes there.
- Offer the product's languages as a short list of links in the product's top bar, where ACT-003b puts it, each written in its own language and leading to that version of the page.
- The select *Rows per page* over the task table changes the table in place, and "Showing 50 tasks" is announced as FBK-004 asks. If a new page has to load from the server, put a *Show rows* button next to the select, or use a menu of links instead of the select.
- A plan picker is a `RadioGroup` with *Starter*, *Team* and *Business*. Choosing one only records it. The button *Continue to payment* after the group sends the choice, as ACT-004 and ACT-005 describe for the submit button.
- The checkbox *I accept the terms* only records the answer. *Create account* sends the form.
- In a settings form that is saved with *Save settings*, use checkboxes such as *Email me a weekly summary*. A switch tells people its setting applies at once; where a press on *Save settings* is still needed, it misleads. Or drop the button and let each switch apply and confirm in place.
- When turning something on needs more steps, such as choosing a card for automatic payments, use a button whose label starts with a verb, as ACT-001a asks: *Set up automatic payments* opens the dialog. Do not hide that dialog behind a switch.
- A `ToggleGroup` with `type="single"` switches the task view between *List* and *Board* in place. *Export tasks* is a separate button beside it, not a segment of the group.
- Filter chips such as *Assigned to me* and *Overdue* narrow the task list in place. A chip that runs something, such as *Add a task*, is a button and sits apart from the filter group.
- A `DropdownMenuRadioItem` for *Sort by* or a `DropdownMenuCheckboxItem` for *Show done tasks* records a value and may update the view in place. It does not also navigate.
- A `Command` palette whose items open a task or run a command is a menu of places and commands, and each item acts on Enter or a click. A combobox whose picked suggestion only fills the field is a choice. Results that update in place while the person types are allowed.

### Don't

- Build *Switch workspace* as a `Select` with `onValueChange={(v) => router.push(v)}`, even with a line above it saying that choosing one opens it.
- In an onboarding flow, move on to the next step as soon as *2 to 10 people* is chosen in the radio group *Team size*. Moving to another step is a button's job: put *Next* after the group.
- Use a `RadioGroup` whose `onValueChange` opens checkout. Radix checks a radio when an arrow key reaches it, so every arrow press would fire it.
- Give a `Checkbox` an `onCheckedChange` that calls `form.handleSubmit()`.
- Put a `Switch` in a form that only takes effect after *Save settings* is pressed.
- Mix segments that show a selection with a segment that runs a command in one `ToggleGroup`.
- Let a filter chip open another page.

### Exceptions

- **Updates in place.** Revealing fields, filtering or sorting a list in place, switching a view in place and applying a setting at once are what a choice may do. They are not actions in the sense of this rule.
- **Menus of commands and places.** A `DropdownMenu` whose items are commands or links is a menu of actions, not a control that holds a choice. This rule is about the role a control plays, not about a component's name.
- **Text fields.** Sending a field when it is full, such as a one-time code, is covered by FRM-012a. Asking for a button there instead of a notice is FRM-012a's own advice, not part of this rule.
- **Neighbouring rules.** The law's floor, where a notice before the control is enough, is FRM-012a. Which of a button and a link to build is the guidelines' own choice: a link for going somewhere (ACT-009a), a button for acting in place (ACT-009b). The button's label is ACT-001a, its place ACT-003b, and whether a submit button may be unavailable ACT-004 and ACT-005. Announcing updates in place is FBK-004.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Select`, `RadioGroup`, `Checkbox`, `Switch`, `ToggleGroup` or `DropdownMenuRadioItem` whose `onValueChange` or `onCheckedChange` calls `router.push`, `navigate()`, `window.location` or `window.open` to go to another page or step, even with a notice. Leave alone a change of search params that filters or sorts the same view.
- A value change on such a control that calls `form.handleSubmit()`, `requestSubmit()` or runs a command such as export. A switch that applies and saves its own setting in place is fine.
- A `ToggleGroup` or filter chip group with an item that runs a command or opens another page, such as "Export tasks" or "Add a task".

<a id="frm-013"></a>

## FRM-013 Receiving focus never sends a form, opens a page, a window or a dialog that takes focus, or moves focus on

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-013/

### Rule

When a control receives focus, by Tab, a click or a script, that alone never sends a form, opens a page, a window or a dialog that takes focus, or moves focus to another control. A notice before the control does not change this. Content that appears beside the control and leaves focus in it is allowed.

### Why

Keyboard users move through a page by giving each control focus in turn. If arriving on a control sets something off, they cannot pass it: the page sends or changes under them, or focus is thrown somewhere else before they can act. Screen reader users meet the same wall, and anyone who clicks into a field to read it can be sent away by mistake. [WCAG 2.2, 3.2.1 On Focus](https://www.w3.org/TR/WCAG22/#on-focus) requires that a component receiving focus does not start a change of context. Unlike [3.2.2 On Input](https://www.w3.org/TR/WCAG22/#on-input), which FRM-012a covers, it has no exception for people who were told beforehand. The Working Group's way to pass is to let changes of context start only when people activate something, such as a link or a button ([G107](https://www.w3.org/WAI/WCAG22/Techniques/general/G107)). It lists as a failure a script that takes focus away as soon as a control gets it ([F55](https://www.w3.org/WAI/WCAG22/Techniques/failures/F55)), which also breaks [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard). That is why 2.1.1 is listed as support. Showing something on focus that leaves focus where it was, such as a tooltip, a hint or a list of suggestions, is a change of content and outside the criterion.

### Do

- In a clinic's booking form, the field *Appointment date* opens its calendar `Popover` when the person presses the calendar button next to it or presses Enter or Space on that button. Tab from *Appointment date* goes on to the calendar button and then to *Reason for visit*.
- If the calendar opens when the date field gets focus, keep focus in the field with `onOpenAutoFocus={(e) => e.preventDefault()}`, and let the down arrow or the calendar button move into it. The calendar stays open while focus is in the field or inside the calendar, and closes when focus goes anywhere else or the person presses Escape, as TXT-002a asks for content shown on focus.
- The icon next to *Reason for visit* shows the tooltip "Seen only by your doctor" on focus and on hover, and focus stays on the icon. TXT-002a and TXT-002b set how that tooltip behaves.
- The combobox *Doctor* opens its list of names when it gets focus, with focus still in the input. Nothing is chosen until the person picks a name with Enter or a click, and Escape closes the list, as TXT-002a asks.
- In the `DropdownMenu` *Booking actions*, with *Move appointment* and *Print confirmation*, arrow keys move the highlight without running anything. Only Enter, Space or a click runs an item. In a `Select` such as *Clinic*, Enter only records the value, as FRM-012b asks. Radix behaves this way by default; keep custom `onFocus` or `onPointerMove` handlers on items from changing that.
- Our own advice: show a value the clinic fills in, such as *Patient number*, as plain text, or as a `readOnly` input that keeps its place in the tab order. Many screen reader users expect to reach and read such a field, so do not take it out of the tab order just to hide it. Either way focus stays where it lands and needs no forwarding.
- Every control stays reachable and visibly focused by keyboard, as KBD-001 asks.

### Don't

- Open the calendar `Popover` from `onFocus` on *Appointment date* and let Radix move focus into the calendar, so Tab never gets past the field.
- Open a `Sheet` with search filters when the field *Search clinics* is tabbed into, and let it take focus, so a keyboard user is pulled into the panel each time they reach the field. The same goes for a `HoverCard` or `Popover` with the doctor's profile that opens when a doctor's name gets focus and moves focus into it.
- Call `router.push` from `onFocus` on a clinic card in a list, so tabbing through the list opens the first clinic.
- Send the search *Find a clinic* when the field is tabbed into, or start the next step when its first field gets focus.
- Forward focus from one control to the next in an `onFocus` handler, or call `blur()` in one so the control drops focus as soon as it gets it. The Working Group lists that second pattern as a failure.
- Our own advice, beyond what 3.2.1 covers: do not move focus into a menu's panel when the pointer merely hovers its trigger. Hover gives no focus, and a script that adds it surprises keyboard and screen reader users. Inside a menu that is already open, Radix moving focus to the item under the pointer is fine; leave that default alone.
- Write "Reaching this field opens the filters" above *Search clinics* and keep the `Sheet` that takes focus. No notice makes a change on focus acceptable.

### Exceptions

- **Activation.** A click or a press of Enter or Space on a button or a link activates it, and may open a page or a dialog. That is not focus alone. Where focus goes when a dialog opens and closes is DLG-006, and the order focus follows is LAY-002.
- **Focus set after the person acted.** A page or dialog that opens with focus in its first field, because the person pressed something to get there, is outside this rule.
- **The focused item disappears.** When the item with focus is removed, focus has to move somewhere. Where focus goes then is DLG-006 when it happens behind a dialog, and STA-002a when a list is emptied; elsewhere this rule does not decide it.
- **One control that grows.** A search icon that opens into its own field and puts focus in it is perceived as one control. This rule neither forbids nor recommends it.
- **Changes of value.** A combobox that chooses the highlighted option when it loses focus has changed a value, and that is FRM-012a.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Tab through every control and see whether arriving on one sends a form, opens a page, opens a `Popover`, `Sheet`, `Dialog` or `HoverCard` that takes focus, or moves focus on. Focus placed after the person pressed a button is fine (see Exceptions).
- An `onFocus` handler that calls `router.push`, `handleSubmit()`, `requestSubmit()`, `blur()`, or `.focus()` on another element.
- An `onFocus` that opens a `Popover` without `onOpenAutoFocus={(e) => e.preventDefault()}`, or opens a `Sheet` or `Dialog`, which always take focus.
- Click into a field and see whether anything opens that pulls focus away, such as a calendar or a filter panel.

<a id="frm-014"></a>

## FRM-014 Give email, phone and web address fields the input type that matches the value

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-014/

### Rule

Give a field that asks only for an email address `type="email"`, a field for a phone number `type="tel"` and a field for a web address `type="url"`. A phone or tablet then shows a keyboard with the keys that value needs.

### Why

On a phone, the standard keyboard puts the at sign, the dot, the slash and the digits behind a second or third layout. Typing an email address or a phone number on it means switching layouts again and again, and every switch is a chance to hit the wrong key. The input type tells the browser what kind of value the field holds, and the browser picks a keyboard that has those keys on its first layout. On a computer with a physical keyboard the type changes nothing for typing.

The type is not the field's purpose. [WCAG 2.2, 1.3.5 Identify Input Purpose](https://www.w3.org/TR/WCAG22/#identify-input-purpose) is met by the `autocomplete` value that FRM-007 asks for, never by the type. A field with the right type and no `autocomplete` value can still fail 1.3.5, and a field without the type does not fail it. The two go together: the type picks the keyboard, the `autocomplete` value lets the browser fill the field in.

### Our reasons

Fewer than two judges have spoken about which keyboard a field calls up, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Apple supports it. So does GOV.UK, an expert witness who does not vote. Material and Carbon are silent, which is not a vote against. We ask for the type for three reasons.

- **Fewer layout switches.** The right keys on the first layout save taps on every field, and they matter most to people with motor or dexterity difficulties, for whom each extra tap is slow and can go wrong.
- **It costs nothing.** The type is one attribute. It does not change how the field looks, and on a desktop it does nothing for typing.
- **Fewer typos in values that must be exact.** An email address or a phone number with one wrong character reaches nobody, and the person often finds out only when a confirmation never arrives. Keys that are easy to reach make that slip less likely.

### Do

- On the form *Become a supplier* for a weekly food market, *Email* is `<Input type="email" autoComplete="email" />`, *Mobile number* is `<Input type="tel" autoComplete="tel" />` and *Shop website* is `<Input type="url" autoComplete="url" />`. Each field keeps its visible label, as FRM-001 asks, and the `autocomplete` values follow FRM-007.
- Let *Mobile number* take spaces, brackets, dashes and a leading plus sign. `type="tel"` only picks the keyboard; it does not check the format. Check the value in your own code, as FRM-002a and FRM-002b describe.
- Our own advice: let *Shop website* take an address typed without `https://`, such as "fieldandfork.example", and add the scheme yourself. People seldom type it. Because `type="url"` makes the browser refuse an address without a scheme, this only works with the browser's own check turned off.
- Turn the browser's own check off on the form with `noValidate`, as FRM-007 says, and show errors at the field and after a failed send as FRM-002a, FRM-002b and FRM-011 describe.
- Keep `type="email"` on the field when a zod schema already checks the address. The schema checks the value; the type picks the keyboard. They do different jobs.
- Trim spaces from an email address in your own code before you check it. Some browsers trim them in an email field and some may refuse an address with letters outside ASCII; test the addresses your users have.

### Don't

- Leave *Email*, *Mobile number* and *Shop website* at the default text type, so every one opens the letters keyboard.
- Give *Mobile number* `type="number"`. A phone number is not a quantity; FRM-014b keeps it out of a number input.
- Use the type in place of the `autocomplete` value. *Email* with `type="email"` and no `autoComplete="email"` still lacks its purpose (FRM-007).
- Give *Email or username* on a sign-in form `type="email"`. The browser's check would refuse a user name, and the keyboard would suit only half of what the field takes.

### Exceptions

- **Fields that take more than one kind of value.** A field that accepts an email address or something else, such as a user name, stays `type="text"`.
- **Digits and numbers.** Fields that take only digits, such as codes and card numbers, are FRM-014a for the keypad and FRM-014b for the type. A phone number is covered here.
- **Search fields.** Whether a search field is `type="search"` is a question of role, not of keyboard, and is outside this guideline.
- **A product that chooses otherwise.** This is a guideline. A field without the type still needs its label (FRM-001) and its `autocomplete` value (FRM-007).

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<Input>` with `autoComplete="email"`, or labelled as an email address, that has no `type`, or has `type="text"`, unless its label also names a user name.
- An `<Input>` with `autoComplete="tel"` or `tel-national`, or labelled as a phone number, that has no `type`, or has `type="text"`. A phone field with `type="number"` is FRM-014b's check.
- An `<Input>` with `autoComplete="url"`, or labelled as a website or web address, that has no `type`, or has `type="text"`.
- `type="email"` on a field labelled for an email address or a user name, such as "Email or username".

<a id="frm-014a"></a>

## FRM-014a Give a text field that takes only digits the digit keypad with inputmode

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-014a/

### Rule

When a text field takes a value made of digits only, other than a phone number, give it `inputMode="numeric"`. When it takes an amount or measurement with a decimal part, give it `inputMode="decimal"`. A phone or tablet then shows a digit keypad.

### Why

On a phone, digits sit behind a second layout of the standard keyboard, in a row of small keys. Typing a sixteen-digit card number or a six-digit code there means switching layouts and aiming at small keys, which is slow and easy to get wrong. The `inputmode` attribute asks the browser for a keypad of large digit keys instead. It only picks the keypad: it does not check or limit what can be typed, so a person with a physical keyboard, or one who pastes, loses nothing.

No WCAG criterion asks for a keypad. The field's purpose under [WCAG 2.2, 1.3.5 Identify Input Purpose](https://www.w3.org/TR/WCAG22/#identify-input-purpose) comes from its `autocomplete` value (FRM-007), not from `inputmode`; the keypad only makes the same field easier to fill in by hand.

### Our reasons

Fewer than two judges have spoken about the digit keypad, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Apple supports it. So does GOV.UK, an expert witness who does not vote. Material and Carbon are silent, which is not a vote against. We ask for the keypad for three reasons.

- **Fewer slips.** Large digit keys and no layout switching cut the taps and the mistakes on long strings of digits, most of all for people with motor or dexterity difficulties.
- **It takes nothing away.** The attribute changes only the on-screen keyboard. Paste, autofill and physical keyboards work as before.
- **The field stays a text field.** Leading zeros, spaces and long values keep working, which a number input does not promise (FRM-014b).

### Do

- On a gym's payment page, *Card number* is `<Input autoComplete="cc-number" inputMode="numeric" />` and *Security code* is `<Input autoComplete="cc-csc" inputMode="numeric" />`. Both keep their visible labels (FRM-001) and their `autocomplete` values (FRM-007). A keypad may have no space key, but spaces people paste are still accepted, as the guideline FRM-017a says.
- *Membership number* takes ten digits, such as "0471826390". It gets `inputMode="numeric"` and is checked as a string, so the leading zero stays.
- A masked *PIN* field still gets `inputMode="numeric"`. On sign-in, FRM-008 covers how it takes a paste and a password manager.
- *Top-up amount* in euros and *Room length in metres* take a decimal part, so they get `inputMode="decimal"`. Parse the value with the person's locale in mind: on many devices the decimal key types a comma.
- A postcode field gets `inputMode="numeric"` only in a country where every postcode is digits only, and keeps `autoComplete="postal-code"` (FRM-007).
- A one-time code on sign-in gets the keypad the same way; FRM-008 covers how it takes a paste.
- In JSX, write the prop as `inputMode`, which React renders as the `inputmode` attribute.
- Keep the field's type as text. Whether a digit field may be a number input is FRM-014b.

### Don't

- Use `type="number"` to get the keypad on *Card number* or *Membership number*. FRM-014b keeps such values out of a number input.
- Our own advice: don't give *Card number* `type="tel"` to get digits. That tells the browser it is a phone number, which can bring the wrong autofill suggestions.
- Rely on `pattern="[0-9]*"` alone for the keypad. It is not a keypad setting, and it starts the browser's own check when the form is sent.
- Give `inputMode="numeric"` to a value that can hold letters, such as an order reference like "RX-20931" or a postcode in a country where postcodes mix letters and digits. Some keypads have no letters at all.

### Exceptions

- **Values that can be negative.** Some digit keypads have no minus sign. A field that allows one, such as *Temperature change*, is a plain text field without `inputmode`; that is our reading of the safer choice.
- **Phone numbers.** A phone number gets `type="tel"`, as FRM-014 says, and needs no `inputmode` of its own.
- **Values that mix letters and digits.** These keep the standard keyboard; see Don't.
- **A product that chooses otherwise.** This is a guideline. A field without the keypad still needs its label (FRM-001) and its `autocomplete` value (FRM-007).

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A text `<Input>` with `autoComplete="cc-number"` or `cc-csc` and no `inputMode="numeric"`.
- A text `<Input>` validated by a digits-only pattern, such as `z.string().regex(/^\d+$/)` or `/^\d{6}$/` on a one-time code, with no `inputMode="numeric"`.
- A text `<Input>` validated by a pattern for a decimal number with no minus sign, such as `z.string().regex(/^\d+([.,]\d+)?$/)`, with no `inputMode="decimal"`.
- `inputMode="numeric"` or `inputMode="decimal"` on a field whose validation pattern allows letters, such as `/^[A-Z]{2}-\d+$/`.

<a id="frm-014b"></a>

## FRM-014b Put a string of digits that is not a quantity in a text input, never a number input

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-014b/

### Rule

Put a string of digits that is not a quantity, such as a one-time code, a card number, an account number, a phone number or a postcode, in a text input: `type="text"`, or `type="tel"` for a phone number. Never put it in `type="number"`.

### Why

A number input treats its value as a quantity that goes up and down in steps. A code or a card number never does: nobody wants the next card number. The browser's number handling then works against the value, in the ways listed under Our reasons. No WCAG criterion requires this.

### Our reasons

Fewer than two judges have spoken about which input a string of digits belongs in, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So do GOV.UK and NN/g, expert witnesses who do not vote. Material and Apple are silent, which is not a vote against. We keep such values out of a number input for four reasons.

- **The value changes on its own.** A leading zero can vanish once the value is read as a number, so "04718" becomes 4718. A long card number can be shown in exponent form or lose its last digits.
- **What people type is refused or let through wrongly.** Spaces and dashes are refused, `maxLength` is ignored, while "e", plus and minus are let through.
- **Errors cannot be explained.** A value the browser cannot read comes back empty, so the form cannot tell the person what was wrong.
- **The value moves by accident.** The arrow keys, and in some browsers the scroll wheel over a focused field, change the value when the person meant to move on.

### Do

- On a gym's payment page, *Card number*, *Security code* and *Membership number* are text inputs, with the `autocomplete` values from FRM-007. Check each value as a string, for example with `z.string().regex(/^\d{10}$/)` on the value with spaces removed, as the guideline FRM-017a describes, so leading zeros stay.
- Get the digit keypad from `inputMode="numeric"`, as FRM-014a describes, not from the number type.
- *Mobile number* is `type="tel"`, as FRM-014 says, and keeps the spaces and the plus sign the person typed.
- A one-time code on sign-in is a text input, so a pasted "482 913" goes in and the spaces can be stripped; FRM-008 covers the paste.
- Turn the browser's own check off with `noValidate`, as FRM-007 says, and show errors as FRM-002a and FRM-002b describe.
- A true small count may use a number input with step controls. On a café's booking form, *Tables* starts at 1 and is seldom more than three, so `<Input type="number" min={1} />` is allowed. This guideline does not require it.
- Our own advice, beyond this guideline: where people type an exact amount across a wide range, a text input with `inputMode="decimal"` (FRM-014a) is often the better choice.

### Don't

- Use `<Input type="number">` for *Membership number* to get the keypad. "0471826390" can come back as 471826390.
- Hide the spinner on a number input with `[appearance:textfield]` and call it a text field. The arrow keys and the scroll wheel still change the value.
- Read a code with `valueAsNumber` or `z.coerce.number()`, which throws away its leading zeros.
- Give *Postcode* `type="number"`, which refuses a postcode with a space or a letter. In a country where every postcode is digits only, it is still a text input, with `inputMode="numeric"` from FRM-014a.

### Exceptions

- **Quantities.** Counts, amounts, prices, years and ages are outside this guideline. It takes no side on quantities.
- **The keypad and the keyboard.** Which keypad a digit field shows is FRM-014a; email, phone and web address types are FRM-014.
- **Purpose.** The `autocomplete` values for card, code, phone and postcode fields are FRM-007.
- **A product that chooses otherwise.** This is a guideline. A product that keeps a number input for such a value still checks it as a string and shows errors as FRM-002a asks.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `type="number"` on an `<Input>` with `autoComplete="one-time-code"`, `cc-number`, `cc-csc`, `tel`, `tel-national` or `postal-code`.
- `type="number"` on a field labelled as a code, PIN, card, account, member, customer or order number, phone number or postcode, also when classes such as `[appearance:textfield]` hide its spinner.

<a id="frm-015"></a>

## FRM-015 Let Enter in a single-line field send the form, as its main button does

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-015/

### Rule

In a form, pressing Enter in a single-line field, such as a text, email, number or search input, sends the form, the same as pressing its main button.

### Why

People who type expect to finish with the key under their hand. When Enter in the last field does nothing, they have to reach for the pointer or tab past every other control to find the button, and someone who relies on the keyboard pays that every time. When Enter does something other than the main button, such as clearing a field or adding a row, the press they meant as "done" quietly does the wrong thing. On the web the browser already gives this for free, but only when the form is built as a real form with a real submit button, and that is easy to break in a React app without noticing.

No WCAG criterion asks for Enter to send a form, so this rule rests on the judges. The law points the same way. [WCAG 2.2, 3.2.2 On Input](https://www.w3.org/TR/WCAG22/#on-input) is about values that change the context by themselves; pressing Enter to send is the person asking on purpose, the same as pressing the button, so it sits outside what that criterion forbids and on the other side of FRM-012a. [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) asks that the keyboard can do the job; Enter in a field is one route to sending, though a submit button that Tab reaches is enough for that criterion on its own.

### Do

- On *Apply for an allotment plot*, the fields *Full name*, *Email address* and *Preferred site* sit in one `<form onSubmit={form.handleSubmit(onSubmit)}>` with `<Button type="submit">Send application</Button>` at the end. Enter in any of the text fields sends the application, exactly as a click on *Send application* does.
- A one-field form works the same way. In a team settings page, *Email address* sits above a *Send invite* button, both inside a `<form>`. The person types an address, presses Enter, and the invite goes out. A tag field labelled *New tag* with an *Add tag* button does the same.
- In a `Dialog` titled *Rename board*, put the `<form>` around the field and the `DialogFooter`, so the *Save name* submit button is inside it. If the layout keeps the footer outside, give the form an `id` and the button `form` with that id.
- On a step of a multi-step form, Enter does what *Continue* does: it sends that step.
- Our own advice: make the main button the only submit button in the form, or the first one in the code, and give every helper button `type="button"`: a *Show password* eye, a *Clear* icon, *Add another address*, a stepper's plus and minus, and *Cancel*. The stock shadcn `Button` renders a plain `button` with no type, which inside a form is a submit button unless told otherwise, and the browser presses the first one in the code. Justified's `Button` defaults to `type="button"` instead, so with it the main button needs `type="submit"` written out. A *Save draft* that sends the form with `formAction` may stay a submit button if it comes after the main one.
- On *Edit contact*, *Delete contact* sits in the same row as *Save contact*. Give it `type="button"`. Left without a type and placed first in the code, it is what Enter presses, the worst form of this break.
- When Enter sends a form with problems, handle it exactly like a click on the main button: focus goes to the first problem or to a summary, as FRM-011 says, and the errors show at their fields, as FRM-002a says.
- The guard against a second send sits on the form's submit, not only on the button's click, as the guideline STA-005b advises. Enter pressed twice then sends once.
- react-hook-form and server actions both work with the native form. Nothing more is needed than the `<form>` and `type="submit"`.
- Our own advice: let the browser do it. If a custom Enter handler cannot be avoided, call `form.requestSubmit()`, which runs validation and the submit event, never `form.submit()`, which skips both. Ignore Enter while an input method is still composing text (`e.nativeEvent.isComposing`), so people typing Japanese, Chinese or Korean do not send half a word.

### Don't

- Lay out *Email address* and *Send invite* in a `div` with `onClick={sendInvite}` on the button and no `<form>`, so Enter in the field does nothing.
- Give the main button `type="button"` and send from its `onClick`. With two fields Enter then does nothing; with one field the browser still sends the form, but around the click handler and whatever it does.
- Stop "early sends" with an `onKeyDown` that calls `preventDefault()` on Enter. If people send too soon, that is a question for validation (FRM-002b, FRM-011), not a blocked key.
- Leave the *Show password* eye without a type, before *Sign in* in the code, so Enter in the password field shows the password instead of signing in.
- Listen for Enter on `document` and send whichever form is on screen. That is not the browser's behaviour and fires from places this rule does not cover.

### Exceptions

- **Multi-line fields.** In a `Textarea`, Enter adds a new line, as the browser does by default. This rule does not change that. A chat composer that sends on Enter and adds a line with Shift+Enter is a product choice outside this rule; our own advice there is to say on screen how to add a line and to ignore Enter while an input method is composing.
- **Controls where Enter has its own job.** In an open `Select`, `Combobox` or `Command` list, a date picker grid or a list of suggestions, Enter picks the item and does not send the form; FRM-012b and FRM-013 already say a choice only records it. A button with focus runs itself, not the main button.
- **Destructive confirmations.** This rule does not apply where the person confirms a destructive action. In a dialog, Enter in a field, such as one asking for the name of what will be deleted, must not run the action, as DLG-004 says. Our own choice: the same holds on a page, such as *Delete account* behind a field that asks for the account name.
- **Two equal choices.** When a form has two submit buttons and neither is the main one, this rule does not decide which one Enter presses; the browser takes the first in the code. Our own advice: put the safer one first. Enter still never presses a helper button such as *Show password*.
- **An unavailable main button.** A submit button that is switched off also stops Enter. The guideline ACT-004 advises keeping it on in long forms. Where ACT-004 leaves a short form out of scope and the team switches the button off, Enter doing nothing is expected, and the note before the button says why, as ACT-005 asks.
- **Fields outside a form.** A filter box that narrows a list as people type, or an inline rename in a table cell, is not a form. What Enter does there is not decided by this rule.
- **Neighbouring rules.** The keyboard in general is KBD-001; this rule is a narrower case and KBD-001 does not require it on its own. Which button gets the emphasised style is ACT-002a.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Single-line `<Input>` fields and the button that sends them with no `<form>` around them, the button sending through `onClick` only. Leave a filter box or an inline edit in a table cell (see Exceptions).
- A `<form>` holding a single-line field with no `type="submit"` button inside it and none tied to it with `form="…"`, such as a main `<Button type="button" onClick={form.handleSubmit(onSubmit)}>`, or a main Justified `Button` with no `type`, which renders `type="button"`. Leave a destructive confirmation.
- An `onKeyDown` on a `<form>` or a single-line input that calls `preventDefault()` when `e.key === "Enter"`. Leave a handler that then calls `requestSubmit()` or acts only while `isComposing`, and leave combobox, list, textarea and destructive cases (see Exceptions).
- A `<button>` or stock shadcn `Button` with no `type` inside a `<form>`, placed before the main submit button in the code, such as a show-password or clear icon, so Enter presses it instead.
- A `Dialog` or `Sheet` whose `<form>` ends before the `DialogFooter` or `SheetFooter` holding the main button, with no `form="…"` on that button. Leave alone a dialog that confirms a destructive action.

<a id="frm-016a"></a>

## FRM-016a Let a click on a checkbox's or radio button's text change it, as a click on the box does

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-016a/

### Rule

When a checkbox or a radio button shows its own text beside it, a click, tap or pen press on that text checks or unchecks the checkbox, or selects the radio button, exactly as a press on the box or circle does.

### Why

The box or circle is small, and the words beside it are what people read and aim at. When the words do nothing, a near miss on the box is a lost press, and anyone with a tremor or a large fingertip pays for it most. Making the text respond gives each option a target as wide as its words, with no change to how it looks.

WCAG does not require this. It supports it: the label technique for [WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) ([H44](https://www.w3.org/WAI/WCAG22/Techniques/html/H44)) names the larger click area as an extra gain for people with limited motor control, and a responding label serves the same need as [2.5.8 Target Size (Minimum)](https://www.w3.org/TR/WCAG22/#target-size-minimum). Text that does not respond does not by itself fail either criterion. Whether the control has a name in code is FRM-010; whether the box itself is large enough is ACT-006.

### Do

- On a ferry booking form, the checkbox *Add a cabin for the night crossing* is a shadcn `Checkbox` with `id="cabin"` and a `<Label htmlFor="cabin">` beside it. A click on the words ticks the box and does everything a click on the box does, firing the same `onCheckedChange`.
- The question *Seat type* is the `<legend>` of a `FieldSet` around a `RadioGroup`, as FRM-010 advises. Each `RadioGroupItem`, *Reclining seat* and *Cabin bed*, has its own `Label` tied to its `id`, so a tap on *Cabin bed* picks that option.
- In a list of options built with `.map()`, build each `id` from the item's key or from `useId()`, so every label reaches its own control.
- In shadcn's `Form`, keep the `FormLabel` in the same `FormItem` as the `FormControl`; it gets the right `htmlFor` by itself. The `Field` component with `FieldLabel` does the same.
- Wrapping the control and its text in one `<label>` works too. An option card where the whole card is the label is fine, as long as the card holds no other control.
- A disabled option stays still when its text is clicked, just as when its box is.

### Don't

- Put *Add a cabin for the night crossing* in a `<span>` next to the box, so the words look like a label and do nothing.
- Name the box with `aria-label` and leave the visible text as plain text. FRM-010 may be met; this rule is still broken.
- Give every mapped `Checkbox` the `id` "option", so each label ticks the first box.
- Fake it with an `onClick` on the row `div`. A click on the box then toggles twice, and nothing is tied for assistive technology.
- Put a click handler on the row or the label that toggles the box, so a click on the link *cabin prices* inside the option's text also ticks it. A plain link in a `<label>` only follows the link. Nor let a link fill most of the text, which leaves little to click that ticks the box.

### Exceptions

- **No text of its own.** A checkbox with no visible text beside it, such as one that selects a table row, is outside this rule. Its name in code is FRM-010.
- **Other text.** Only the option's own text is meant. A group label, a hint under the option or a heading need not respond.
- **Target size.** This rule does not make a small box pass ACT-006. The text counts toward the target only as ACT-006 says.
- **Switches.** A switch's text is FRM-016b.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `<Checkbox>` or `<RadioGroupItem>` whose visible text sits in a `<span>`, `<p>` or `<div>` beside it, with no `<Label htmlFor>` or `<label htmlFor>` matching its `id`, no wrapping `<label>`, and no `FormLabel` in the same `FormItem` or `FieldLabel` in the same `Field`.
- A `<Label>` beside a checkbox or radio button with no `htmlFor`, or one that matches no control's `id`, for example because the `id` sits on a wrapping `div`.
- Options rendered with `.map()` that give every item the same hard-coded `id`, so each label selects the first option.
- `pointer-events-none` on the label of an enabled option, not only in a disabled variant such as `group-data-[disabled=true]:`, or an `absolute` sibling placed over the label text, so a click on the text never reaches it.
- A row `div` with an `onClick` that sets the checked state, standing in for a label tied to the control.

<a id="frm-016b"></a>

## FRM-016b Let a click on a switch's text turn it on or off, as a click on the switch does

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-016b/

### Rule

When a switch shows its own text beside it, a click, tap or pen press on that text turns the switch on or off exactly as a press on the switch does.

### Why

A switch and its text read as one setting, and people aim at the words as often as at the small track. Text that does nothing turns a near miss into a lost press. WCAG does not require this; a responding label serves the same need as [WCAG 2.2, 2.5.8 Target Size (Minimum)](https://www.w3.org/TR/WCAG22/#target-size-minimum), and text that does not respond does not by itself fail it. Checkboxes and radio buttons are FRM-016a, a rule.

### Our reasons

Fewer than two judges have spoken about the text of a switch, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. We make it for two reasons.

- **One setting, one target.** The words and the track say the same thing, so a press on either should do the same.
- **One way of building.** The switch then works like the checkbox and radio button in FRM-016a, with the same label tied to the same kind of control.

### Do

- In a ferry app's settings, the row *Email me before departure* holds a shadcn `Switch` with `id="departure-email"` and a `<Label htmlFor="departure-email">`. A tap on the words turns the switch on and does everything a tap on the track does, firing the same `onCheckedChange`.
- In a `justify-between` row, where the text sits at the far side from the switch, tie the two with `htmlFor` and `id`, or wrap the row in one `<label>`.
- A whole row may act as the label, as long as it holds no other control, such as a *Learn more* link or a help button.
- In a list of settings built with `.map()`, build each `id` from the setting's key or from `useId()`.
- A switch that applies its setting at once does exactly the same when its text is pressed, no more. FRM-012a still applies.

### Don't

- Put *Email me before departure* in a `<span>` beside the switch, so the words do nothing.
- Use a `<Label>` with no `htmlFor` at the other end of the row.
- Give every mapped `Switch` the same `id`, so each label flips the first one.
- Fake it with an `onClick` on the row `div` that flips the state. A tap on the switch itself then flips it twice, and nothing is tied for assistive technology.

### Exceptions

- **No text of its own.** A switch with no visible text beside it is outside this guideline. Whether it needs text is FRM-001, and its name in code is FRM-010.
- **Target size.** This guideline does not make a small switch pass ACT-006.
- **A product that chooses otherwise.** This is a guideline. A product whose switch text does not respond still names the switch as FRM-010 asks.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `<Switch>` whose visible text sits in a `<span>`, `<p>` or `<div>` beside it, with no `<Label htmlFor>` or `<label htmlFor>` matching its `id`, no wrapping `<label>`, and no `FormLabel` in the same `FormItem` or `FieldLabel` in the same `Field`.
- A `<Label>` beside a switch with no `htmlFor`, or one that matches no control's `id`, for example in a `justify-between` settings row.
- Settings rendered with `.map()` that give every `Switch` the same hard-coded `id`, so each label turns the first one on or off.
- `pointer-events-none` on the label of an enabled switch, not only in a disabled variant such as `group-data-[disabled=true]:`, or an `absolute` sibling placed over the label text, so a click on the text never reaches it.

<a id="frm-017"></a>

## FRM-017 Let every text field take a pasted value, and never cut it without saying so

Guideline, our choice. Verdict: Insufficient evidence (0 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-017/

### Rule

Outside sign-in, which FRM-008 covers, let every text field and text area take a pasted value. Never block a paste, and never cut or drop pasted characters without saying so. Removing separators from the value that is checked, as FRM-017a describes, is not such a change.

### Why

People paste because retyping is slow and easy to get wrong. A policy number from an email, a reference from a letter or a paragraph drafted in another app reaches the field in one step and exactly as it was. When a field refuses the paste, the person has to read the value character by character and type it again, which is hardest for people with memory, reading or motor difficulties. When the page cuts or alters the paste out of sight, the field holds something the person did not give, and they have no reason to look.

WCAG requires paste only at sign-in. [WCAG 2.2, 3.3.8 Accessible Authentication (Minimum)](https://www.w3.org/TR/WCAG22/#accessible-authentication-minimum) is FRM-008. Outside sign-in, this guideline is our choice and not a WCAG requirement. [3.3.7 Redundant Entry](https://www.w3.org/TR/WCAG22/#redundant-entry) supports it loosely: pasting from an earlier screen is one way people cope with being asked for a value again.

### Our reasons

No judge has spoken about paste outside sign-in, so the verdict is Insufficient evidence (0 of 3 judges spoke) and this guideline is our choice. GOV.UK and NN/g support it; they are expert witnesses who do not vote. We let every field take paste for four reasons.

- **The reason WCAG gives at sign-in holds everywhere.** Copying spares people from holding a value in their head and typing it out. An account number or a booking reference is as long and as easy to mistype as a password.
- **Blocking paste does not make a value more correct.** A person told to type a value again types it from the same place they would have copied it, and a typed copy is more likely to hold a slip than a pasted one.
- **A silent change is worse than a refusal.** A refused paste is at least noticed. A paste that loses its last characters, or a few of its letters, looks right at a glance and is sent wrong.
- **It costs the product nothing.** The page can still clean and check the value after it arrives (FRM-017a) and hold free text to a limit (FRM-017b and FRM-017c).

### Do

- On a home insurance claim form, *Policy number* is a plain `<Input>`. The person copies "HX-4471-0923" from their renewal email and pastes it, and it arrives whole.
- *What happened* is a `<Textarea>`. A paragraph written earlier in a notes app goes in as pasted.
- *Booking reference* is shown as two boxes of three characters, six in total. A paste of "KP4-92X" into either box spreads across both, as FRM-008 asks of code boxes at sign-in.
- The field keeps what the person pasted. Spaces at either end and separators are removed only from the value that is checked and sent, as FRM-017a describes.
- On a number or code field, leave `maxLength` off and check the length after cleaning, so a paste with spaces in it is never cut. FRM-017a says the same.
- When a paste is longer than a free-text field allows, the field says so, as FRM-017c describes, and does not cut it in silence.
- If a form asks for a value a second time anyway, such as *Confirm account number*, that field takes paste too. Whether to ask twice at all is FRM-009.
- When an account is created, *New password* and *Confirm new password* take paste, so a password from a password manager can go in. FRM-008 leaves these fields out of its scope; this guideline asks that they take paste.
- A rich text editor may paste as plain text and drop formatting. The result is in the editor, where the person can see and change it.

### Don't

- Put `onPaste={(e) => e.preventDefault()}` on *Confirm account number* so that people have to type it twice.
- Wrap `<Input>` in a custom component that cancels paste to keep a mask intact.
- Use a masking library that drops a pasted value because it has a space or a hyphen the mask does not expect.
- Give *What happened* `maxLength={500}` with no count, so a 700-character paste keeps the first 500 and nothing says so.
- Strip every character that is not a digit from a pasted policy number when letters are part of it, and send what is left.

### Exceptions

- **Removing separators.** Removing spaces, hyphens and other separators from the value that is checked, as FRM-017a describes, is not a change to the paste under this guideline.
- **Sign-in.** Every step of signing in, and of getting back into an account, is FRM-008, which WCAG requires.
- **When typing is the task.** A typing test, or an answer that only means something if the person types it, such as a spelling exercise, may refuse paste. Keep this to fields where the typing itself is what is being checked.
- **Filling by the browser.** Filling a field from the browser or a password manager is a different route from paste and is covered by FRM-007.
- **A product that chooses otherwise.** This is a guideline. A field that refuses paste still needs its visible label (FRM-001) and its `autocomplete` value where FRM-007 asks for one.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `onPaste` that calls `preventDefault()` or returns `false` on a text field or text area, or a `paste` listener on a form or on `document` that cancels the event, without inserting the pasted text itself. Sign-in fields are FRM-008; leave alone a field where typing is the task (see Exceptions).
- A code split over several inputs, each with `maxLength`, and no `onPaste` that spreads the value, so a paste into the first box fills only that box.
- A key filter in `onKeyDown` or `onBeforeInput`, or a masking library, that throws away a whole pasted value, or part of it, with nothing on screen saying so.
- A `maxLength`, or an `onChange` that keeps only `value.slice(0, n)`, with nothing at the field that says how much of a paste did not fit (FRM-017c). On a number or code field, check the length after cleaning instead (FRM-017a).

<a id="frm-017a"></a>

## FRM-017a Accept the spaces and separators people write in a number or code, and remove them before checking

Guideline, our choice. Verdict: Insufficient evidence (0 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-017a/

### Rule

When a field takes a number or code people write in several ways, such as a phone or card number, accept the spaces, hyphens, brackets, dots and letter case they type or paste, and remove them before checking.

### Why

People copy numbers from cards, letters and other apps with whatever spacing they came with, and voice input adds spaces of its own. A value that is right but refused because of a space is hard to put right: the space is easy to miss, and harder still to find with a screen reader, magnification or dictation. The value is only wrong in the form the page expected, so the page can fix it instead of the person.

[WCAG 2.2, 3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) and [3.3.3 Error Suggestion](https://www.w3.org/TR/WCAG22/#error-suggestion) allow a page to refuse such a value, as long as it says what is wrong and how to fix it. [3.3.2 Labels or Instructions](https://www.w3.org/TR/WCAG22/#labels-or-instructions) asks that a format the page needs is stated. Accepting the value in the first place is a step beyond what those criteria ask, and that step is our choice.

### Our reasons

No judge has spoken about separators in numbers and codes, so the verdict is Insufficient evidence (0 of 3 judges spoke) and this guideline is our choice. GOV.UK and NN/g support it; they are expert witnesses who do not vote. GOV.UK gives a dissenting opinion on formatting the value as people type. We allow it within three limits rather than ban it. We accept separators for four reasons.

- **The person did nothing wrong.** "4111 1111 1111 1111" is how the number is printed on the card. Refusing it puts the work on the person and adds an error they have to read, understand and fix.
- **Cleaning is cheap and certain.** Removing spaces, hyphens, brackets and dots, and folding letter case, takes one line of code and loses nothing for these values.
- **A hidden space is the hardest error to see.** A message saying "Enter a valid card number" next to a number that looks valid sends people looking for a mistake they cannot find.
- **A formatter that works against the person is worse than none.** Keeping the caret in place is our own reading of what that means: a field that jumps the caret to the end after each edit in the middle makes a small fix hard, and no source names this. The other two limits, no refused character and no lost paste, follow from the rest of this guideline.

### Do

- A field that formats as people type never refuses a character, drops a paste or moves the caret from where they type.
- On a library's membership form, *Library card number* is checked with a schema that cleans first: `z.string().transform((v) => v.replace(/[\s\-().]/g, "")).pipe(z.string().regex(/^\d{14}$/))`. "2938 0047 1182 06" and "29380047118206" both pass.
- *Mobile number* takes "+44 7700 900123", "07700 900123" and "(07700) 900-123". Keep a leading plus sign; remove the rest of the separators before checking.
- *Booking reference* takes "kp4 92x", "KP492X" and " KP4-92X ". Fold it to one case and remove spaces and hyphens before checking.
- Clean the value that is checked and sent, not what the field shows. The field keeps what the person typed or pasted, so they can compare it with where it came from. FRM-017 counts this cleaning as no change to the paste.
- If *Card number* adds a space after every four digits as people type, a typed space or hyphen is ignored rather than refused, a pasted "4111-1111-1111-1111" is reformatted whole, and an edit in the middle leaves the caret where the person is typing.
- If the field shows a prefix such as "+44" outside the input, accept the prefix typed again in the field too.
- Leave `maxLength` off these fields and check the length after cleaning. A cap sized for any one format still cuts a paste in another, with nothing to say so, which FRM-017 rules out. An error for a value that is still wrong after cleaning appears at the field (FRM-002a) and says what to do, such as "Enter a card number with 16 digits", as TXT-001a describes.
- Keep these fields as text inputs (FRM-014b). A digit keypad from `inputMode="numeric"` (FRM-014a) may have no space or hyphen key; that is fine, since this guideline asks only that separators people type or paste are accepted.

### Don't

- Check *Card number* with `z.string().regex(/^\d{16}$/)` on the raw value, so "4111 1111 1111 1111" fails with "Invalid card number".
- Block every key but digits in `onKeyDown`, so *Mobile number* refuses the plus sign and the space.
- Give *Card number* `maxLength={16}`, so the spaces people write use up characters and a pasted "4111 1111 1111 1111" loses its last four digits.
- Rewrite the value in `onChange` with `.replace(/\D/g, "")` on a controlled `<Input>`, so the caret jumps to the end after an edit in the middle that the rewrite changes, such as a space typed between two digits.
- Use a phone mask with the placeholder "(___) ___-____", which drops a paste in any other country's format.

### Exceptions

- **Amounts and quantities.** Prices, sums and measurements are outside this guideline. Their decimal and thousands separators depend on the person's locale, which is a different problem.
- **Free text.** Names, addresses and messages keep the characters people type. Length limits on free text are FRM-017b and FRM-017c.
- **Sign-in codes.** A one-time code with a space in it is FRM-008.
- **A value that is still unclear after cleaning.** When the cleaned value could mean two things, such as a phone number that could belong to two countries, ask, or show an error that states the format, as FRM-002a and TXT-001a describe.
- **A product that chooses otherwise.** This is a guideline. A field that refuses separators still states the format it needs (3.3.2) and explains a refused value (3.3.1, 3.3.3).

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A Zod `.regex()` or `.length()` on a phone, card, account or reference value with no `.transform()` or `z.preprocess()` before it that removes spaces, hyphens, brackets and dots, such as `z.string().regex(/^\d{16}$/)` on the raw value.
- An `onKeyDown` or `onBeforeInput` on such a field that calls `preventDefault()` for every key that is not a digit, so a space, hyphen or plus sign is refused.
- `maxLength` on such a field, such as `maxLength={16}` on a card number, which cuts a value pasted with its separators, or `pattern="[0-9]*"` with the browser's own check switched on.
- A controlled `<Input>` whose `onChange` rewrites the value, such as `.replace(/\D/g, "")` or adding separators, with no code that puts the caret back where the person was typing after an edit in the middle that the rewrite changes.
- A masking library set to drop a pasted value that does not match its pattern, or a fixed placeholder such as "(___) ___-____" that takes one country's phone format only.

<a id="frm-017b"></a>

## FRM-017b State a free-text field's length limit and show how much is used

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-017b/

### Rule

When a free-text field limits how many characters or words it takes, state the limit in its label or hint and show how much is used in a count that is tied to the field in code.

### Why

A limit people cannot see is one they find only by running into it. Knowing it before they start lets people plan what to write, and a count lets them trim while they write instead of after they are stopped or refused. A screen reader user cannot glance at a counter in the corner, so the count has to be tied to the field and read as words.

No WCAG criterion requires a counter. [WCAG 2.2, 3.3.2 Labels or Instructions](https://www.w3.org/TR/WCAG22/#labels-or-instructions) supports stating the limit, and [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) supports how a changing count reaches assistive technology without taking focus. What happens when the limit is reached is FRM-017c.

### Our reasons

Fewer than two judges have spoken about showing a length limit and a count, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Material supports it. So does GOV.UK, an expert witness who does not vote. Carbon and Apple are silent, which is not a vote against. We ask for the limit and the count for three reasons.

- **A rule people cannot see is unfair.** The product knows the limit from the start. Keeping it to itself until the text is too long makes the person pay for what the product did not say.
- **Writing to a length is easier with a gauge.** A person who sees "120 characters left" can choose what to cut. One who sees nothing finds out when the text stops going in or the form is refused.
- **The count costs little.** It is one line of text under the field, tied to it in code.

### Do

- On a volunteer sign-up form, *Tell us about yourself* has the hint "Up to 500 characters" and a count under the field that reads "320 characters left". The field points to the hint and the count with `aria-describedby`.
- Our own choice: the count may appear only once the person is near the limit, such as within 50 characters, as long as the hint states the limit from the start.
- The count reaches a screen reader as a polite announcement, as FBK-004 describes, and not on every key: for example when the person pauses, or once they are near the limit. It says the whole phrase, "20 characters left", not "20".
- A word limit works the same way: "Up to 250 words" in the hint and "40 words left" as the count.
- Count as the server counts. If the server counts a line break or an emoji differently, the visible count matches the server, so nobody is refused below the limit they were shown.
- The live count is not an error. It may change while the person types. An error for text that is too long appears when they leave the field or send the form, as FRM-002b says.

### Don't

- Copy `maxLength={500}` from the database column onto *Tell us about yourself* with no hint and no count.
- Put the limit only in `z.string().max(500)`, so the first sign of it is an error after the form is sent.
- Render `{value.length}/500` in a `<span>` that is not tied to the field, so a screen reader user never hears it.
- Announce the count with `aria-live="assertive"` on every key, so it interrupts the person as they type.

### Exceptions

- **Reaching the limit.** What the field says when the limit is reached or passed, and whether it stops input, is FRM-017c.
- **Short coded fields.** A postcode, a card number or another code is FRM-017a, which checks the length after cleaning.
- **Paste.** Whether a field takes a paste at all is FRM-017.
- **A product that chooses otherwise.** This is a guideline. A product without a count still never cuts text in silence (FRM-017c) and shows an error for text that is too long as FRM-002a describes.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `maxLength` on a `<Textarea>` or a free-text `<Input>` with no limit in its label or hint, or with no count anywhere in the field's markup.
- A limit only in a schema, such as `z.string().max(500)`, with no limit stated and no count shown before the form is sent.
- A count such as `{value.length}/500` in a `<span>` that the field does not point to with `aria-describedby`.

<a id="frm-017c"></a>

## FRM-017c Say in words when a free-text limit is reached, and never cut text in silence

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/frm-017c/

### Rule

When a free-text field limits how many characters or words it takes, say in words when people reach or pass the limit. Never stop or cut typed or pasted text without saying so.

### Why

A field that stops taking text without a word looks broken: the person keeps typing and nothing appears. A paste that loses its end looks whole at a glance and is sent short. A screen reader user cannot see either happen, so the field has to say it. [WCAG 2.2, 3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) supports naming the error when text is too long, and [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) supports how a message at the limit reaches assistive technology without taking focus. Neither requires a message at the limit itself.

### Our reasons

Fewer than two judges have spoken about what a field says at its limit, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So does GOV.UK, an expert witness who does not vote. Material and Apple are silent, which is not a vote against. We ask for words at the limit for three reasons.

- **A silent stop is mistaken for a fault.** People who see nothing appear as they type try again, reload or give up. One short line tells them the field is working and why it stopped.
- **A silent cut changes what is sent.** The end of a message is often the part that matters most, such as the question or the date. Losing it without a sign sends something the person did not write.
- **Colour is not words.** A count that turns red tells nothing to people who cannot see the colour or do not know what it means, as VIS-003a says.

### Do

- On a volunteer sign-up form, *Tell us about yourself* takes up to 500 characters. If input stops at 500, the count under the field reads "Limit reached".
- When a paste is cut at a hard stop, the line says how much did not fit: "Limit reached. The last 200 characters you pasted were not added."
- If input runs past 500 instead, the count reads "20 characters over the limit". That count is not an error while the person types: no `aria-invalid` and no error styling on a key press. The error appears at the field when they leave it or send the form (FRM-002a, FRM-002b), such as "Your answer to Tell us about yourself is 520 characters. Shorten it to 500 or fewer.", worded as TXT-001a describes.
- The words at the limit reach a screen reader without moving focus, as FBK-004 describes.
- Our own advice: saved text that is already over a new, lower limit shows as over and is not cut.
- A word limit works the same way: "Limit reached" or "12 words over the limit".
- How the limit and the count are shown before the person gets there is FRM-017b.

### Don't

- Put `maxLength={500}` on *Tell us about yourself*, so a 700-character paste keeps the first 500 and nothing says so.
- Trim the value in `onChange` with `value.slice(0, 500)` and leave the field silent.
- Turn the count red at the limit with no words.

### Exceptions

- **Hard stop or overflow.** Input may stop at the limit, or run past it and show an error. This guideline allows both and does not choose.
- **Short coded fields.** A postcode, a card number or another code is FRM-017a, which checks the length after cleaning.
- **Paste.** Whether a field takes a paste at all is FRM-017.
- **A product that chooses otherwise.** This is a guideline. A product that leaves out the words at the limit still states the limit and shows the count (FRM-017b).

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `maxLength` on a `<Textarea>` or a free-text `<Input>` with no text that appears when the limit is reached.
- An `onChange` that keeps only `value.slice(0, max)` on a free-text field, with nothing on screen that says the text was cut.
- A count or field that only changes colour at the limit, with no words such as "Limit reached" or "20 characters over the limit".

<a id="kbd-001"></a>

## KBD-001 Let the keyboard do everything the pointer can, and show where focus is

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/kbd-001/

### Rule

Everything a person can do with a pointer can also be done with the keyboard alone, unless the task depends on the path of the movement; and whenever an element has keyboard focus, a visible indicator marks it for as long as it has focus.

### Why

Many people never touch a mouse or a touch screen. Some cannot see a pointer, some cannot hold one steady, and some move faster with keys. For them, a task that needs a pointer is a task they cannot finish, and a page that hides focus leaves them guessing where the next key press will land. [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) requires that all functionality works from a keyboard, either through the same control or through a comparable keyboard route that reaches the same result, and [2.4.7 Focus Visible](https://www.w3.org/TR/WCAG22/#focus-visible) requires that keyboard focus can be seen. Neither sets a size or a shape for the indicator. When we style the indicator ourselves, [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) also applies: it shows a state, so the part people need to see in order to find focus needs at least 3:1 against the colours next to it. Those are the colours it actually touches, so where you draw the ring decides what it is measured against. An indicator left exactly as the browser draws it is outside that figure but must still be visible. [2.4.13 Focus Appearance](https://www.w3.org/TR/WCAG22/#focus-appearance) sets further thresholds, but it is Level AAA, so it is a further step you may take, not a requirement of this rule.

### Do

- Build actions from real `<button>`, `<a href>` and form elements. They take focus and respond to keys without extra code. In the shadcn adapter, `Button`, `Checkbox`, `RadioGroupItem`, `Switch` and the field controls already do this. Their role in code is ACT-009.
- Give a sortable list *My favourites* a keyboard route next to the drag handle: a menu on each row with *Move up* and *Move down*, or arrow keys while the row is picked up. Keep a click or tap way that needs no dragging too, as ACT-007a requires; what a screen reader hears during the move is ACT-007b.
- Let a price slider *Price, £0–£5,000* move with the arrow keys, and let Home and End jump to its ends.
- When a row in *Upcoming bookings* shows *Change* and *Cancel booking* on hover, show them on keyboard focus as well. In a table row, TBL-003 covers this.
- Offer a keyboard shortcut such as Alt+Shift+N for *New note*, matched on `e.code` so Option on a Mac does not change the key, as an extra, beside a button that does the same thing. Which keys to choose and how people find and change them is KBD-003, KBD-003a and KBD-003b.
- Keep the indicator on for as long as the element has focus. Showing it only for keyboard focus, as `:focus-visible` does, is fine.
- Keep the visible part of an indicator we style ourselves at 3:1 or more against the colours next to it, in both themes. We measure in both themes, as VIS-001 explains. Our `focusRing` draws a 2px ring outside the control with a 2px gap in the page colour, and our contrast test checks the ring against the page, card, muted and accent surfaces in both themes.
- Make the indicator survive forced-colours mode (Windows high contrast). That mode drops box shadows, so a shadow ring alone disappears. Our `focusRing` keeps `outline-none` on the base state and adds `focus-visible:outline-hidden`, a transparent outline that forced-colours mode draws in a system colour, so an outline appears there on keyboard focus. This is our own technical point.
- Give every focusable thing an indicator: links, switches, radio buttons, a scrollable *Terms* box and a card that acts as one big link.

### Don't

- Put a click handler on a `<div>` that looks like a button, such as *Show more trips*, and give it no focus and no key handling.
- Let a file upload *Upload receipt* work only by dropping files on a drop zone, with no button that opens the file picker. It fails ACT-007a as well.
- Set `outline: none` on all controls and add nothing in its place, so Tab moves through *Search tickets* without any visible sign.
- Show focus on *Add passenger* only by turning its background a shade lighter. It is easy to miss and may rely on colour alone; use a ring or an outline.
- Let the ring fade out a second after a control gets focus.
- Move focus away by script as soon as an element receives it.
- Make a key held down for two seconds, or a fast double press, the only way to confirm *Confirm payment*.
- Treat a mode that steers the mouse pointer with the arrow keys as keyboard support.

### Exceptions

- **Path-based tasks.** When the result is the path itself, such as tracing a running route by hand on a map in *Draw your route*, that tracing is exempt. The controls around it, such as *Undo*, *Clear* and *Save route*, are not, and a way to enter the route stop by stop is still welcome.
- **Disabled controls.** A control that is off need not take focus; ACT-005 relies on this.
- **Neighbouring rules.** Getting out of a dialog by keyboard is in DLG-001, focus into, inside and out of a modal dialog is in DLG-006 and DLG-007, the order focus moves in is in LAY-002, and focus hidden by sticky bars or other layers is in KBD-002. The way without dragging is ACT-007a, sortable table headers TBL-002 and row actions TBL-003. A control's role is ACT-009, its hover and pressed looks VIS-008, and Enter in a form FRM-015. This rule does not repeat them.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `<div>`, `<span>` or `<li>` with `onClick` but no `role`, `tabIndex` and key handler, such as a fake *Show more* button. Leave alone a clickable card or row whose link or button inside does the same thing. The missing role is ACT-009.
- `outline-none`, `focus:outline-none` or `outline: none` on a focusable element with no other focus style on it, such as `focus-visible:ring-*` or `focus-visible:outline-*`.
- Controls shown only on hover, such as `opacity-0 group-hover:opacity-100` or `hidden group-hover:flex`, with no matching `group-focus-within:` or `focus-visible:` class.
- A dnd-kit `useSensors` with `PointerSensor`, `MouseSensor` or `TouchSensor` but no `KeyboardSensor` and no other keyboard route such as *Move up*, or a react-dropzone area with `noKeyboard: true` and no button that calls `open()`. Leave alone drawing a path by hand.
- A focus style that is only a slight change, such as `focus:bg-accent` alone on an item with no ring or outline. Check that the indicator is plain to see. A shadow ring alone is fine here; forced colours is our own advice in Do.

<a id="kbd-002"></a>

## KBD-002 Keep the focused element at least partly in view

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/kbd-002/

### Rule

When an element has keyboard focus, at least part of it stays in view: no sticky header or footer, toast, cookie banner, chat button or panel that the page put on screen may cover it completely.

### Why

A keyboard user follows the focus to know where they are. If it moves under a bar or a banner, they press Tab and see nothing happen. They cannot tell which control will react to Enter, and they may give up or act on the wrong thing. The same goes for people who use switches or voice control, and for people who zoom in and see only a small part of the page at a time. [WCAG 2.2, 2.4.11 Focus Not Obscured (Minimum)](https://www.w3.org/TR/WCAG22/#focus-not-obscured-minimum) requires that content the page itself places on top never hides the focused element completely. Partly hidden still meets the criterion. Our aim goes further and keeps the whole element in view, as [2.4.12 Focus Not Obscured (Enhanced)](https://www.w3.org/TR/WCAG22/#focus-not-obscured-enhanced) asks at Level AAA, but that is not required here. Whether the focus indicator exists and can be seen is KBD-001. What sticky bars do at 320 pixels is LAY-001.

### Do

- Reserve scroll room for sticky bars. Set `scroll-padding-top` on the scrolling element to the height of a sticky header, and `scroll-padding-bottom` to the height of a sticky footer, so the browser stops a newly focused element clear of them. `scroll-margin` on the elements themselves works too.
- Let that reserved room follow the bar's real height. A header with *My account* and *Sign out* that grows to two lines with larger text needs more room, so read the height from a CSS variable that changes with the breakpoint, not a fixed number.
- Leave enough space at the end of the page that the last links, such as *Accessibility statement* and *Contact*, can scroll up above a sticky footer with a *Go to checkout* button.
- Tab down a long page and back up again under the sticky header, and check every focused element stays at least partly in view both ways.
- Keep a cookie banner in the normal flow at the very start of the page, so it pushes content down instead of lying over it. When the person picks *Accept all* or *Necessary only*, it goes away.
- Place toasts and chat buttons in empty space where no control sits under them, and check that space at every breakpoint. Make them smaller or move them where it is tight.
- Place a toast with *Undo* after *Archive* so it never covers the row of buttons that has focus. If the person tabs on to *Edit* in the row below, that button must still show.
- Where there is room, let a side panel such as *Filter* push the main area narrower so it reflows, rather than lie over the result list. Where the panel must lie over the list, as at narrow widths in LAY-001, the person opens it, and it either closes with Escape or keeps focus inside until closed.
- Treat a modal dialog as already meeting the rule when focus moves into it as it opens and the page behind cannot be used until it closes, as DLG-006 and DLG-007 say.
- Close an autocomplete list for *City* as soon as focus leaves the field, so it never stays over the next field.
- Test with the page zoomed to 400 percent as well as at full size, since layers take a larger share of the screen when zoomed.

### Don't

- Fix a header to the top with no reserved scroll room, so tabbing back up puts *Search* or a link in the article right under it.
- Fix a cookie banner to the bottom of the viewport while the page behind it can still be used, so it hides *Read more* and *Next* as focus moves down.
- Show a lasting toast, such as "Your change is saved" with *Undo*, in the top right where it covers the user menu *Anna S* when that gets focus.
- Leave a chat button in the bottom right over a small link such as *Terms*, so the link vanishes completely when it has focus.
- Let a promotional pop-up appear by itself over the form and stay there while the person tabs through the fields behind it.
- Treat a toast as fine because the person can tab to its close button. The focused element was hidden before they could.
- Rely on a semi-transparent or blurred layer to keep focus visible without checking that the indicator seen through it still has enough contrast, as [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) asks.

### Exceptions

- **A layer the person opened.** If the person opened a layer themselves, such as a chat window from *Chat with us*, it may cover the focused element as long as they can uncover it without moving focus, for example by pressing Escape to close it or by scrolling the page. A toast that appears after the person's own action, such as saving or archiving, does not count as opened by them. The page placed it, so the rule applies in full.
- **A panel the person can drag.** If people can move a toolbar or panel, judge it where it first appears. A design that also keeps focus clear after a move is better.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Tab down a long page and back up, at full size and at 400 percent zoom, and see whether any focused element goes fully under a sticky header or footer, a toast, a cookie banner or a chat button.
- A `sticky top-0` or `fixed` header or footer with no matching `scroll-pt-*` or `scroll-pb-*` on the scrolling element and no `scroll-mt-*` on the elements.
- A `fixed bottom-0` cookie banner or a `fixed` chat button over a page that can still be used, or a sonner `Toaster` placed over controls such as the user menu.
- A pop-up or panel the page opened by itself over a form while the person tabs through it. Leave alone a layer the person opened, if Escape or scrolling uncovers the focused element; a toast after their own action does not count as opened by them.

<a id="kbd-003"></a>

## KBD-003 Let people turn off or change a shortcut made only of character keys

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/kbd-003/

### Rule

When the page reacts to a shortcut made only of character keys (letters, digits, punctuation or symbols, with or without Shift), people can turn it off or change it to include a key that types nothing, such as Ctrl, Alt or Cmd, unless it works only while its own control has focus.

### Why

A shortcut on a single letter fires whenever that letter reaches the page. Some speech input programs turn spoken words into key presses, so a stray word can archive, delete or move things they never meant to touch. Keyboard users with tremors hit keys by accident, and the same happens to anyone whose focus has slipped out of a field. [WCAG 2.2, 2.1.4 Character Key Shortcuts](https://www.w3.org/TR/WCAG22/#character-key-shortcuts) requires one of three ways out for such a shortcut: a way to turn it off, a way to remap it to include a key that types nothing, or a shortcut that acts only while its own component has focus. The criterion treats the three as equal, and so does this rule. The Working Group shows how to meet it in [G217](https://www.w3.org/WAI/WCAG22/Techniques/general/G217) and what fails in [F99](https://www.w3.org/WAI/WCAG22/Techniques/failures/F99). This rule is the floor the law sets. KBD-003b goes further, as a rule the judges decide: it asks that shortcuts include a modifier key from the start, so that this rule's way out is seldom needed. Where both apply, this rule comes first. A single-key set the person turned on must be possible to turn off again, and a shortcut that adds only Shift, such as Shift+D, still needs one of the three ways out here, even though it meets KBD-003b's default.

### Do

- In a team's ticket desk, `/` moves focus to *Search tickets*, `e` closes the selected ticket and `?` opens the list of shortcuts. *Settings* has a switch *Single-key shortcuts* that turns all three off. With it off, the page ignores those keys. This is the first way out. The switch starts off, as KBD-003b asks; this rule only needs it to exist.
- Offer the second way instead, or as well: in *Settings > Keyboard shortcuts*, each shortcut can be changed to one with Ctrl, Alt or Cmd, such as Alt+E for *Close ticket*.
- Or use the third way: handle `j` and `k` on the ticket list's own `onKeyDown`, so they move the selection only while the list or a row in it has focus. A listener on `document` or `window` is not focus-bound, even when the shortcut is meant for one panel.
- Do not count Shift as a modifier; in these texts a modifier is Ctrl, Alt or Cmd. `?` is often Shift plus `/`, and Shift+D still types a character, so both need a way out. A sequence such as `g` then `t` for *Go to tickets* is made of character keys too.
- Make the switch and the remap screen work by keyboard, like any other control (KBD-001), and keep the choice once made, for example per account. How long the choice lasts is our own advice; the criterion does not say.
- Keep ignoring keys typed in `input`, `textarea` and `[contenteditable]`, so shortcuts never eat text. It is needed, but it is not one of the three ways out.
- Shortcuts with Ctrl, Alt or Cmd are outside this rule. A command menu that opens on Cmd+K or Ctrl+K and the shadcn sidebar toggle on Cmd+B or Ctrl+B are fine as they are.
- Keep every shortcut an extra beside a visible control, as KBD-001 says. *Close ticket* is still a button.

### Don't

- Bind `useHotkeys("e", closeTicket)` in the layout and offer no setting, so a speech user's word "edit" closes the ticket on screen.
- Add a `keydown` listener on `document` that focuses search on `/`, and count the guard for text fields as the fix.
- Use Shift+D for *Delete draft* on the whole page with no way out, as if Shift made it safe.
- Hide the switch so well that only people who read the help page find it. The criterion only asks that it exists; KBD-003a is where people find shortcuts and the place to link it from.

### Exceptions

- **Focus-bound keys.** Keys that act only while their own control has focus meet the rule as they are: typeahead in a `Select` or listbox, letter keys in an open `DropdownMenu`, `j` and `k` on a list's own `onKeyDown`, a `useHotkeys` whose ref is attached to the list, `tinykeys` bound to an element rather than `window` or `document`, single-key tools on a focused drawing canvas, and `/` that opens a block menu inside a focused editor.
- **Keys outside the criterion.** Escape, the arrow keys, Home, End, Page Up, Page Down, Tab, Enter, Space, Delete, Backspace and the function keys are not letters, digits, punctuation or symbols, and the Working Group's failure test leaves them out. Closing a panel with Escape is outside this rule.
- **Text input.** Characters typed into a focused field or editor are input, not shortcuts.
- **Keys that are not the page's.** The browser's and the screen reader's own keys are outside this rule.
- **Neighbouring rules.** The visible control beside every shortcut is KBD-001, telling people a shortcut exists is KBD-003a, and the judges' default of a modifier key is KBD-003b.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `useHotkeys`, `tinykeys` or `Mousetrap.bind` bound to the whole page, not to an element through the hook's ref or a target element, with a key such as `"/"`, `"e"`, `"?"` or `"shift+d"` and no `ctrl`, `alt`, `meta`, `mod` or `$mod`, while nothing lets the person turn it off or change it.
- A `keydown` listener on `document` or `window` that compares `e.key` with a character and does not require `e.ctrlKey`, `e.altKey` or `e.metaKey`, with no such setting. Requiring `e.shiftKey` alone does not take a shortcut out of this rule.
- A guard that only skips events from `input`, `textarea` or `[contenteditable]`, used as the only way out. Leave alone keys handled on a component's own `onKeyDown` (see Exceptions).

<a id="kbd-003a"></a>

## KBD-003a Show every shortcut the product adds, beside its command or in one list

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/kbd-003a/

### Rule

Every keyboard shortcut the product adds can be found inside the product: shown beside the command it triggers, such as in a menu item or tooltip, or listed with the others in one place, such as a shortcuts dialog or help page.

### Why

A shortcut nobody knows about helps nobody. The interface has little room to teach keys, so people learn them where the command lives or in one list they can return to. That matters most to the people who lean on the keyboard all day, and to anyone who needs to know which keys the page has taken before turning some of them off. No Level A or AA criterion asks that shortcuts be made known. [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) is met by the visible control that KBD-001 asks for, and [2.1.4 Character Key Shortcuts](https://www.w3.org/TR/WCAG22/#character-key-shortcuts) only needs a way out to exist. Both are better served when people can see the shortcuts, but neither requires it, so this rule rests on the judges.

### Do

- In a photo library, the menu item *Add to album* shows Alt+A at its end in a `DropdownMenuShortcut`, and the command menu shows the same keys beside *Add to album*. That span sits inside the item, so its text joins the item's name; give it `aria-hidden` and put the keys in `aria-keyshortcuts` on the item. Match Alt shortcuts on `e.code`, as KBD-003b says, so they work with Option on a Mac.
- Give an icon button a tooltip with its name and keys, such as "Rotate left (Alt+L)", and show it on keyboard focus as well as on hover. The name itself is set on the button, as ACT-001b asks; the tooltip only shows it with the keys.
- Or gather them: a dialog *Keyboard shortcuts*, opened from *Help* in the user menu, lists every shortcut grouped by area, such as *Library*, *Album* and *Editor*. Once single-key shortcuts are turned on (KBD-003b), `?` may open it too, but the menu item must, or only people who already know the key find the list. `?` is a character key, so KBD-003 applies to it.
- Shortcuts that act only inside one component, such as `j` and `k` in the photo grid, count too. Give the grid a short hint or list them under their own heading in the dialog.
- Put the switch that turns single-key shortcuts off, which KBD-003 asks for, in or next to the list, so people find both in one place.
- Keep the keys out of the control's name. Show them in a separate element, for example inside `aria-hidden` text next to the label, and give them to screen readers with `aria-keyshortcuts`. This is our own advice.
- Show Cmd on a Mac and Ctrl on Windows and Linux, read from `navigator.userAgentData?.platform` or `navigator.platform`. This is our own advice.
- Our own advice: show only keys that work. `CommandShortcut`, `DropdownMenuShortcut`, `ContextMenuShortcut` and `Kbd` in shadcn only draw text; bind the keys they show.

### Don't

- Bind Alt+A with `useHotkeys` and show it nowhere, so people only learn of it by accident.
- Open the list of shortcuts only by `?`, with no link to it anywhere on screen.
- Put the keys only in a `title` attribute, which shows on mouse hover and never on keyboard focus, or only in `aria-keyshortcuts`, which reaches screen readers and nobody else.
- Name a button "Search Ctrl K", so a voice control user must say the keys to press it.
- Show ⌘S beside *Save* to everyone, so people on Windows press a key their keyboard does not have.

### Exceptions

- **Keys that are not the product's.** The browser's, the operating system's and the screen reader's own keys need no listing.
- **The standard keys of a control.** Arrow keys in a menu, Escape in a dialog, Enter in a form and typeahead in a listbox come with the control and are not shortcuts the product adds.
- **Neighbouring rules.** A shortcut is always an extra beside a visible control (KBD-001). Listing a single-key shortcut does not make it acceptable; it still needs a way out (KBD-003). Which keys to choose is KBD-003b.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A shortcut bound with `useHotkeys`, `tinykeys` or a `keydown` listener whose keys appear in no `Kbd`, `CommandShortcut`, `DropdownMenuShortcut`, `ContextMenuShortcut` or tooltip, and in no shortcuts list. The list may live in a help page, so look before calling it a break.
- A shortcuts list that opens only by its own key, such as `?`, with no menu item, button or link that opens it.
- Keys given only in `aria-keyshortcuts` or a `title` attribute, with nothing on screen that shows them.

<a id="kbd-003b"></a>

## KBD-003b Build a shortcut on a modifier key by default

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/kbd-003b/

### Rule

A keyboard shortcut the product adds includes a modifier key (Ctrl, Alt or Cmd) or Shift by default. A single key, such as `n` or `/`, works as a shortcut only after the person turns such shortcuts on, or only while its own control has focus.

### Why

A key that types a character also arrives when someone types in the wrong place, brushes the keyboard or speaks to some speech input programs, which turn words into key presses. A shortcut that needs Ctrl, Alt or Cmd cannot fire that way, so it is safe from the start, without asking anyone to find a setting first. [WCAG 2.2, 2.1.4 Character Key Shortcuts](https://www.w3.org/TR/WCAG22/#character-key-shortcuts) asks less: it allows a single-key shortcut on from the start, if it can be turned off, changed or is bound to focus. That floor is KBD-003, a Requirement. This rule raises it, on the judges' verdict, not the law's. The two never pull apart: a product that follows this rule follows KBD-003 too, provided the single-key shortcuts a person turned on can be turned off again, as KBD-003 asks. A product that meets only KBD-003, with single keys on by default and a switch to turn them off, meets the law but not this rule. Shift is not a modifier in these texts. Shift alone meets this rule's default, but Shift+N still types a character, so KBD-003 asks for a way out: a switch, a remap or focus binding. Where both apply, KBD-003 comes first.

### Do

- In an invoicing app, Cmd+K or Ctrl+K opens the command menu, bound with `useHotkeys("mod+k", …)` or `(e.metaKey || e.ctrlKey) && e.key === "k"`. The button *Search* in the header opens it too (KBD-001).
- Give *New invoice* Alt+Shift+N beside its button. Match Alt and Option shortcuts on `e.code` (`KeyN`), because Option plus a letter types a special character on a Mac and `e.key` is no longer `n`.
- Offer single keys as a choice: *Settings > Keyboard shortcuts* has a switch *Use single-key shortcuts*, off at first. Once turned on, `n` starts a new invoice and `/` focuses search. The same switch turns them off again, which is what KBD-003 needs.
- Bind both platforms. Libraries' `mod` and `$mod` mean Cmd on a Mac and Ctrl elsewhere; `e.metaKey` alone does nothing on Windows.
- Our own advice: leave the browser's own combinations alone, such as Ctrl or Cmd with F, L, T, W or P, and Ctrl+Tab. A page that saves its own documents may use Ctrl or Cmd+S for *Save*, since that keeps its usual meaning.
- Our own choice: prefer Ctrl, Alt or Cmd to Shift alone, so the shortcut needs none of KBD-003's ways out.
- Give a Shift-only shortcut, such as Shift+N, one of KBD-003's ways out.
- Show the keys you chose, as KBD-003a asks.

### Don't

- Ship `useHotkeys("n", newInvoice)` on from the start, even with a switch to turn it off. It meets KBD-003 but not this rule.
- Bind only `e.metaKey`, so the shortcut does nothing for people on Windows.
- Call `preventDefault()` on Ctrl+F, so people lose find in page.

### Exceptions

- **Keys bound to focus.** Typeahead in a `Select` or listbox, letter keys in an open `DropdownMenu`, `j` and `k` on a list's own `onKeyDown` or on a `useHotkeys` whose ref is attached to the list, `tinykeys` bound to an element rather than `window` or `document`, and single-key tools on a drawing canvas that has focus are not page-wide shortcuts. They are outside this rule, as they are outside KBD-003's demand for a way out.
- **The standard keys of a control.** Escape in a dialog or an open overlay, the arrow keys in a menu and Enter in a form come with the control and are not shortcuts the product adds.
- **Neighbouring rules.** The legal floor for character keys is KBD-003, the visible control beside every shortcut is KBD-001, and making shortcuts findable is KBD-003a.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `useHotkeys` or `tinykeys` bound to the whole page, not to an element through the hook's ref or a target element, with a single letter, digit, punctuation mark or symbol and no modifier or Shift, such as `"n"` or `"/"`, active before the person has turned single-key shortcuts on.
- A `keydown` listener on `document` or `window` that acts on a single character (`e.key.length === 1`) without requiring `e.ctrlKey`, `e.altKey`, `e.metaKey` or `e.shiftKey`, active before the person has turned anything on. Escape that closes an overlay does not match (see Exceptions).
- A setting for single-key shortcuts whose starting value is on.

<a id="lay-001"></a>

## LAY-001 Let the page fit a 320-pixel viewport without scrolling sideways

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/lay-001/

### Rule

When the viewport is 320 CSS pixels wide, every piece of content and every function is still there. Nothing needs scrolling in two directions to be read or used, except a part that needs two dimensions to be understood or used, such as a data table or a map.

### Why

Many people make the page bigger to read it. At 400 percent zoom a normal laptop window is only 320 CSS pixels wide, about as narrow as a small phone. If the layout keeps its wide shape, every line runs off the edge, and the reader has to scroll right and back again for each one. That is slow and tiring, and it is easy to lose your place. If the layout drops a menu or a button to make room, the person who zoomed in can no longer do what everyone else can. A narrow window should show less at once, never offer less. [WCAG 2.2, 1.4.10 Reflow](https://www.w3.org/TR/WCAG22/#reflow) requires this. [1.4.4 Resize Text](https://www.w3.org/TR/WCAG22/#resize-text) supports it; text enlarged to 200 percent is LAY-003a, and wider text spacing is LAY-003b.

### Do

- Test at 320 CSS pixels: set the browser window to 1280 pixels and zoom to 400 percent, or set the viewport width to 320 in developer tools. Then check that nothing outside an exempt part needs sideways scrolling to be read or used.
- Check the widths between full size and 320 too, such as 1024, 768 and 480. A layout that works at both ends can still break at a width in between, for example when two columns are squeezed before they stack.
- Give each exempt part its own scroll area, so the page itself scrolls only up and down. This is the clearest way to meet the rule.
- Let a row of three product cards, *Wool cardigan*, *Beanie* and *Mittens*, become two columns and then one as the window narrows.
- Turn a two-column form with "First name" and "Last name" side by side into one column, with each label still above its field.
- Collapse the main navigation into a *Menu* button. Every link that was in the bar is still in the menu.
- Let long words and strings wrap, such as the file name "workplace-safety-planning-guidelines-2026-final.pdf", a tracking number like "GB123456789012345678" or the address "customer.service@example.com". Use `overflow-wrap: anywhere` or `word-break` where needed.
- Put a wide table of monthly costs per department in its own scroll area with a visible focus and an accessible name. The row of filter chips above it, "2025", "2026" and "Leeds only", and the link "Download costs as CSV" below it still fit the page. The table's title can name that area, as TBL-004 describes, and the table keeps its headers inside it (TBL-001).
- Size a map or chart to its container width. People may pan or scroll inside it, while the page around it stays put.
- Move a recipe photo from beside the text to above it on narrow screens, so *Cinnamon buns* and the list of ingredients get the full width.
- Make a sticky header or a cookie banner static, smaller or closable at narrow widths, so it does not cover most of the screen or hide the element that has focus.
- Open a side panel such as *Filters* over the content or in place of it at narrow widths, rather than pushing the content past the window edge.
- If you use a row that scrolls sideways, such as *Recently viewed*, make each card narrow enough to be read and used whole at 320 pixels.
- Use Justified's layout tokens as a starting point. `--layout-margin` shrinks the page margin to 1rem on small screens, and `max-w-page` sets only a maximum width, so the content can always get narrower. They help, but they do not do the job on their own: any child with a fixed width can still push the page sideways.

### Don't

- Give the page or its main wrapper a minimum width, such as `min-width: 1024px`, that forces sideways scrolling on narrow screens.
- Hide the *Save draft* button or the language switch at small widths with no other way to reach them.
- Cut "Your order confirmation and receipt" or a long product name off with an ellipsis and give no way to read the full text.
- Let one wide table or image push the paragraphs around it wider than the window, so that they have to be scrolled sideways too.
- Treat the table exception as covering the whole page, and leave the filter chips and the download link at their desktop width.
- Keep a fixed header, a fixed footer and a chat button on screen at 400 percent zoom, so only a thin band of content is left between them.
- Lock the page to portrait or landscape when the task does not need one of them. A layout that follows the available width works in both.

### Exceptions

- **Content that needs two dimensions.** Data tables, maps, diagrams, charts and video may need scrolling in both directions. So may a work area, such as the canvas in an image editor, whose toolbar must stay in view while people use it. The toolbar itself is not exempt and still fits the viewport. The exception covers only these parts. A page that scrolls sideways only because of such a part can still pass, as long as nothing else on it needs sideways scrolling.
- **Truncation with a way to the whole.** When text cannot wrap, an ellipsis is acceptable on the terms LAY-003a sets.
- **Text that runs sideways.** For content written to scroll sideways, such as some vertical scripts, the same test applies at a viewport 256 CSS pixels high, with scrolling sideways only. This rarely matters for left-to-right languages such as English.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Set the viewport to 320 CSS pixels wide, or 1280 at 400 percent zoom, and widths between such as 768, and see whether the page scrolls sideways outside a table, map, chart or work area.
- Widths that cannot shrink on the page or its wrappers, such as `min-w-[1024px]`, `w-[600px]` or `min-width: 1024px`, outside a part with its own scroll area.
- Content or functions hidden at small widths with no other route, such as `hidden md:flex` on navigation or a *Save draft* button that appears in no menu.
- `truncate` or `line-clamp-*` on text with no way to read all of it, or long file names, codes and addresses with no `break-words`, `break-all` or `overflow-wrap: anywhere`.
- A wide table or image without its own `overflow-x-auto` container, so it pushes the text around it past the window edge.

<a id="lay-002"></a>

## LAY-002 Keep the order in the code telling the same story as the order on screen

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/lay-002/

### Rule

Where the order of content carries meaning or affects how it is used, the order in the code, which screen readers read and the keyboard follows, tells the same story as the order on screen, and layout tools such as grid placement or the order property never rearrange that content so the two disagree.

### Why

A sighted person reads the page in the order it is drawn. A screen reader user hears it, and a keyboard user moves through it, in the order it is written in the code. When a layout tool moves things on screen but leaves the code as it was, these people get a different page: step 3 before step 2, a price before the product it belongs to, a button before the text that explains it. The meaning breaks, or the page becomes hard to use. [WCAG 2.2, 1.3.2 Meaningful Sequence](https://www.w3.org/TR/WCAG22/#meaningful-sequence) and [2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order) require an order that keeps meaning and use intact wherever order matters. They do not ask that the two orders be identical, and neither does this rule.

### Do

- Write the code in the order people should meet the content, and let the layout follow it. This is the simplest way to meet the rule.
- On a product page, keep *Wool cardigan*, the price "$89", the size picker and *Add to bag* in that order in the code as well as on screen.
- In a form with numbered steps, such as "1. Your details", "2. Delivery" and "3. Payment", keep the steps and the fields inside each step in the same order in the code as on screen.
- When a layout changes at a breakpoint, let content move and change size, but keep the sequence of anything whose order matters. A row with *Cancel* and *Save* that stacks on a small screen keeps the two buttons in the same order.
- Keep a label, an instruction or a heading in the same position relative to its field, control or section in the code as on screen. If the label of a checkbox is shown after the box, it comes after the box in the code too.
- When a menu, popover or panel opens from a button, let the keyboard reach its content next. Either place it right after the button in the code, or move focus into it when it opens and back to the button when it closes. A modal dialog always takes the second way, as DLG-006 says.
- Treat order between independent regions as free. A news article and a box with today's weather shown beside it may come in either order in the code. Inside each region, the order still follows this rule.

### Don't

- Use `order` or grid placement to show the steps "1. Your details", "2. Delivery" and "3. Payment" in the right order on screen while the code has them as 1, 3, 2, so a screen reader reads *Payment* before *Delivery* and Tab goes there first.
- Reverse a flex row so *Add to bag* appears after the price on screen but comes before the product name in the code.
- Use absolute positioning to lift a warning such as "Just 2 left" to the top of a card while it is read last.
- Add a positive `tabindex` to patch an order that the layout broke. Fix the order in the code instead.
- Put the panel that opens from *Filters* at the end of the page in the code and leave focus on the button, so a keyboard user must pass the rest of the page to reach the filters.

### Exceptions

- **Order without meaning.** Content whose order carries no meaning, such as a gallery of photos without ranking, is outside the rule. A ranking, a date order or a chosen sort makes the order meaningful again.
- **Decorative moves.** Showing an image above a heading that comes before it in the code is fine when it does not change what the content means. Use judgement, and when in doubt, show the content in the same order as it has in the code.
- **Right-to-left languages.** Mirroring a layout for Arabic or Hebrew keeps the logical order the same. It is not a rearrangement.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Classes that reorder content, such as `order-*`, `flex-row-reverse`, `flex-col-reverse`, `col-start-*` or `row-start-*`, and ask whether the moved content has an order that matters. Leave alone right-to-left mirroring, unranked galleries and decorative moves.
- Absolute positioning, such as `absolute top-0`, that lifts a badge, warning or price above content that comes before it in the code.
- A positive `tabIndex`, such as `tabIndex={1}`, used to patch a focus order.
- A panel or popover opened from a button but placed at the end of the page in the code, with focus left on the button. A portal is fine when focus moves in on open and back on close.
- Tab through forms, steps and stacked button rows at narrow and wide widths, and see whether focus follows the order shown on screen.

<a id="lay-003a"></a>

## LAY-003a Let text grow to 200 percent without losing content or function

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/lay-003a/

### Rule

Text, also in controls and labels, can be enlarged to 200 percent without losing content or function: nothing is cut off, laid over other content or stops working. Do not switch off zoom or cap it below 200 percent in the viewport setting, and size no text in viewport units alone.

### Why

Many people with low vision read the web at a larger size, and on the web the usual way to get there is the browser's own zoom, on a phone by pinching. The page rarely has to do anything special for this. It has to stay out of the way: let the browser zoom, let text sizes follow the zoom, and let every box that holds text grow with it. [WCAG 2.2, 1.4.4 Resize Text](https://www.w3.org/TR/WCAG22/#resize-text) requires that text can be resized to 200 percent without assistive technology and without loss of content or function. The page meets it when at least one way of enlarging works, and each step between 100 and 200 percent must work too. The Working Group documents the breaks this rule names: zoom switched off in the viewport setting, text sized in viewport units, and text that is clipped or overlaps once it grows. The W3C test fails a viewport setting that blocks or caps zoom whatever the browser, even though desktop browsers and most current phone browsers ignore it or let people override it. Treat it as a break, never as an old-phone detail. Browser zoom enlarges fixed heights too, but the zoomed layout is narrower, so wrapping text takes more lines and a box of fixed height clips it or lets it spill. The boxes that break are those holding text that can wrap, not one-line controls. Above 200 percent, the page must still reflow at 320 CSS pixels, which is LAY-001. What happens when people widen the spacing of text, rather than its size, is LAY-003b.

### Do

- In a Next.js app, write the viewport export as `export const viewport = { width: "device-width", initialScale: 1 }` and leave `maximumScale` and `userScalable` out. A `maximumScale` of 5 is fine too.
- Stop iOS Safari from zooming in when a field gets focus by giving the field text of at least 16 px, never by blocking zoom. Justified's `Input` already uses `text-base` for this.
- Size text in `rem` or with Tailwind's text classes. A fluid heading such as `text-[clamp(1.75rem,1.25rem+2vw,3rem)]` can work, because its rem part grows with zoom. Check it at 200 percent rather than assuming it does.
- In a community garden's booking app, the cards *Plot 14*, *Plot 15* and *Herb bed* let their description set their height: `min-h-24` instead of `h-24`, padding instead of a fixed height, and grid rows that size to their content. At 200 percent the cards get taller and every line is still there.
- Give a sticky header vertical padding, such as `py-3`, instead of `h-14`, so the page title *Book a plot for the spring season* can wrap onto a second line without running under the content.
- Let a hero banner with text over a photo grow with its text: `min-h-[420px]` with padding, not `h-[420px]`.
- Keep toasts, popovers and tooltips free of a fixed height, so an enlarged message wraps instead of being cut.
- Test with the browser's own zoom in a window about 1280 pixels wide, at 200 percent and at the steps between, such as 125, 150 and 175. Open the menus, dialogs, popovers and toasts as well, since a closed menu hides its own breaks.
- `overflow-hidden` is fine where nothing but an image or a scroll area is clipped, such as a rounded photo crop, an avatar, a carousel track or a list in `ScrollArea`.
- Sizes in px are not a break on their own: browser zoom enlarges them. We still prefer `rem`, so the browser's text-size setting works as well. That is our own choice.

### Don't

- Write `maximumScale: 1, userScalable: false` in the viewport export, or `user-scalable=no` in a hand-written meta tag in `app/layout.tsx` or `index.html`, to stop the zoom on focus. `maximum-scale=1` on its own blocks zoom too.
- Size the garden's welcome heading as `text-[5vw]`. Zooming does not change it, so it never reaches twice its size.
- Put `h-32 overflow-hidden` on the card text "South-facing, raised bed, water tap within ten metres. Tools are kept in the shed by the gate." At 200 percent the last lines vanish with no way to read them.
- Give the hero banner `h-[420px]` with its heading and *Book a plot* button inside it, so that at 200 percent the button spills out over the section below.
- Give a toast body a fixed height, so the end of "Your booking for Plot 14 is confirmed for 12 April" is cut off.

### Exceptions

- **Captions and images of text.** Captions and text that is part of an image are outside this rule. When text may be an image at all is a separate criterion, not covered here.
- **Text the browser draws.** Only what the browser or the system draws is exempt, such as the browser's built-in validation bubble or an `alert()` or `confirm()` dialog. The page's own controls still have to grow, including the button of an `<input type="file">` and any tooltip the page builds.
- **Truncation with a way to the whole.** Let text wrap or its box grow first. Where that cannot be done, an ellipsis is acceptable when it is clear that more can be seen and the full text is one step away, such as a plot name in a card that is visibly a link to the plot's page. A tooltip may be that way only when the visible part still tells the item apart from the others and is enough to use it, and it opens on focus too; what the person needs stays on the page (TXT-002b). Where the ellipsis leads nowhere, the text is lost. LAY-001 covers the same case at 320 pixels.
- **No exception for small labels.** Tabs, app bars and navigation labels grow with the rest of the page. Browser zoom enlarges them, and the criterion makes no exception for them.
- **Neighbouring rules.** Reflow at 400 percent is LAY-001, text spacing is LAY-003b, contrast is VIS-001, and target size is ACT-006.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A viewport meta tag or a Next.js `viewport` export with `user-scalable=no`, `user-scalable=0`, `userScalable: false`, or `maximum-scale` / `maximumScale` below 2.
- Text sized only in viewport or container units, such as `text-[4vw]`, `text-[3vh]`, `vmin`, `vmax`, `dvw`, `svh`, `lvh`, `cqw` or `cqi`. A `clamp()` that mixes `rem` with `vw` is not a hit by itself: zoom to 200 percent and see whether the text has doubled.
- Zoom a window about 1280 pixels wide to 200 percent, and to the steps between, and look over every view, open menus, dialogs, popovers and toasts included, for text that is cut off, overlaps other content or no longer works.
- A fixed `h-*` or `max-h-*` on a box of text that can wrap onto more lines, with or without `overflow-hidden`, so grown text is cut or spills. Leave alone one-line controls such as `Button` or `Input`, image crops, avatars, carousels and scroll areas.

<a id="lay-003b"></a>

## LAY-003b Keep all text and functions intact when people widen the text spacing

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/lay-003b/

### Rule

When a person sets line height to 1.5 times the font size, space after paragraphs to 2 times, letter spacing to 0.12 times and word spacing to 0.16 times, no text is cut off, hidden or laid over other content, and every function still works. The page need not use these values itself.

### Why

Some people with low vision or dyslexia read much better when lines, words and letters sit further apart, and they set this with a browser extension, a bookmarklet or a style sheet of their own. A layout that was measured to the pixel for the default spacing then cuts off the last line of a card or turns a tab label into half a word. [WCAG 2.2, 1.4.12 Text Spacing](https://www.w3.org/TR/WCAG22/#text-spacing) requires that nothing is lost when those four values are applied and no other style is changed. The values are the floor of the test; people may choose more. The criterion does not ask the page to use them by default or to offer a control for them; it asks the page to survive them. The Working Group documents the usual break, text in a box that cannot grow, clipped or spilling over its neighbour, as a failure ([F104](https://www.w3.org/WAI/WCAG22/Techniques/failures/F104)). The same boxes often break when text grows in size, which is LAY-003a.

### Do

- In a volunteer rota app, the badge "Needs 2 more volunteers" on a shift card has `px-2 py-0.5` and no height of its own, so a taller line or wider word spacing makes the badge bigger rather than cutting it. A row of such badges uses `flex flex-wrap gap-2`, so a badge that no longer fits moves to the next line.
- Let a shift's description set the card's height: `min-h-*` instead of `h-*`, vertical padding instead of a fixed height, and grid rows that size to their content.
- Clamp a long description with `line-clamp-3` only where the full text is one step away: the card's title *Saturday morning, food bank* is a link to the shift page, which shows the description in full.
- Let sidebar items, tabs, segmented controls and nav pills grow with their label. These often have a fixed height together with `overflow-hidden` or `truncate` on the label. Test the ones you use rather than assuming they pass.
- Let a sidebar item such as *Community kitchen volunteers* wrap onto a second line rather than truncate it. If it must stay on one line, make the full name one step away, such as on the page the item opens. A tooltip that also opens on focus is enough only when the visible part, such as *Community kitchen…*, still tells the item apart from the others (TXT-002b).
- A button with a fixed height and a one-line label, such as Justified's `Button` with `h-10`, usually still fits the taller line. Check any button whose label could wrap under the wider spacing, for example in a narrow column.
- Test with all four values at once and nothing else changed: `line-height: 1.5`, `letter-spacing: 0.12em` and `word-spacing: 0.16em` on every element, and `margin-bottom: 2em` on paragraphs. Open menus, dialogs and toasts during the test.

### Don't

- Give the chip "Morning shift, front desk" `h-6 overflow-hidden`, so the wider spacing pushes half of it out of sight.
- Clamp a description by hand with `max-h-[3rem] overflow-hidden` on a card that links nowhere, so the person never learns that the shift needs closed-toe shoes.
- Give a card a fixed height without `overflow-hidden`, so its text runs over the *Sign up for shift* button below it.
- Give the tabs *Open shifts*, *My shifts* and *Swap requests* `w-28 truncate`, so they read "Swap reque…" under the wider spacing, with no way to read the rest.
- Add `!leading-tight` or `!tracking-tight` to body text. The criterion does not forbid `!important` as such, but it can stop a person's own spacing from taking effect, so we advise against it on these properties. That is our own advice.

### Exceptions

- **A script that lacks a property.** Text in a writing system that does not use one of the four properties, such as paragraph spacing in some scripts, is tested only on the properties it uses.
- **Truncation with a way to the whole.** Let text wrap or its box grow first. Where that cannot be done, an ellipsis is acceptable when it is clear that more can be seen and the full text is one step away, such as a card that is visibly a link to a page with the text in full. A tooltip may be that way only when the visible part still tells the item apart from the others and is enough to use it, and it opens on focus too; what the person needs stays on the page (TXT-002b).
- **The person's tool fails.** If an extension or bookmarklet cannot apply the values, the page is not at fault, unless the page itself stops them.
- **Images of text and captions in the picture.** Text in an image, text drawn on a `canvas` and captions burned into a video's picture are outside this rule.
- **Neighbouring rules.** Text that grows in size is LAY-003a, and reflow at 320 pixels is LAY-001, which covers `truncate` and `line-clamp-*` at that width.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Apply line height 1.5, letter spacing 0.12em and word spacing 0.16em to every element, and 2em after paragraphs, with a bookmarklet or user style. Look over every view, open menus, dialogs, toasts, tabs and table cells included, for text that is cut off, hidden or overlapping.
- An element holding text with a fixed `h-*` or `max-h-*` and `overflow-hidden`, or with a fixed height and nothing else, where one more line would be cut or spill over the next element.
- A label with `truncate` or `whitespace-nowrap` inside a fixed width or height, such as a sidebar item, tab or pill, that is cut off under the wider spacing and has no way to the full text (see Exceptions).

<a id="nav-002a"></a>

## NAV-002a When a menu shows the current page, say so in the code on that item

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/nav-002a/

### Rule

When a navigation menu shows which item is the page the person is on, the code or the text says so too, so a screen reader announces that item as the current page. The usual way is `aria-current="page"` on its link.

### Why

A highlighted menu item tells a sighted person where they are. A screen reader user who hears only "Invoices, link" gets none of that, and has to work out their place from the page itself. [WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) requires that what the presentation shows can also be found in code or in text. The criterion does not name any attribute. The Working Group lists `aria-current` as a sufficient way to expose the current item in a set of links ([ARIA26](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA26)); its techniques are how the Working Group reads the criterion, not the criterion's own words. Sufficient is not the only way. Text that says so, read out with the link, also meets the criterion, so the rule names `aria-current` as the usual means and accepts others that a screen reader announces just as clearly. The same technique is also listed under 2.4.8 Location, which is Level AAA and outside this rule. [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) points the same way but is written about states a person sets on a control, so this rule does not rest on it. Whether the menu should show a current item at all is NAV-002b.

### Do

- In the invoicing app *Tallowbrook*, the sidebar lists *Dashboard*, *Invoices*, *Clients* and *Reports*. On the invoice list, *Invoices* is highlighted, and its link has `aria-current="page"`. A screen reader reads it as "Invoices, current page, link".
- shadcn's `SidebarMenuButton` takes an `isActive` prop. In the current shadcn source (read on 25 November 2026) it sets only `data-active`, which the classes use for the highlight, and adds no `aria-current`. `SidebarMenuSubButton` does the same. Set it yourself: `<SidebarMenuButton asChild isActive={active}><Link href="/invoices" aria-current={active ? "page" : undefined}>Invoices</Link></SidebarMenuButton>`.
- Next.js `Link` does not set `aria-current` by itself, so pass it as above. React Router's `NavLink` sets `aria-current="page"` on its own when the route matches; keep it, and do not swap it for a plain `Link` with an active class. Radix `NavigationMenu.Link` sets it when you pass `active`, so pass `active` rather than only a class.
- Our own choice: put the mark on the element that is the link, the `a`, and on one item per menu.
- When the top bar and the sidebar each show a current item, each `nav` marks its own.
- Our own reading: on a single invoice, `/invoices/INV-0042`, the sidebar still highlights *Invoices* as the section the person is in, but that page is not in the menu. Mark *Invoices* with `aria-current="true"`, the current item in a set, rather than `"page"`.
- On a narrow screen the shadcn `Sidebar` moves into a sheet. Because the mark is on the link, it moves with it, as the links themselves must under LAY-001. A menu built from a second, hand-written list needs the same mark.
- shadcn's `BreadcrumbPage` already renders the last crumb with `aria-current="page"`. If you show the current page in a breadcrumb as a real link instead, give that link the mark.
- Another way that meets the criterion: visually hidden text such as "(current page)" inside the link. Use one way, not both, or the screen reader says it twice.
- Keep the current link focusable and in the tab order, as KBD-001 expects of links.

### Don't

- Set `isActive={pathname === item.url}` on `SidebarMenuButton` and stop there, so the highlight has no counterpart in code.
- Put `aria-current` on the `li` or on a wrapping `div` instead of the link.
- Use `aria-selected` on a menu link. It belongs to tabs, options and grid cells. It is not a supported state on a link, and most screen readers do not announce it there.
- Give every item `aria-current="true"`, or two items in the same menu `aria-current="page"`.
- Mark the current item only with a class such as `font-semibold` or `bg-accent`.

### Exceptions

- **A menu that shows no current item.** There is nothing to expose, so this rule asks nothing. Whether it should show one is NAV-002b.
- **Tabs.** shadcn `Tabs` switch a panel in place, and Radix already exposes the selected tab. This rule is for menus of links that go to pages.
- **Steps and result pages.** The same attribute takes the values `step` for the current step in a process and `page` for the current page of results in pagination. Those are outside this navigation rule.
- **Language pickers.** The current entry in a language picker is said in code the same way, for example with `aria-current`. The language of each entry is STR-006a.
- **Neighbouring rules.** The menu's `nav` and its name are STR-004. What the current item looks like is NAV-002b.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A shadcn `SidebarMenuButton` or `SidebarMenuSubButton` with `isActive` whose link has no `aria-current`, such as `<SidebarMenuButton asChild isActive={active}><Link href="/invoices">`, and no visually hidden text such as "(current page)" inside the link. React Router's `NavLink` as the child sets it itself.
- A navigation link whose current state is only a class, such as `cn(active && "bg-accent font-semibold")` on a Next.js `Link`, with no `aria-current` set from the same condition and no visually hidden "(current page)" text.
- A Radix `NavigationMenu.Link` styled as current through a class but given no `active` prop.
- `aria-current` on an `li`, `div` or other wrapper instead of the `a`, or `aria-selected` used on a menu link in its place.
- `aria-current` set on every item of a menu, or `"page"` able to match two items in the same menu. On a page that is not in the menu, `aria-current="true"` on its section's item is fine.

<a id="nav-002b"></a>

## NAV-002b Mark the current page in a repeated menu with a cue that is not colour alone

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/nav-002b/

### Rule

A navigation menu that repeats across pages marks the item for the page or section the person is in, and only that item. The mark does not rest on colour alone: use heavier text, a filled icon, a shape behind the item or a bar beside it.

### Why

A mark on one menu item tells the person where they are at a glance; a mark on two items, or one that looks like hover, answers it wrongly. A mark made of colour alone is lost on people who do not see that colour difference, and in forced-colours mode. No WCAG criterion at Level AA asks a menu to show the current item; 2.4.8 Location asks for it, but that is Level AAA. [WCAG 2.2, 1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) sets a lower floor than this rule: it accepts a colour change that also differs enough in lightness, and a swap of foreground and background. So a colour-only mark does not always fail WCAG. Asking for a cue that is not colour at all is the judges' level, not the law's. This rule sits on two Requirements and sets no contrast figure of its own. When the mark uses colour, VIS-003a sets the lightness difference the law asks as a minimum. When a bar, a border or a shape behind the item is how people see the mark, VIS-004 sets the contrast that indicator needs. Saying the same thing in code is NAV-002a.

### Do

- In the invoicing app *Tallowbrook*, the sidebar lists *Dashboard*, *Invoices*, *Clients* and *Reports*. On the invoice list, *Invoices* has semibold text, a filled icon and a bar on its leading edge. The other items have regular text and outlined icons.
- Know what shadcn gives you. In the current source (read on 25 November 2026), an active `SidebarMenuButton` gets `bg-sidebar-accent`, `text-sidebar-accent-foreground` and `font-medium`, and hover uses the same background and text colour. Only the weight tells the current item from the hovered one. An active `SidebarMenuSubButton` changes colour only. Add a cue of your own, such as `data-[active=true]:font-semibold` with a left border.
- Keep the current mark and the hover style different, so the person can tell the page they are on from the item under the pointer. VIS-008b asks this of every state that lasts.
- Take the mark from the route, not from a click handler, so it is right after a reload, a back press or a link from elsewhere.
- Match routes so that one item wins. `pathname.startsWith("/")` is true everywhere, so *Dashboard* at `/` matches only exactly.
- Our own reading: on a single invoice, `/invoices/INV-0042`, which is not in the menu, mark *Invoices*, the section the person is in.
- In a nested group, the child item gets the mark. The parent may show that it holds the current page, for example by staying expanded, but not with the same mark.
- Keep a cue that survives the collapsed sidebar (`collapsible="icon"`), where the label is gone: a filled icon, or a border or shape behind the icon that meets the contrast VIS-004 asks for against the bar behind it. A shape that falls short of that does not count as the cue.
- On a narrow screen the menu moves into a sheet (LAY-001). The current item keeps its mark there.
- Our own advice: forced-colours mode (Windows high contrast) drops background colours, so a mark made only of a background pill, or a bar drawn with a background, disappears. Weight, a border and an icon change survive.
- Make the mark look nothing like the focus ring, which KBD-001 owns. Both can show on the same item at once.

### Don't

- Mark *Invoices* with `text-foreground` while the rest are `text-muted-foreground`, and nothing else.
- Use the hover classes for the current item, so moving the pointer over *Clients* makes two items look current.
- Highlight *Dashboard* and *Reports* together on the reports page because of a prefix match.
- Set the active item in state on click, so nothing is marked after a reload.
- Leave only a faint tint behind the icon when the sidebar collapses to icons.

### Exceptions

- **No item matches.** On a page reached from the account menu, such as *Profile*, which the sidebar does not list, mark nothing rather than the nearest item.
- **Menus that are not about place.** An account menu or a menu of actions has no current page and needs no mark.
- **Tabs.** Tabs that switch a panel in place show a selected tab; this rule is for menus of links that go to pages.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- The classes for the current item, such as `data-[active=true]:` styles or an `active &&` branch. Do they change only colour, such as `text-foreground` against `text-muted-foreground`, or a faint tint? Look for heavier text, a filled icon, a shape behind the item that meets VIS-004, or a bar beside it.
- A shadcn `SidebarMenuSubButton` with `isActive` and only its default classes, which change colour only.
- Whether the current style matches the hover style, so the item under the pointer looks current too. In shadcn's `SidebarMenuButton`, only `font-medium` tells them apart.
- How the current item is chosen: from the route, such as `usePathname()` or `useLocation()`, not from state set on click; and so that only one item matches, with `/` matched exactly rather than by `pathname.startsWith`.
- Collapse the sidebar to icons with `collapsible="icon"` and see whether the current item still has a cue that is not colour alone, such as a filled icon or a border.

<a id="nav-003"></a>

## NAV-003 Keep repeated navigation in the same order on every page

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/nav-003/

### Rule

Navigation that repeats on several pages of a product, such as a top bar, a sidebar or a row of footer links, lists its items in the same relative order on every page, unless the person changed the order themselves.

### Why

People learn a menu once and then reach for an item by where it sits in the list. A screen reader user learns it as a sequence, and a person using magnification learns it by where it is, because they see only part of the screen at a time. When two items swap places from one page to the next, all of them have to start reading the menu again, and some will pick the wrong item. [WCAG 2.2, 3.2.3 Consistent Navigation](https://www.w3.org/TR/WCAG22/#consistent-navigation) requires that navigation repeated across a set of pages keeps the same relative order. "Relative" matters: an item may be added on some pages or left out on others, as long as the items that remain keep their order. The Working Group lists a menu whose links come in a different order on two pages as a failure ([F66](https://www.w3.org/WAI/WCAG22/Techniques/failures/F66)). In WCAG's terms, everything at one URL is one page ([Understanding 3.2.3](https://www.w3.org/WAI/WCAG22/Understanding/consistent-navigation.html)). In an app, routes with their own URL are separate pages and the criterion compares them. Views that switch without changing the URL count as one page, so keeping their order is our own advice there.

### Do

- In the invoicing app *Tallowbrook*, the sidebar reads *Dashboard*, *Invoices*, *Clients*, *Reports*, *Settings* on every view. Build it from one shared list, such as `navItems`, rendered by one `AppSidebar` in the root layout, so no page can build its own.
- Filter that one list for items the person may not use; never sort it differently per page. A bookkeeper without access to *Reports* sees *Dashboard*, *Invoices*, *Clients*, *Settings*, which keeps the order.
- An expanded group under *Invoices*, such as *Drafts* and *Overdue*, may appear on some pages. Items inserted that way do not break the order.
- Render the mobile sheet from the same list as the desktop sidebar, so the order holds at every width. Every link must also survive the collapse, as LAY-001 says.
- When the person drags *Clients* to the top of their sidebar, keep their order on every page until they change it again.
- Our own advice: keep a list of recently opened clients in its own labelled group below the main items, rather than sorting the main items by recent use. The main list stays fixed.
- Our own advice: keep the same set of items on every page. When *Reports* has nothing to show yet, keep the item and explain on its page why it is empty, rather than hiding it. The criterion would allow hiding it.
- Our own advice: keep the menu in the same place on screen too. The criterion is about order, not position.
- Buttons that keep their place from page to page are ACT-003b.

### Don't

- Let the dashboard list *Dashboard*, *Invoices*, *Clients* and the settings page list *Clients*, *Dashboard*, *Invoices*, because each page builds its own array.
- Move the current item to the top of the menu, or let a pinned item jump to the front on some pages only.
- Build the mobile sheet from a second, hand-written list that has drifted from the sidebar.

### Exceptions

- **A change the person made.** An order the person set themselves is allowed, and it then holds.
- **A flow without the menu.** A checkout or sign-up flow that drops the product's navigation is a separate set of pages. The rule does not ask it to show the menu.
- **Other language versions.** Each language version of the product is its own set.
- **Position on narrow screens.** Moving the menu from a sidebar into a sheet changes where it is, not its order. The order still holds; LAY-001 covers the rest.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Pages or layouts that each render their own array of navigation items instead of one shared list, such as `navItems` rendered by one `AppSidebar` in the root layout. Compare the orders they produce.
- A mobile `Sheet` menu built from a second, hand-written list rather than the list the desktop sidebar uses.
- A `sort`, `reverse` or other reordering of the navigation list by the current route, recent use or a pinned flag. Filtering items out, such as by permission, keeps the order, and so does an order the person set themselves.
- Open several routes and read the top bar, sidebar and footer links in order. Do the items shown on both keep the same relative order? A checkout or sign-up flow without the menu is left alone.

<a id="nav-004"></a>

## NAV-004 Start a page with a skip link when links come before its main content

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/nav-004/

### Rule

When a header or sidebar with links comes before a page's main content, make a skip link the first thing Tab reaches. It is visible while it has focus, and it moves focus to the start of the main content.

### Why

A keyboard user moves through a page one stop at a time, from the top. When the page opens with a header and a sidebar of twenty links, they pass all twenty on every page before they reach what they came for. [WCAG 2.2, 2.4.1 Bypass Blocks](https://www.w3.org/TR/WCAG22/#bypass-blocks) requires a way past blocks that repeat across pages, but it accepts several ways, and landmarks built as STR-004 asks are one of them ([Understanding 2.4.1](https://www.w3.org/WAI/WCAG22/Understanding/bypass-blocks.html)). A page with a correct `main` can meet the criterion without a skip link, so the skip link is our choice, not something WCAG requires. Once it is there, [2.4.7 Focus Visible](https://www.w3.org/TR/WCAG22/#focus-visible) applies to it like any other link: a skip link that stays hidden while it has focus fails that criterion.

### Our reasons

Fewer than two judges have spoken about a skip link, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So do GOV.UK and NN/g, expert witnesses who do not vote. We ask for it for three reasons.

- **Landmarks do not reach everyone.** A screen reader can jump to `main`. Most browsers give a sighted keyboard user without a screen reader no key for that, so for them the landmarks of STR-004 change nothing, and the long sidebar still costs them a press per link.
- **It is found without looking for it.** The first press on Tab shows it. Nobody has to know a shortcut or that the page has landmarks.
- **It costs almost nothing.** One link, hidden until it has focus, takes no space and is skipped with one more press by anyone who wants the menu.

### Do

- In the invoicing app *Tallowbrook*, the first Tab on any page shows *Skip to main content* in the top left corner, over the header, with the usual focus ring from KBD-001. Enter moves focus to the start of the invoice list, so the next Tab lands on the list's first control, not in the sidebar.
- Put the link first in the code, before the logo, the header and the sidebar, not only first on screen (LAY-002). If the page shows a cookie banner, the link comes right after it.
- In a shadcn layout, place it before the `Sidebar` inside `SidebarProvider`, with the adapter's `focusRing` classes so its ring is the one KBD-001 describes: `<a href="#main-heading" className={cn("sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:bg-background focus:px-4 focus:py-2", focusRing)}>Skip to main content</a>`.
- Give the target an `id` and make it able to take focus from script with `tabIndex={-1}`. Without it, some browsers scroll to the target but leave focus at the top, so the next Tab goes back into the menu.
- Our own advice: point the link at the view's `h1` inside `main`, such as `<h1 id="main-heading" tabIndex={-1}>Invoices</h1>`, rather than at `SidebarInset`, which renders `main`. The focus indicator then shows on the heading, small and exactly where focus went. Pointing at `main` itself also works, and then the ring goes round the whole content area.
- Keep the visible focus indicator on the target as well, as KBD-001 asks of anything with keyboard focus.
- Let the text say where it goes: *Skip to main content*.
- Keep it outside `nav` and outside the header, on its own. If an automated checker reports it as content outside a landmark, leave it where it is.
- When a sticky header would cover the target after the jump, add `scroll-mt` to the target, so it stays in view as KBD-002 asks.
- In an app that changes views without loading a page, focus can stay on the sidebar link that was pressed, behind the skip link. Where focus goes after a view change is outside this guideline; STR-001 covers the title that changes with it.

### Don't

- Build a `SidebarProvider` layout with no skip link, so the first twenty presses on Tab walk the sidebar on every page.
- Give the link `className="sr-only"` with no `focus:not-sr-only`, so it gets focus but is never seen.
- Hide it with `display: none` or `hidden`, so it never gets focus at all.
- Point it at `#main-heading` when no element has that `id`, or put the `id` on a wrapper outside `main`.
- Put `outline-none` on the skip target to hide its ring, so the person cannot see where focus went.
- Put it inside the sidebar's `nav`, after the logo or after the first menu links.

### Exceptions

- **No links before the content.** A sign-in page with only a form, a full-screen editor or a checkout flow without the product's menu needs no skip link.
- **Navigation after the content.** When the menu comes after the main content in the code, the first Tab already lands in the content.
- **Dialogs.** A dialog is not covered; focus inside it is DLG-006 and DLG-007.
- **A product that chooses otherwise.** This is a guideline. A page without a skip link still needs some way past its repeated blocks, which the landmarks of STR-004 can give.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Load a page where a header or sidebar with links comes before the main content in the code, press Tab once, and see whether the first stop is a visible skip link, such as "Skip to main content".
- Press Enter on the skip link, then Tab, and see whether focus is now in the main content, not back in the header or sidebar.
- A skip link with `sr-only` and no `focus:not-sr-only` or other style that shows it on focus, or one hidden with `hidden` or `display: none`.
- A skip link whose `href`, such as `#main-heading`, matches no `id`, or whose target is outside `main` or cannot take focus because it has no `tabIndex={-1}`.
- A skip link placed after the logo, inside the sidebar's `nav` or after the first menu links in the code. Right after a cookie banner is fine.

<a id="sta-001"></a>

## STA-001 Show a wait in the part that is loading, not over the whole page

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/sta-001/

### Rule

When content in one part of a view loads, show the wait in that part, at the control that started it or as a small indicator where the content will appear, never as a layer over the whole page, and keep the rest of the view usable.

### Why

Most waits concern one thing: a table after a filter, a panel fetching its data, one button doing its job. A layer over the whole page turns that small wait into a stop for everything. The person cannot read what is already there, cannot change the filter again and cannot tell which part is busy. A wait shown in place says what is loading and lets the person carry on elsewhere. WCAG does not require this placement. [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages) applies to the wait wherever it is placed: a visible wait that appears without focus moving is a status message and must be announced, as FBK-004 describes. It says nothing about placement. [WCAG 2.2, 2.2.2 Pause, Stop, Hide](https://www.w3.org/TR/WCAG22/#pause-stop-hide) sets a limit on it, described under Do.

### Do

- A person changes the date range on an orders table. The rows dim and a small indicator sits in the table area until the new rows arrive. The date picker, the search field and the side menu keep working.
- A person presses *Load more comments* at the end of a thread. An indicator appears in the space below the last comment, where the new ones will land, and the comments already shown stay readable.
- A weather panel on a travel page fetches its forecast while the rest of the page is already usable. A small indicator named "Loading forecast" sits in the panel until the data arrives.
- A person presses *Export CSV* in a toolbar. A small spinner shows inside or beside that button. What the button itself does while it works is covered by STA-005a, and a second press by the guideline STA-005b.
- Give the indicator a name that says what is loading, such as "Loading orders", not just "Loading".
- Avoid several indicators at once. Give each part its own indicator only when the person started each one separately. Parts or items that load together get one indicator for the group.
- If a layer covers only the busy part, make the content under it unreachable by keyboard too (inert), not only hidden from sight. If focus is inside that part, keep it on the control that started the wait, or move it to the indicator or the part's heading, so focus is never lost (KBD-001, KBD-002).
- Inside an open dialog, show the wait inside the dialog, in its button or its content area, as DLG-002 asks.
- Our own choice, not a source's or WCAG's: show nothing for a wait under about half a second, so nothing flashes. When the amount of work becomes known, switch to an indicator that shows how far it has come.
- A loader that starts on its own, runs next to content the person can use and lasts more than five seconds falls under 2.2.2. A loader that starts when the person scrolls a list into view counts as starting on its own. Give a way to stop or hide its motion, or stop the motion after five seconds and leave static text such as "Still loading orders", unless the motion is essential. Respect reduced motion as well, as VIS-006 asks. A spinner that starts because the person pressed something does not start on its own, so it is outside 2.2.2. Doing this helps you work toward 2.2.2; it does not settle it. Moving content that is not a loader is VIS-005.
- When the part fails to load, show the failure in that same part, as FBK-002 asks.

### Don't

- Cover the whole page with a dimmed layer and a large spinner while one chart refreshes.
- Freeze the filter panel while the results it controls update, so the person cannot correct a wrong choice.
- Fill one panel or table of a page already in use with placeholder blocks. A small indicator fits there; placeholders belong to the first load of a whole view.
- Remove the content already shown while more items load at the end of a list.
- Open a spinner layer on top of an open dialog.

### Exceptions

- **First load of a whole view.** When the whole page or screen is what is loading, a whole-view indicator is fine. Placeholders that show the real layout are often clearer than a lone spinner, but either is allowed.
- **The person's own action that leaves nothing usable.** When the person's own action leaves nothing in the view usable until it ends, such as saving or submitting the whole view, a whole-view indicator is fine. A filter, a list loading more rows or one panel fetching data never counts.
- In both cases the layer must not hide keyboard focus (KBD-002) or lower the contrast of the focus indicator seen through it, and the content behind it is inert for the keyboard too, not only covered.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A layer with `fixed inset-0`, a backdrop or a large spinner over the whole page while one table, chart or panel fetches, such as on its query's `isFetching`. Leave it alone for the first load of a whole view, or for saving or submitting the whole view (see Exceptions).
- Filters, search, navigation or other parts set to `disabled` or `inert` while a single part loads. Change a filter and see whether the rest of the view keeps working.
- A whole-view layer allowed by the Exceptions that hides keyboard focus, or leaves the content behind it reachable with Tab because it is only covered, not `inert`.

<a id="sta-002a"></a>

## STA-002a Say what will appear in a space that holds nothing yet, and offer the first step

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/sta-002a/

### Rule

When a list, table, panel or page has finished loading and holds nothing yet, show a short message in that space that says what will appear there. When the person can add the first item, offer that action as one button or link with the message.

### Why

A space with nothing in it tells the person nothing. They cannot tell whether it is still working, has broken or was set up wrong, and they have to guess how to fill it. A line that names what belongs there, with the step that puts it there, turns a dead end into a start. No WCAG criterion asks for an empty state. The rule rests on the judges. [WCAG 2.2, 2.4.3 Focus Order](https://www.w3.org/TR/WCAG22/#focus-order) bears only on where focus goes when the last item is removed, as described under Do. This rule covers the case where loading is over and there is truly nothing: a first visit, or a list the person has emptied. While the content is still on its way, STA-002b applies. When a search or a filter found nothing, the guideline STA-003 applies.

### Do

- A bike repair workshop opens its new app for the first time. The page *Repair jobs* holds no jobs. Where the list would be, a heading reads "No repair jobs yet", the line below says "Jobs you add will show here, with the bike, the customer and the due date.", and one button reads *Add repair job*. It is the page's main task, so it may have the `default` style, as ACT-002b allows. If the page header already has an *Add repair job* button in `default` style, the empty state does not add a second one: give its button `variant="outline"`, or point to the header button in the line.
- Name the action with a verb and the item, as ACT-001a asks. Our own choice: a second route may follow as a quiet text link below the main button, never as a second button, with text that says where it goes, such as "Import jobs from a spreadsheet", as TXT-003 asks.
- Put the message where the items would be: inside the card, the panel or the table's area. Not in a toast, and not in a page-wide banner far from the space.
- A start page has three cards, *Parts on order*, *Open quotes* and *Bikes ready for collection*, and all are empty. *Parts on order* and *Open quotes* each give one button with `variant="outline"`, *Order parts* and *Write a quote*, so the page does not end up with three primary buttons (ACT-002a, ACT-002b).
- *Bikes ready for collection* fills on its own, when a mechanic marks a job done. It has no button. Its line says "Bikes show here when a mechanic marks the repair as done."
- A person whose role cannot create jobs sees "Repair jobs added by the workshop manager will show here." and no button. Say how the items arrive, if the product knows.
- Our own choice for a table: replace the whole table, header row included, with the message. A screen reader user then does not pass a row of column headers before learning that there are no rows. The table's title stays as the heading above the message, so the space keeps its name (TBL-004). If that title is a `TableCaption` inside the table, move it out as a heading when the table is replaced, or the name goes with the table.
- If the header row has to stay, for instance because column settings live there, put the message as text outside the table body, under the table, not as a fake data row.
- A list with groups, where one group is empty, shows a short line in that group, such as "No jobs this week", not a full empty state.
- An icon or image in the empty state only decorates: `alt=""` on an `img`, or `aria-hidden="true"` on an inline SVG, as STR-005 says. Our own choice: use it sparingly, or not at all.
- The person deletes the last job in *Today's jobs*. The empty state appears in that place. Our own choice, resting on 2.4.3: focus moves to its heading (with `tabindex="-1"`) or to its button, so it is never lost and stays visible (KBD-001). When the delete ran through a confirmation dialog, the row's delete button that opened it is gone when it closes, so the fallback DLG-006 asks for, set in `onCloseAutoFocus`, points at the empty state. If *Undo* brings the job back, as DST-001a offers, the list returns and the empty state goes.
- An empty state that is there when the page loads is page content, not a status message. One that appears in place after the person's action, while focus stays put, is announced as FBK-004 says. The empty state component is usually mounted together with its text, so write the line into a polite live region that was already in the page. For example, *Delete selected* in a toolbar removes the last rows while focus stays on the toolbar, and the region says "No repair jobs left".

### Don't

- Keep the shadcn data table's last row as it comes, one `TableCell colSpan={columns.length}` reading "No results.", on a list that is empty because nothing has been added. Nobody searched, so "No results." is wrong, and it offers no way forward.
- Map over an empty array and render nothing, so *Repair jobs* is a heading over white space.
- Write "No data" or "Nothing here" with no noun and no next step.
- Fill the space with a large illustration and a joke, and no button.
- Offer *Add repair job*, *Import jobs*, *Invite a mechanic* and *Watch the tour* as four buttons of equal weight.
- Put something the person must keep, such as a setup code or a deadline, only in the empty state. It disappears once the first item exists.

### Exceptions

- **Still loading or failed.** While the content is on its way, show the wait (STA-001, STA-002b). A load that failed is a failure, shown as FBK-002 and TXT-001a say, never as an empty space.
- **No matches.** A search or filter that found nothing is the guideline STA-003. Its way out is to change the query, not to create an item.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- The shadcn data table's default empty row, a `TableCell colSpan={columns.length}` reading "No results.", on a list that is empty because nothing has been added yet.
- `items.map(...)` with no branch for an empty array, so once loading has finished the heading sits over blank space.
- An empty message such as "No data" or "Nothing here". Read it and ask: does it say what will appear in this space?
- An empty space where the person can add the first item but no button or link offers it. Leave it alone when the person cannot add items, items arrive on their own, or the line points to the same action already in the page header.
- An empty message shown in a toast or a page-wide banner instead of inside the list, table, card or panel it is about.

<a id="sta-002b"></a>

## STA-002b Never say a space is empty while its content is still loading

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/sta-002b/

### Rule

While a list, table or panel is still fetching its content, show that it is loading, never that it is empty. Show the message that there is nothing only after the fetch has finished and returned no items.

### Why

A message that says there is nothing is an answer, and people act on it. If it shows while the content is still on its way, some leave and never see their data, and those who wait and see it fill in learn not to trust what the app tells them. A blank space during the fetch does harm too, since it looks the same as an empty one. The space has to say "on its way" until the reply is there, and "nothing" only after. How and where the wait is drawn is STA-001. What the empty space then says is STA-002a, or the guideline STA-003 after a search or filter. No WCAG criterion says which of the two to show. When the line changes in place while focus stays elsewhere, both "Loading orders" and "No orders yet" are status messages under [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), announced as FBK-004 says.

### Do

- Give the component at least three states, not two: loading, empty and ready, and a fourth for a failure. A plain `useState([])` cannot tell "not fetched yet" from "fetched, nothing there".
- With TanStack Query, show the wait while `isPending` is true. Show the empty state only when `isSuccess` is true and the data is an empty array. Never treat `data` that is still `undefined` as empty. A query with `enabled: false`, such as a search before anything is typed, stays pending without fetching: show neither the wait nor the empty state then, only the prompt to type.
- A dashboard card *Overdue invoices* fetches on its own. Until the reply it shows a small indicator named "Loading overdue invoices", as STA-001 asks. Then it shows the invoices, or the empty state STA-002a describes.
- A table refetches after the person changes a filter. Keep the old rows, dimmed, with an indicator, as STA-001 says, until the new rows or the no-match message from STA-003 arrive. With TanStack Query, set `placeholderData: keepPreviousData` so the old rows stay while the new query key loads, and dim them while `isPlaceholderData` is true.
- A command menu searches the server as the person types. While the request runs, the list says "Searching customers …". Only after the reply does it show the matches, or the no-match line.
- Give a Suspense boundary a `fallback` with a skeleton or an indicator.
- When the fetch fails, the space shows a failure, not an empty state. FBK-002 says where it goes and how long it stays, and TXT-001a what it says, with a way to try again. It may use the same place as the empty state, but it is a failure message.
- Whether to show a wait at all for a very quick reply is STA-001's own choice of about half a second. Applied here: for that half second the space shows neither the wait nor the empty state.
- The line that changes from "Loading invoices" to "No overdue invoices" or to "12 overdue invoices" is announced as FBK-004 says. The rows themselves are not a status message.

### Don't

- Write `const [items, setItems] = useState([])` and render `items.length === 0 ? <Empty /> : <List />`, so "No invoices yet" flashes on the first render before the effect has fetched anything.
- Write `catch { setItems([]) }`, or pass `data ?? []` to the shadcn data table, so a server error or a dropped connection shows the table's "No results." row.
- Clear the rows as soon as a filter changes, so the empty row shows for as long as the request takes.
- Use `fallback={null}` on a Suspense boundary, so the area is blank while it loads.
- Show `CommandEmpty` with "No results found." after the first keystroke while the request is still running.

### Exceptions

- **Content already on the page.** A list that is rendered with the page, with nothing to fetch, has no loading state. Show the items or the empty state at once.
- **What the wait looks like.** A spinner, a skeleton or dimmed old rows all fit this rule. STA-001 decides which and where.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A list kept as `useState([])`, filled by a fetch in `useEffect`, that renders the empty state on `items.length === 0` with no separate loading state. Leave it alone when the items come with the page and nothing is fetched.
- `data ?? []` or `data || []` from TanStack Query, SWR or similar passed to a table, a list or a `.length === 0` check, with no earlier branch for `isPending` or `isLoading`.
- `catch { setItems([]) }`, or an `isError` that falls through to the empty state, so a failed fetch reads as an empty list.
- A Suspense boundary around fetched content with `fallback={null}`, or `CommandEmpty` in a command menu that searches the server, shown while the request is still running.
- Rows that go empty when a filter or the query key changes, with no `placeholderData: keepPreviousData` and no loading branch, so the empty row shows during the request.

<a id="sta-003"></a>

## STA-003 When a search or filter matches nothing, say so and offer a way to change it

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/sta-003/

### Rule

When a search or filter matches nothing, say in the results space that nothing matched, and offer a way to change or clear the search or the filters. Our own choice: name what was searched for or filtered by, and keep the query and the filters in place, ready to edit.

### Why

An empty result after a search is a different thing from an empty list. The items may well exist; the person's words or choices kept them out. If the space only goes blank, or says "No results." with nothing else, they cannot tell a search that found nothing from one that is slow or broken, and they do not know which of their choices to undo. A message that names the query and offers the way back lets them correct it in one step. No WCAG criterion asks for the content of this message. When the line appears while focus stays in the search field, it is a status message under [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), announced as FBK-004 says.

### Our reasons

Only one judge has spoken, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So does NN/g, an expert witness who does not vote. Naming the query or the filters in the message is our own choice, backed by NN/g. Keeping the query in the field is backed only by NN/g, so that is our own choice too. We follow it for three reasons.

- **A dead end costs the person the search.** Without a way out, the only next step is to start over, and many people give up instead.
- **The cause is the person's own input.** Naming the query or the filters shows them what to change, and a clear control lets them change it without hunting.
- **Rebuilding a search is work.** A query or a set of filters that is cleared after an empty result must be typed and chosen again. Leaving it in place costs nothing.

### Do

- A bike parts shop's stock table has a search field and the filters *Brand* and *In stock*. The person types "alloy seatpost" with *In stock* on. Where the rows were, the table area says "No in-stock parts match “alloy seatpost”.", with *Clear search* and *Clear filters*. "alloy seatpost" stays in the field, and *In stock* stays on.
- The count line above the table, "0 parts", sits in a polite live region that was in the page before the search, as FBK-004 says. The rows themselves are not a status message.
- The filters live in a popover. Outside it, the toolbar shows "2 filters on" and *Clear filters*, so an empty table never looks like missing stock.
- Our own advice: when one filter is likely to blame and the product can tell cheaply, offer to remove just that one, such as *Show parts not in stock (4)*.
- Our own advice: suggest a spelling or wider words when the search can, such as a link *Search for “seat post”*.
- In a shadcn command menu, replace the default text of `CommandEmpty` with a line that repeats the typed words and a hint, such as "No customers match “Hendrix”. Check the spelling or try fewer letters." `CommandEmpty` only mounts when the count reaches zero, so it is created together with its text, and focus stays in the input. Write the same line into a polite live region that is in the menu from the start, as FBK-004 says.
- A tag combobox, where creating the typed tag is what the person likely wants, may offer *Create tag “gravel”* in the empty line. Elsewhere, changing or clearing the query is the main way out, not creating an item.
- Write in a plain tone and neutral colours. No match is a normal outcome, not an error, so it does not use the danger colour or the wording TXT-001a asks of a problem.
- A search that found near matches may show them under a line that says nothing matched exactly.
- Buttons follow ACT-001a: *Clear filters*, not *Reset* or *OK*.

### Don't

- Keep the data table's "No results." row for every empty case, so a filter with no match, a list with no items and a failed fetch all look alike.
- Leave `CommandEmpty` at "No results found." with no hint and nothing to do.
- Clear the search field or the filters when the result is empty, or reset them when the person comes back with the browser's Back button.
- Put the count line in a `div` that is created at the same moment as its text, so screen readers miss it.
- Show "No matches" in red with a warning icon.
- Offer *Add part* as the main button under "No in-stock parts match “alloy seatpost”".

### Exceptions

- **Nothing there at all.** When the list is empty with no search or filter applied, STA-002a applies.
- **Still searching or failed.** While the request runs, show the wait (STA-002b). A search that failed is a failure, shown as FBK-002 and TXT-001a say, not a no-match.
- **A product that chooses otherwise.** This is a guideline. A product that words its no-match message differently still announces the count line, as FBK-004, a requirement, asks.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Apply a search or filter that matches nothing and see whether the results space says that nothing matched, rather than showing blank space or the same "No results." row used for an empty list or a failed fetch.
- A no-match state with no way out: no *Clear search* or *Clear filters*, and the query or filters not editable from there, for example filters hidden in a closed popover with nothing saying they are on.
- A no-match line that does not name what was searched for or filtered by, such as `CommandEmpty` left at "No results found.".
- Code that clears the search field or resets the filters when the result is empty or when the person comes back with Back, such as `setQuery("")` in the empty branch.

<a id="sta-004"></a>

## STA-004 Let people turn off, lengthen or extend a time limit the product sets

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/sta-004/

### Rule

When the product sets a time limit that can end a person's chance to act or throw away their work, let them turn it off, lengthen it, or extend it after a warning, unless an exception applies. Each option meets 2.2.1 only with the conditions listed for it first under Do. Our advice is to prefer them in that order.

### Why

Some people read slowly, type with a switch or a head pointer, use a screen reader, or need to stop and think. A clock they cannot see or control can sign them out halfway through and take their work with it. [WCAG 2.2, 2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable) requires one of the three options for every limit the content sets. A limit that exists for security, or that the product's own server enforces, still counts. It covers an idle sign-out, a session with a fixed maximum length, a hold on something the person has reserved, a step that must be done within a set time, and a page that refreshes or redirects on its own after a delay. No limit at all helps most, so ask first whether the limit is needed. A warning at the end helps least, because it still interrupts.

The warning has to reach everyone. If it appears without taking focus, it is a status message under [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), and FBK-004 says how it is announced; losing work soon is the kind of warning FBK-004 keeps role="alert" for. The control that extends the limit must work from the keyboard, as [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) asks.

We also aim, beyond Level AA, for two things that WCAG places at Level AAA and does not require here. When a person signs in again after a lapse, they carry on where they were with nothing lost ([WCAG 2.2, 2.2.5 Re-authenticating](https://www.w3.org/TR/WCAG22/#re-authenticating)). And when idle time can lose their data, they are told how long that time is when the task starts ([WCAG 2.2, 2.2.6 Timeouts](https://www.w3.org/TR/WCAG22/#timeouts)). These are our aims, not part of the requirement.

### Do

- **Option 1: turn it off.** The person can switch the limit off before they reach it.
- **Option 2: lengthen it.** Before they reach it, the person can set the limit to at least ten times the default, over a wide range.
- **Option 3: warn and extend.** Before time runs out, warn the person, give them at least 20 seconds to answer, and let them extend the limit with one simple action, such as one button. Allow that at least ten times.
- An internal admin tool signs people out after 30 minutes of inactivity. Under *Settings*, *Security*, the person can choose *Sign me out after* 30 minutes, 2 hours, 8 hours or *Never on this device*. The longest choice is far more than ten times the default.
- A web app signs people out after 15 minutes idle. Two minutes before that, a dialog with role="alertdialog" opens: "You will be signed out in 2 minutes because you have been inactive." It has two buttons, *Stay signed in* and *Sign out*. One press of *Stay signed in* resets the clock, and the person can do that as often as they like.
- The warning stays on screen until the person answers or the limit passes. It is never a toast that closes on a timer (FBK-005 and FBK-003 cover how long messages stay).
- A person is typing in a dialog *Edit invoice* when the idle warning is due. No second dialog opens. A notice appears inside *Edit invoice*, above its buttons, with *Stay signed in*, the same way DLG-002 shows a failed main action. Focus stays where it was, and the notice is announced as FBK-004 says.
- When no dialog is open, the warning may instead be an alert in the page with role="alert" and a *Stay signed in* button the person can reach by keyboard. It does not cover the element that has focus (KBD-002).
- Pressing Escape on the warning dialog counts as *Stay signed in*. That is the button that leaves everything as it is, so DLG-001 gives it to Escape. It resets the clock and closes the warning. Escape never signs the person out, and it never just hides the warning while the clock keeps running.
- Our own choice: give the warning dialog only *Sign out* and *Stay signed in*, with no *Cancel*, *Close* or close icon. A third way out would leave the person unsure whether the clock is still running.
- After *Stay signed in*, focus returns to where the person was, and every field keeps what they typed. Extending never discards unsaved work, also in a full-screen dialog with unsaved changes (FRM-004a).
- A support chat ends the conversation after five minutes without a reply from the person. A minute before that, a line in the chat says "This chat will close in 1 minute because we have not heard from you." with a button *Keep the chat open*. Each press gives five more minutes, and the line stays until the person answers or the chat closes.
- A confirmation page shows "Your password has been changed" and a link *Go to your account*. It does not redirect on its own after five seconds. If a redirect is truly needed, let the person stop it or follow the link when they are ready.
- Our aim beyond AA: the first step of a long customer survey says, once, "If you leave this survey for 45 minutes, it closes. Your answers so far are kept." When the person opens the survey link again, they return to the question they were on with their answers in place (FRM-009).
- Our own choice: when the product runs in several tabs, the warning and the extension apply to the whole session, so choosing *Stay signed in* in one tab keeps the others signed in too.

### Don't

- Sign a person out after a period of inactivity with no warning, no setting and no way to extend.
- Show a warning only 10 seconds before the limit, or show a countdown with no button to get more time.
- Make the person type their password or solve a puzzle to extend the limit. One simple action is enough.
- Allow only one or two extensions and then sign the person out anyway.
- Show the warning as a toast that disappears after a few seconds.
- Open the warning as a second dialog on top of a dialog the person is working in.
- Throw away what the person typed when they extend the limit, or reload the page to do it.
- Let Escape or closing the warning count as *Sign out*.
- Refresh a page of open orders every two minutes on a timer while the person is reading or filling it in, with no way to stop it.
- Treat a limit as essential just because it is convenient for the server.

### Exceptions

- **Real-time events.** When a live event cannot happen without the limit and no alternative is possible, such as a live poll that closes when the presenter moves to the next question, the three options do not apply.
- **Essential limits.** When more time would break the point of the activity, the limit may stay, for example a timed reaction drill in a training game. Some security limits can count as essential, such as a sign-in code that lapses after a few minutes; the sign-in still follows FRM-008. Even then, move as much of the work as possible out of the timed part.
- **Limits longer than 20 hours.** These are outside the requirement.
- **Limits outside the product.** A limit set by the browser, the operating system or the network is not one the product sets. A limit the person chose themselves meets the second option only if the setting reaches at least ten times the default.
- **Short-lived messages.** How long a toast or snackbar stays on screen, including one that holds a button, is covered by FBK-005 and FBK-003, not by this rule.
- **Limits on reading.** Content that moves or updates on its own, such as a carousel, a ticker or a live feed, is outside this rule. [WCAG 2.2, 2.2.1 Timing Adjustable](https://www.w3.org/TR/WCAG22/#timing-adjustable) and [WCAG 2.2, 2.2.2 Pause, Stop, Hide](https://www.w3.org/TR/WCAG22/#pause-stop-hide) still apply to it; VIS-005 covers the second.
- **After the limit passes.** What the person sees once they have been signed out follows FBK-002, which says that news is never carried only by a message that closes itself.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A timer that signs out, ends a session or throws away input, such as `setTimeout(signOut, ...)`, an idle timer's `onIdle` or a short session `maxAge`, with no setting to turn it off or lengthen it and no warning first.
- Let the limit run to its warning: are there at least 20 seconds to answer, and does one simple action such as *Stay signed in* extend it, at least ten times, with no password or puzzle?
- A warning shown as a toast that closes on a timer, or as a countdown with no button to get more time.
- Press *Stay signed in* and see whether every field keeps what was typed and the page does not reload.
- A page that redirects or refreshes on a timer, such as `router.push` in a `setTimeout` on a confirmation page. Leave alone real-time and essential limits, limits over 20 hours and limits the product does not set (see Exceptions).

<a id="sta-005a"></a>

## STA-005a Show that a sent action is under way until the reply comes

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/sta-005a/

### Rule

When a button sends, saves or deletes something and the reply does not come at once, show that the action is under way until the reply comes.

### Why

Between the press and the reply the person knows nothing. If the view looks the same as before, they cannot tell a press that was taken from one that missed, so they press again, wait in doubt or leave before the work is done. A sign that the action is under way says "we have it". A sign that stays until the reply says "not yet", and keeps the person from reading a spinner that stopped early as an answer. STA-001 says where a wait is shown. This rule adds two things for an action that is sent: that the wait is shown at all, and that the sign lasts until the reply. What the reply then shows is decided by other rules: FBK-003 for a success and FBK-002 for a failure. No WCAG criterion asks for a sign that an action is under way. Once one is shown while focus stays put, it is a status message under [WCAG 2.2, 4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages); FBK-004 says how it reaches assistive technology. Two more criteria bear on a button that changes while it works, [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) and [2.5.3 Label in Name](https://www.w3.org/TR/WCAG22/#label-in-name), as described under Do.

### Do

- A tool hire shop has a page form *Hire a tool* with *Tool*, *Collection day* and *Number of days*. The person presses *Send hire request* and the reply takes three seconds. While it is on its way the button shows a small spinner and reads "Sending request …", and it goes on doing so until the reply is there. The page that then opens says "Hire request sent. We will confirm it by email." That page is the result, as FBK-003 allows.
- A member of staff presses *Mark as returned* on the hire card *Floor sander, 2 days*. While the change is saved, the card shows "Marking as returned …" next to the button. When the reply comes, the card's status reads *Returned*. The other hire cards show nothing and keep working.
- The dialog *Add an accessory* has *Accessory*, *Quantity*, *Cancel* and *Add accessory*. While it saves, the sign sits inside the dialog, on *Add accessory*, as STA-001 and DLG-002 ask. When the accessory is saved the dialog closes, the accessory is in the hire's list, and focus returns to the button that opened the dialog, as DLG-006 says.
- "Delete the hire Tile cutter, 3 days?" has *Cancel* and *Delete hire*. After the press on *Delete hire* the dialog shows "Deleting …" until the reply. Then the dialog closes and the hire is gone from the list.
- Where the sign goes, at the button, in the part the action acts on or, when STA-001 allows it, over the whole view, is decided by STA-001. This rule only asks that the sign is there and that it lasts.
- "Not at once" uses the figure STA-001 gives as our own choice. The sign may wait until that time has passed, so that nothing flashes for a quick reply. Once it shows, it stays until the reply. A reply that comes sooner shows its result with no sign in between.
- When the reply comes, the sign does not just disappear. A success shows as FBK-003 says and a failure as FBK-002 says. Those rules decide the result; this one does not.
- Our own choice: a short "Request sent" on the button before the next view opens. It never replaces what FBK-003 asks for.
- The working label describes a state. It is not a new action, so the verb-first form in ACT-001a does not apply to "Sending request …". When the reply comes and the button is still on screen, *Send hire request* returns. Our own choice: keep the button's width fixed while the label changes, so nothing around it jumps.
- For as long as the button reads "Sending request …", its accessible name contains those words, as ACT-001b says. A fixed `aria-label` with the old words breaks that. This helps meet 2.5.3.
- If the button changes state while it works, for example by becoming unavailable to a new press as STA-005b describes, expose that state in code, not only in its looks. This helps meet 4.1.2.
- How the wait and the result are announced is FBK-004. Applied here: write a text that names the action, such as "Sending hire request", into a polite live region that was in the page before the press. A spinner alone, with no text for assistive technology, is not enough. When the wait ends and focus stays where it is, write the result there in place of the working text. A result that moves focus, or that opens a new page or a dialog, is not also written to the region. A failure that needs attention now may use `role="alert"`, as FBK-004 says.
- Our own choice: focus stays on the pressed button during the wait. If the result removes the button, focus goes where the rule for that result says, such as DLG-006 when a dialog closes.
- Our own choice, for a dialog: while it sends, *Cancel*, Escape and the close icon behave alike. Choose one of two ways. Stop: each of them withdraws the request, and the view then says what happened. Wait: all three are unavailable until the reply, and the dialog keeps showing that it is working. The dialog never closes while the request runs on unseen.
- Stop, in practice: the dialog *Add photos of the tool* is uploading six photos. *Cancel* stops the upload. The dialog goes back to its form with the six photos still chosen, and a line reads "Upload stopped. No photos were added." A second press on *Cancel* is an ordinary close, and FRM-004b decides whether a question comes first.
- Offer Stop only when the request can truly be withdrawn. A delete or a payment that has left the browser cannot be called back by closing a dialog, so *Delete hire* above uses Wait: *Cancel*, Escape and the close icon do nothing until the reply. With Wait, keep *Cancel* and the close icon focusable and expose that they are unavailable.
- Our own choice: while a dialog sends, no question about discarding input is asked. The input is on its way, so FRM-004a and FRM-004b have nothing to protect until the reply.
- Our own choice: the form and what the person entered stay on screen during the wait. Nothing is cleared before the reply says the send worked.
- *Send hire request* fails because the booking system does not answer. The sign goes, *Send hire request* is ready again, and every answer is still in its field. A notice near the button says "The hire request was not sent. The booking system did not answer. Your answers are still here. Try again in a moment.", as FBK-002 and TXT-001a ask. If the reply instead points at fields, such as a collection day when the shop is closed, the messages show at those fields and focus moves as FRM-011 says.
- Fields may be locked during the wait. That is allowed, not asked for. Our own choice: if you lock them, make them read-only, not disabled, so the values stay readable and focus is not lost, and unlock them if the send fails. If you leave them open, do not silently drop an edit made during the wait.
- When a view has several buttons that send different things, only the pressed one shows work. Our own choice: make another button unavailable only if it depends on the same data.
- Our own choice, for a long wait: say more than a spinner can. STA-001 covers the switch to an indicator that shows how far the work has come. Add a line near the button about what is happening or roughly how long it takes. A send that stalls or times out becomes a failure the person can act on, as FBK-002 says, and never a spinner without end. A job that runs for minutes lets the person go on with other things and leaves a lasting sign when it is done, as FBK-003 says.
- A change shown at once, as the second exception allows: on the staff board a member of staff drags the hire card *Concrete mixer, 1 day* from *Booked* to *Out*. The card sits in *Out* from the moment it is dropped, and the moved card is the result, as FBK-003 allows. The move itself is announced as ACT-007b describes; the server's agreement adds nothing. The card's *Move to* menu does the same without dragging, as ACT-007a asks.
- The same move, refused: the card goes back to *Booked*, in the place it had, and the card itself reads "Could not be moved to Out. The booking system did not answer." with *Try again*, as FBK-002 asks. The text is written to a polite live region that was in the page before the move, as FBK-004 says. If the card was moved with the keyboard, focus stays on the card in its old place.
- Our own choice: a star button on the tool *Pressure washer* adds it to the person's favourites and fills at once. Its accessible name, or `aria-pressed`, follows the star both ways, also when it goes back after a refusal, and the tool's row then says "Could not be added to favourites." This helps meet 4.1.2.
- Our own choice, for fast repeats: when the star is pressed three times within a second, the view follows the last press. A late reply to an earlier press never undoes a later one, and a refusal puts back the last state the server agreed to, not an older copy. Each press sets a state, so this is the harmless repeat STA-005b allows, not a second send.
- Our own choice: the tool name *Hammer drill 800 W* is edited in place and the new name shows as soon as the person presses Enter or leaves the field. If the save fails for a server reason, the old name comes back and the message sits at the name. If the server refuses the value itself, such as "A tool with this name already exists.", that is a field error: the field opens again with what the person typed and the message follows FRM-002a. The typed name is never thrown away.
- Delete with *Undo*, as DST-001a describes, is the same pattern and needs no working sign. If the server then refuses the delete, the row comes back where it was with a notice in the row or the list, as FBK-002 says, and the message with *Undo* is removed or replaced, since there is nothing left to undo (FBK-005).
- Our own choice: a faint "Saving …" or a small mark on the changed item while the reply is out. It never blocks the item.

### Don't

- Leave *Send hire request* looking exactly as before for four seconds after the press, so the person cannot tell whether it was taken.
- Show "Sending request …" for a second and then put the old label back while the request is still running.
- Take the spinner away when the reply comes and show nothing else. FBK-002 and FBK-003 ask for the result.
- Empty the form as soon as *Send hire request* is pressed, so a failed send leaves nothing to send again.
- Close *Add an accessory* on Escape while the accessory is still being saved, and let the save carry on with no sign of how it ended.
- Let *Cancel* stop the request while Escape closes the dialog and leaves it running.
- Label a button *Stop* when pressing it only hides the dialog and the delete goes through anyway.
- Show the working sign on every hire card because one *Mark as returned* was pressed.
- Give the busy button a spinner with no text, so a screen reader user hears nothing during the wait.
- Let a spinner turn for minutes after the server has stopped answering.
- Add a hire request to *My hires* as confirmed the moment *Send hire request* is pressed, with no working sign. A request that leaves the product, like a payment or an invitation, is not a small change and shows the sign this rule asks for.
- Let the card *Concrete mixer, 1 day* jump back to *Booked* after a refusal with no word at all, as `useOptimistic` does when nothing renders the error.
- Leave a reordered accessory list in its new order after the server refused it.
- Put the old tool name back when the server says the new one is taken, so what the person typed is lost.
- Turn the star back to empty after a refusal but leave its accessible name or `aria-pressed` on the new state.

### Exceptions

- **A reply that comes at once.** No sign is needed. The result is the answer.
- **A change shown at once and corrected on failure.** A small change to something already on screen, such as ticking a box, flipping a switch, starring an item, moving a card to another column, changing the order of a list or renaming an item in place, may show its result on the press with no sending sign. It holds only when all four of these are true, for a tick box or a switch as well. Everything beyond tick boxes and switches, and the four conditions, is our own choice:
  1. The view can show the result without the server: nothing shown is made by the server, such as an order number, a price or a generated name; a count the view can work out, such as one more star, is fine.
  2. The product can put the earlier state back in full: the same value, the same place in the list, the same column.
  3. A wrong guess costs little: the action does not pay, send anything to other people, publish, or do anything else that cannot be called back. Payments, messages, invitations and sign-ups show the sending sign.
  4. The reply usually comes within the time STA-001 gives and usually agrees.

  When the reply refuses the change, put the earlier state back, say so as text where the change was made, as FBK-002 asks, and announce it, as FBK-004 asks. A refusal of the value itself, such as a name already taken, is a field error instead: keep what the person typed and follow FRM-002a. The view never keeps showing a change that did not happen. This exception allows such changes; it does not prefer them to the sending sign.
- **A form that loads a new page.** When the press sends the form the classic way, the browser loads the next page and that page is the result. The browser's own sign of loading is small and easy to miss, so a sign at the button is still the better choice when the reply can be slow. STA-005b applies to a second press either way.
- **Loading content.** A wait for content to appear, with nothing sent, belongs to STA-001.
- **Before the press.** Whether the button is enabled, and what it says when it is not, is ACT-004 and ACT-005. A second press during the wait is STA-005b.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Slow the network, press a button that sends, saves or deletes, and see whether a sign that it is working shows and stays until the reply. Leave alone replies that come at once and small changes shown at once that meet the conditions under Exceptions.
- A submit or save button that does not use `isSubmitting` from react-hook-form, `isPending` from a mutation or `pending` from `useFormStatus`, with no other working sign nearby. A classic form post that loads a new page is left alone (see Exceptions).
- A working label put back on a fixed timer, such as a `setTimeout` that restores *Send* while the request is still running.
- A dialog that closes on Escape, *Cancel* or the close icon while its request is still running, so the work goes on with no sign of how it ended. Leave it alone when closing withdraws the request and the view says so.
- A change drawn before the reply, with `useOptimistic` or a cache write in `onMutate`, for something that pays, sends to other people, publishes or cannot be called back, with no working sign. Also one whose failure branch renders nothing where the change was made. A missing rollback is FBK-002's check.

<a id="sta-005b"></a>

## STA-005b While an action is being sent, a second press does not send it again

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/sta-005b/

### Rule

While an action is being sent, another press on the same button does not send it again, whether it comes as a click, a tap, Enter or Space.

### Why

A button that sends something is often pressed more than once, and the product cannot tell from the presses whether the person meant it. Almost always they did not: the second press is part of the same decision as the first. If each press is sent, one decision becomes two orders, two payments or two messages to the same people, and the person finds out later, when it takes a phone call to put right. One press should mean one action. No WCAG criterion asks for this, and none says how a repeat press is stopped. If the button changes state while it refuses presses, that state must be available to assistive technology, which is what [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks of every control. The sign that the action is under way is STA-005a.

### Our reasons

Fewer than two judges have spoken about a second press, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Carbon supports it. So does GOV.UK, an expert witness who does not vote. Applying it to every send that costs something to undo, without first asking for proof that duplicates happen, is our choice too. The guideline does not say how the press is stopped. The way we describe under Do is our own. We stop the second send for four reasons.

- **A duplicate is costly to undo.** A second order has to be cancelled, a second payment refunded, and a message sent twice cannot be taken back at all. The person who pressed twice did not ask for any of it.
- **The sign alone does not stop a fast hand.** STA-005a asks for a sign that the action is under way, and that removes most of the doubt that makes people press again. The sign may take a moment to show. A double-click still lands before anyone has read anything.
- **It costs the person nothing.** Nobody means to send the same thing twice within a second or two. A press that is dropped while the first is still on its way takes nothing from them.
- **The person should not have to be careful.** The product can count presses, and it knows that the first one is still on its way. The person should not need to keep track of that.

### Do

- At a theatre's box office site the person presses *Pay £38.00* for two seats and, out of habit, presses again half a second later. One payment is sent, and the second press does nothing. While the payment is on its way the button reads "Paying …", the sign STA-005a asks for. The guard starts at the first press, also before that sign shows.
- The guard covers every way of pressing: a click, a tap, Enter and Space on the button.
- Our own advice: put the guard on the send, not only on the button's click. Enter in a field sends a form too (FRM-015). In *Ask about a booking*, the person presses Enter twice in *Your question*, and one question is sent.
- Our own choice of mechanism: keep the button able to take focus, mark it `aria-disabled="true"` and ignore the press. We prefer that to the `disabled` attribute. A button that gets `disabled` while it has focus drops out of the tab order, and focus can fall to the top of the page; in a dialog it can fall out of the dialog. A team that uses `disabled` anyway moves focus to a sensible place first and puts it back when the reply comes, which is why we prefer the first way.
- Whichever mechanism you use, expose the state in code, not only as a faded look, as VIS-008a says. This helps meet 4.1.2.
- The working label or sign from STA-005a is the explanation for the pause. Nothing is missing from the form, so the note that ACT-005 asks for at an unavailable button is not shown.
- The guard lasts from the press until the reply, and no longer. When the payment is refused or the request is given up, *Pay £38.00* works again at once, so the person can try again.
- After a success, a new press is a new action. In a club's members' pages, *Send message* stays on screen once a message has gone out, and the next press sends the next message.
- When the press loads a new page, the guard holds until that page arrives.
- Not part of the guideline: let the server refuse duplicates as well. A script in the page can fail to load, and a request can be sent again by the network. The guard in the page is for the person; it is not the only protection.
- In a dialog, the main button is guarded in the same way. What *Cancel*, Escape and the close icon do during the wait is in STA-005a.

### Don't

- Take two payments because *Pay £38.00* was double-clicked.
- Guard the click on the button but let Enter in a field send the form a second time.
- Let the button look as usual and silently swallow presses, with no working sign and no state in code.
- Write "Press the button only once" next to it and send every press.
- Keep the button unavailable after the send failed, so the person has to reload the page to try again.
- Switch the button off with `disabled` while it has focus and leave focus to land wherever the browser puts it.

### Exceptions

- **A repeat that does no harm.** A search, a refresh or a filter that is sent twice gives the same answer twice. It needs no guard, though it may have one.
- **Other buttons.** This guideline is about the pressed button and the action it sent. Other buttons in the view keep working unless they depend on the same data, as STA-005a says.
- **Before the press.** A button that is unavailable before anything is sent is ACT-004 and ACT-005. This guideline gives no reason to switch a submit button off before the press.
- **A product that chooses otherwise.** This is a guideline. A product that lets a repeat through still shows the wait, as STA-005a, a rule, asks.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Slow the network, double-click the button, then press Enter twice in a field of the same form, and count the requests sent. More than one is a break. Leave alone searches, refreshes and filters (see Exceptions).
- A send handler with no guard for a request in flight: no check of `isSubmitting`, `isPending` or a ref set on the first press, and no `disabled` or `aria-disabled` while it runs.
- A guard only on the button's `onClick`, while the form's `onSubmit` can still send again when Enter is pressed in a field.

<a id="str-001"></a>

## STR-001 Give every page a title that says what it is for, and change it with every view

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-001/

### Rule

Give every page a title, in the `title` element, that says what the page holds or is for. In a single page app, set a new title on every route change, so the title names the view now shown, not only the app.

### Why

The title is what a browser tab, a bookmark and the history list show, and it is the first thing a screen reader says when a page opens. A person with ten tabs open finds the right one by its title. A screen reader user learns from it, before anything else, whether they have landed where they meant to. A title that says "React App" on every page tells them nothing, and one that never changes in a single page app gives no sign that the view has changed at all.

This is a requirement. [WCAG 2.2, 2.4.2 Page Titled](https://www.w3.org/TR/WCAG22/#page-titled) asks that pages have titles that describe their topic or purpose. In HTML the title is the `title` element in `head` ([H25](https://www.w3.org/WAI/WCAG22/Techniques/html/H25)), and the Working Group's technique for a descriptive title asks that it names the subject and makes sense on its own ([G88](https://www.w3.org/WAI/WCAG22/Techniques/general/G88)). The criterion's text does not mention single page apps. A route at its own address is its own web page, and the Working Group lists as a failure a title that a template repeats on every page, so the pages cannot be told apart by it ([F25](https://www.w3.org/WAI/WCAG22/Techniques/failures/F25)). For views that script swaps at one address, it also advises that the title change to match the current view ([Understanding 2.4.2](https://www.w3.org/WAI/WCAG22/Understanding/page-titled.html)). The criterion does not ask for a fixed format or, beyond that, for titles that are unique. The format under Do is our own choice.

### Do

- In the bookkeeping app *Fernhill*, the view at `/invoices` has the title "Invoices – Fernhill", and the view at `/invoices/2026-114` has "Invoice 2026-114 – Fernhill". Each route sets its own.
- In the Next.js App Router, export `metadata` or `generateMetadata` from each `page.tsx`, and set `title.template` to `"%s – Fernhill"` in the root layout so every page gets the same ending.
- In React 19, render `<title>` inside the route's component; React moves it into `head`. In React Router framework mode, use the route's `meta` export. In TanStack Router, use the route's `head` option. With any other router, set `document.title` when the route changes.
- Replace the starter title before the first release. Vite's `index.html` and `create-next-app` both ship one that names the tool, not the product.
- Our own choice: put the part that names the view first and the product name last, so tabs and screen reader announcements start with the words that differ.
- Our own choice: keep titles unique inside the product. Two views with the same title, such as two lists both called "Overview", get the words that tell them apart.
- Our own choice: make the title and the view's `h1` say the same thing, as far as the product name. The `h1` is STR-003.
- Our own choice: when a form is shown again with problems, start the title with "Error: ", as in "Error: New invoice – Fernhill", so a screen reader user hears it first. Where focus goes is still FRM-011.
- Our own choice: keep personal details of the person using the app out of the title, such as their email address, phone number or account balance. Titles travel further than the page: into history, shared screens and reports. The name of a record they work on, such as an invoice number, is fine.
- Our own advice: while a view loads its data, show a sensible title at once, such as "Invoice – Fernhill", and make it specific when the data arrives.
- Our own advice: let a link's text and the title of the page it opens say the same thing, so people can tell they arrived where they meant to. Link text itself is TXT-003.

### Don't

- Ship with "Vite + React + TS" or "Create Next App" as the title of every page.
- Set the title once in the root layout, so `/invoices`, `/customers` and `/settings` all read "Fernhill".
- Let a template placeholder leak into the title before data arrives, so the tab reads "undefined – Fernhill" or "{invoice.number} – Fernhill".
- Put the signed-in person's email address in the title, as in "anna.berg@example.com – Dashboard".
- Write a title that repeats the product's tagline on every page, so it describes the product and never the view.

### Exceptions

- **Dialogs and sheets.** A dialog or sheet that opens over a view does not need its own title. It has no route of its own, and its name comes from its heading.
- **Tabs inside a view.** Tabs that switch content inside one view keep the view's title. A tab that has its own route and its own heading is a view, and gets its own title.
- **Not covered here.** Whether focus moves or anything is announced after a route change is a separate question this rule does not decide.
- **Neighbouring rules.** The page's language, which changes along with the title when the interface switches language in place, is STR-006.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Move between two routes, such as `/invoices` and `/customers`, and see whether `document.title` changes to name the view now shown, not only the product. Dialogs, sheets and tabs without their own route keep the view's title.
- A starter title left in `index.html` or the root layout, such as "Vite + React + TS", "React App" or "Create Next App".
- A Next.js App Router app where only the root `layout.tsx` sets `metadata.title` and no `page.tsx` or nested `layout.tsx` exports `metadata` or `generateMetadata`, and no route sets the title another way, such as a React 19 `<title>` or `document.title`.
- Open a view while its data loads and see whether the title shows "undefined", "null" or a raw placeholder such as `{invoice.number}`.

<a id="str-002a"></a>

## STR-002a Mark text that heads a part of the view as a heading in code

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-002a/

### Rule

When text heads a part of the view, such as a section, a card, a panel or a dialog, mark it as a heading in code, not only with bold or large type.

### Why

A sighted person finds their way down a page by the titles that stand out. A screen reader user does the same with a list of headings and a key that jumps from one to the next. That only works when the titles are headings in code. Text styled to look like a heading is, to a screen reader, one more line of text, so the page has no sections to jump between. The reverse misleads just as much: heading markup on a label or a number invents a section that is not there.

This is a requirement. [WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) asks that structure shown on screen can also be read from the code. The Working Group lists as a failure text that is styled to look like a heading but is marked up as ordinary text ([F2](https://www.w3.org/WAI/WCAG22/Techniques/failures/F2)), and its HTML technique is the `h1` to `h6` elements ([H42](https://www.w3.org/WAI/WCAG22/Techniques/html/H42)). The same criterion fails heading markup on text that heads nothing ([F43](https://www.w3.org/WAI/WCAG22/Techniques/failures/F43)). The criterion does not ask that a page have headings, or a certain number of them. It asks that what works as a heading is one. What the heading says is STR-002b, and its level is STR-003.

### Do

- In the project tool *Ridgeway*, the page *Project settings* has the sections *Members*, *Billing address* and *Delete project*. Each section title is a heading element, styled with classes.
- In shadcn, `CardTitle` and `AlertTitle` render a `div` and take no `asChild`. When the title heads what is in the card or the alert, put an `h2` or `h3` inside it, or change the element the component renders.
- `SidebarGroupLabel` also renders a `div`, but takes `asChild`. When it heads a group of links, write `<SidebarGroupLabel asChild><h2>Projects</h2></SidebarGroupLabel>`, which keeps its styling.
- Keep `DialogTitle`, `SheetTitle`, `AlertDialogTitle` and `DrawerTitle`. They render headings through Radix and also give the dialog its name.
- When a heading takes focus from script, as DLG-006 allows in one case, it stays a heading element with `tabindex="-1"`.
- Our own advice, not required: when a part is plain to sighted users from the layout but has no visible title, such as a list of search results, give it a heading with the `sr-only` class, such as "Search results".
- Our own choice: use the native `h1` to `h6` elements. `role="heading"` with `aria-level` also counts, as a fallback when the element cannot change.

### Don't

- Head the page with `<p className="text-2xl font-bold">Project settings</p>`.
- Build a section header as `<div className="text-lg font-semibold">Members</div>`.
- Replace `DialogTitle` with a styled `p`, so the dialog loses both its heading and its name.
- Mark the small grey text under a number on a dashboard tile, such as "Open tasks", as an `h4` because the tag fits. It heads nothing, which is the failure in F43.
- Make the price on a plan card, "€12 a month", an `h3` so it stands out. A price heads nothing.

### Exceptions

- **Labels of controls.** A field's `label` or a group's `legend` is not a heading. A label may sit inside a heading when the whole page asks one question, but that is a choice, not part of this rule.
- **Table captions.** A table's caption names the table and is not a heading. A word above a list can be one, when it heads that part.
- **Not covered here.** The heading's words are STR-002b and its level is STR-003. Where a heading sits in the code relative to its part is LAY-002. The page's `title` element is STR-001.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `p`, `div` or `span` with heading-like classes, such as `text-lg font-semibold` or `text-2xl font-bold`, as the first line of a section, card, panel or dialog. Does it head that part? Then it must be `h1` to `h6`, or `role="heading"` with `aria-level`.
- A shadcn `CardTitle` or `AlertTitle` whose text heads the card or alert, with no `h2` to `h6` inside it and its element unchanged; or a `SidebarGroupLabel` that heads a group of links without `asChild` and a heading inside.
- A `DialogTitle`, `SheetTitle`, `AlertDialogTitle` or `DrawerTitle` replaced by a styled `p` or `div`.
- Heading markup on text that heads nothing, such as a price on a plan card or the small caption under a number on a dashboard tile. A `label`, `legend` or table `caption` is not a heading and is left alone.

<a id="str-002b"></a>

## STR-002b Word each heading so it says what the part below it holds

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-002b/

### Rule

Word every heading so it says what the part below it holds or is for. A heading that would fit any part of any page, such as "Details" or "Section 2", does not.

### Why

People rarely read a page from the top. A sighted person scans the headings for the part they need, and a screen reader user often hears the headings as a list, each one without the content under it. A heading that names its part lets both decide at once whether to stop there. Three cards headed *Details*, *Info* and *Misc* make them open each one to find out.

This is a requirement. [WCAG 2.2, 2.4.6 Headings and Labels](https://www.w3.org/TR/WCAG22/#headings-and-labels) asks that headings describe their topic or purpose. It does not ask that a page have headings, and it does not decide whether text is marked as a heading; that is STR-002a. A short heading is fine. One word can describe its part well.

### Do

- In the project tool *Ridgeway*, the sections of *Project settings* are *Members*, *Billing address* and *Delete project*. Each names what is under it.
- On a project page, the three cards are headed *Dates*, *Owner* and *Tags*, after what each one holds.
- When a heading must stay short on screen but is vague out of context, add words for assistive technology inside it with a visually hidden `span`: the visible *Activity* is read as "Activity in Spring launch".
- Our own choice: put the word that tells parts apart first, so a list of headings can be scanned by its first words.
- The visible heading of a dialog says what the dialog is for, such as *Invite a member*. Its words are this rule; that it is a heading is STR-002a.

### Don't

- Head the list of people in a project with *Overview* when *Members* names it.
- Number sections, *Section 1*, *Section 2*, with nothing else in the heading.
- Head every card in a grid with the same word, so the list of headings repeats one word ten times.
- Use a clever line as a heading, such as *The fun part*, over the project's billing details.

### Exceptions

- **Not covered here.** Whether text is a heading in code is STR-002a, and its level is STR-003. Labels of form controls follow FRM-001 and FRM-010, and link text follows TXT-003.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Read the view's headings as a list, without the content below them. Does each say what its part holds or is for, or would it fit any part of any page, such as "Details", "Info" or "Section 2"? One word that names the part, such as "Members", is fine.
- The same heading text on every card in a grid or every section of a view, such as each `CardTitle` reading "Details".
- A heading that is only a number or a clever line, such as "Section 1" or "The fun part", over content it does not name.
- A `DialogTitle` or `SheetTitle` whose words do not say what the dialog is for, such as "Dialog" or "Details".

<a id="str-003"></a>

## STR-003 Give each view one h1 and every other heading the level its place in the outline gives it

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/str-003/

### Rule

Give each view one `h1` that names its main content. Give every other heading the level its place in the outline gives it: one below the heading it belongs under. Going down never skips a level; going back up may skip as many as needed.

### Why

Screen reader users often start a page by listing its headings, or by jumping to the first `h1` and then from level to level. The levels are their map of the page. One `h1` tells them where the main content starts and what it is. Levels that step down one at a time tell them which part belongs to which. A jump from `h2` to `h4` makes them wonder what they missed, and a view with no `h1`, or with three, gives them no clear place to begin. Whether text is a heading at all is STR-002a, and whether its words describe the part is STR-002b. This guideline only decides the level.

### Our reasons

Fewer than two judges have spoken about heading levels, so the verdict is Insufficient evidence (1 of 3 judges spoke) and this guideline is our choice. Material supports it. So does GOV.UK, an expert witness who does not vote. No WCAG criterion requires it. A second `h1` or a skipped level is not a documented failure. The Working Group's technique for organising a page with headings under 1.3.1 does nest them this way ([G141](https://www.w3.org/WAI/WCAG22/Techniques/general/G141)), and so does its example of `h1` to `h6` ([H42](https://www.w3.org/WAI/WCAG22/Techniques/html/H42)). We follow it for three reasons.

- **The levels are a map only if they are kept.** People who move by level trust that an `h3` belongs to the `h2` above it. A level picked for any other reason sends them to the wrong place.
- **One start is easier than several.** "Jump to the `h1`" is a quick way into the main content, and it only works when there is exactly one.
- **It is cheap to get right and easy to check.** The level follows from the outline the team already has in mind. A linter or a heading list in the browser shows a gap at once.

### Do

- In the project tool *Ridgeway*, the view *Project settings* has one `h1`, *Project settings*. Its sections *Members*, *Billing address* and *Delete project* are `h2`. Inside *Members*, the parts *Pending invitations* and *Current members* are `h3`.
- Put the product name in the app shell's header as plain text or a link to the start page, not as an `h1`. The `h1` sits in each view, inside `main`, as STR-004 describes.
- On a dashboard, the section *This week* is an `h2`, and each card in its grid has an `h3` title, one below the section that holds it.
- After an `h4` deep in *Members*, the next section *Billing address* goes back to `h2`. Going back up any number of levels is fine.
- Let a reusable component take its heading level from where it is used. `SettingsSection` accepts `as="h2"` or `as="h3"`, or reads the level from a context the parent sets, so it fits both at the top of a view and nested inside another section.
- When the view shows rich text or Markdown that a user wrote, shift its headings down so its top heading sits below the view's `h1`. A comment's own `#` heading becomes an `h3` inside the section *Comments*, which is an `h2`.
- A dialog is its own context. `DialogTitle` is an `h2`, and that is fine whatever the page behind it uses. It is not a skip, and it need not be an `h1`.
- In the *Ridgeway* shell, the sidebar's list of projects may have its own `h2`, *Projects*. Where that sits in the outline next to the view's `h1` is free.
- The view's `h1` and its title usually say the same thing. The title is STR-001.

### Don't

- Build an app shell where the header shows a logo and every view starts at a `CardTitle` or an `h2`, so no view has an `h1`.
- Put the product name in an `h1` in the shared layout and another `h1` in each view.
- Follow the `h2` *Members* with an `h4` *Pending invitations*, with no `h3` between.
- Hard-code `<h3>` inside `SettingsSection`, so it is one level too deep at the top of a view and right only when nested.
- Show a user's Markdown with its `h1` intact inside a view that already has one.

### Exceptions

- **Content the team cannot change.** A third-party embed, such as a payment form or a map widget, may bring headings whose levels do not fit the view. Fix what you can around it; the embed itself is outside this guideline.
- **Dialogs.** A dialog's heading is outside the page's outline; see Do.
- **A product that chooses otherwise.** This is a guideline. A product that orders its levels another way still marks its headings in code and words them to describe, as STR-002a and STR-002b, both rules, ask.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Render each view and list its headings, with the browser's accessibility tree or `document.querySelectorAll("h1,h2,h3,h4,h5,h6,[role=heading]")`. Is there exactly one `h1`, naming the main content? Leave out headings inside an open dialog.
- A level that steps down more than one, such as an `h2` followed by an `h4` with no `h3` between. Going back up any number of levels, such as from `h4` to `h2`, is fine.
- An `h1` around the product name or logo in a shared layout or app shell, next to the `h1` of each view; or a view that starts at a `CardTitle` or `h2` with no `h1`.
- A reusable section or card component with a hard-coded `<h2>` or `<h3>` that is used at different depths, instead of taking its level from an `as` prop or a context.
- User-written Markdown or rich text rendered with its own `h1` inside a view, with its levels not shifted below the section that holds it. Headings inside a third-party embed are left alone.

<a id="str-004"></a>

## STR-004 Build the page's regions from landmark elements, and name repeated ones apart

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/str-004/

### Rule

Build the page's regions from landmark elements: the main content in `main`, the top bar in `header`, each group of navigation links in `nav` and the bottom bar in `footer`. When a page has more than one `nav`, give each a name that tells them apart.

### Why

A screen reader can list a page's landmarks and jump straight to one, so a person can go from the top bar to the main content in one step instead of passing every link on the way. That only works when the regions are built from landmark elements. A page made of `div`s has no regions to jump to. Two navigation landmarks that are both announced as "navigation" leave the person to try each one to find the menu they wanted.

No WCAG criterion requires landmarks. The Working Group lists them as a sufficient technique ([ARIA11](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA11)) for two criteria. Under [WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) they are one way to make the page's regions readable from the code. Under [2.4.1 Bypass Blocks](https://www.w3.org/TR/WCAG22/#bypass-blocks) they are one of several ways to let people get past blocks that repeat on every page, such as a header and a sidebar ([Understanding 2.4.1](https://www.w3.org/WAI/WCAG22/Understanding/bypass-blocks.html)). A correct `main` is therefore one way to meet 2.4.1, not the only one. A page can meet both criteria without landmarks.

### Do

- In the project tool *Ridgeway*, the app shell is a `header` with the product name and the account menu, a sidebar with a `nav`, the view in `main`, and a `footer` with the links *Help* and *Status*.
- Keep one `main` on each page. In shadcn, `SidebarInset` already renders `main`, so put the view's content inside it and do not add another `main` in the page.
- In shadcn's sidebar blocks, the `header` sits inside `SidebarInset`, so it is part of `main` and not the page's top bar. Move a top bar that spans the product outside `SidebarInset`, or treat the inner `header` as the view's own.
- shadcn's `Sidebar` renders `div`s. Wrap the `SidebarMenu` that holds links in a `nav`.
- The page has a `nav` in the top bar, one in the sidebar and a breadcrumb trail. Name them "Main", "Projects" and "Breadcrumb", with `aria-label` or with `aria-labelledby` pointing to a visible heading. The screen reader adds "navigation" itself, so the name does not repeat it. shadcn's `Breadcrumb` already renders `nav aria-label="breadcrumb"`, so it needs no wrapper of its own.
- A sign-in page with no header still puts its form in `main`.
- A chat panel docked beside the view is an `aside` with a name, such as "Team chat".
- Our own advice: name any other landmark that appears more than once too, such as two `aside`s or two named `section`s, so each can be told apart.
- Our own advice, which [ARIA11](https://www.w3.org/WAI/WCAG22/Techniques/aria/ARIA11) also suggests: put all content inside some landmark, so a person moving by landmark misses nothing. The skip link is the one exception: NAV-004 keeps it on its own before the regions.
- A skip link is a second route past the repeated blocks, for people who use a keyboard without a screen reader. It is outside this rule; NAV-004 is our guideline for it.
- Use the native elements. `role="main"` on a `main` element does no harm, but it adds nothing.
- A search form may use the `search` element or `role="search"`. That is optional.
- Name a `section` only when it is a region people will want to jump to, such as *Activity* on a project page. A named `section` becomes a landmark; one without a name does not.

### Don't

- Build the shell as `<div className="flex min-h-screen">` with a `div` for the top bar, a `div` for the sidebar and a `div` for the content.
- Add `<main>` inside a page that is already rendered inside `SidebarInset`, so the page has two.
- Put the view's content beside `SidebarInset` instead of inside it, so it falls outside `main`.
- Leave the top bar's `nav` and the sidebar's `nav` without names, so both are announced as "navigation" and nothing else.
- Name a `nav` "Main navigation nav" or "Sidebar navigation menu".
- Give every `section` on the page an `aria-label`, so the landmark list fills up with regions nobody jumps to.

### Exceptions

- **Header and footer inside content.** A `header` or `footer` inside an `article` or a `section` belongs to that part and is not the page's top or bottom bar. That is correct HTML. Only the ones at the top level of the page become its banner and its footer landmark.
- **Dialogs.** A dialog is not a landmark. While it is open it sits outside the page's `main`.
- **Not covered here.** The order of regions in the code is LAY-002. The `h1` inside `main` is STR-003.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Render the page and list its landmarks. Is there exactly one `main`, and is the view's content inside it? shadcn's `SidebarInset` already renders `main`, so a page inside it adds no second one, and content beside it falls outside.
- An app shell built from `div`s, such as `<div className="flex min-h-screen">`, with no `header`, `nav`, `main` or `footer` for its top bar, link groups, content and bottom bar. A `header` or `footer` inside an `article` or `section` is not the page's bar.
- A shadcn `SidebarMenu` of links inside `Sidebar` with no `nav` around it.
- More than one `nav` on the page, such as in the top bar, the sidebar and a breadcrumb, where one has no `aria-label` or `aria-labelledby`, or two have the same name. shadcn's `Breadcrumb` is already named.

<a id="str-005"></a>

## STR-005 Give images and icons that carry information a text alternative, and hide the ones that only decorate

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-005/

### Rule

Give an image or icon that carries information a text alternative that says what it tells the person in that place, never a file name or a word that only names the kind of picture. Hide one that only decorates from assistive technology, with `alt=""` on an `img` or `aria-hidden="true"` on an icon.

### Why

A screen reader cannot see a picture. It reads the text the picture carries in code, and nothing else. A red icon that marks an invoice as overdue says "overdue" to a sighted person; with no text alternative, a screen reader user never learns it. The opposite fails too. An icon that only repeats the word beside it, read aloud as "image" or as a file path, wastes the person's time on every line of a list and buries what matters.

This is a requirement. [WCAG 2.2, 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG22/#non-text-content) asks that anything shown as other than text comes with text that does the same job, and that pure decoration is built so assistive technology can ignore it ([Understanding 1.1.1](https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html)). The Working Group lists as failures an alternative that is only a file name or a placeholder word ([F30](https://www.w3.org/WAI/WCAG22/Techniques/failures/F30)), and a decorative image given any alternative other than an empty one ([F39](https://www.w3.org/WAI/WCAG22/Techniques/failures/F39)). Its technique for hiding an `img` is an empty `alt` and no `title` ([H67](https://www.w3.org/WAI/WCAG22/Techniques/html/H67)). Whether an image is decorative is the author's judgement from why it is there. Ask what a screen reader user would miss if the image said nothing. If the answer is nothing, it decorates.

### Do

- In the invoice list of the bookkeeping app *Fernhill*, an overdue invoice shows a red clock icon and no text. The icon carries the status, so the SVG has `role="img"` and `aria-label="Overdue"`, or a visually hidden `span` with "Overdue" sits beside it. Better still, our own choice: show the word *Overdue* next to the icon and hide the icon.
- A `Badge` reads *Paid* with a tick icon before the word. The icon adds nothing to the word, so it has `aria-hidden="true"`.
- The adapter's icons (`adapters/shadcn/src/lib/icons.tsx`) set `aria-hidden="true"`. With any other icon library, check what it does before relying on it, and give the icon a name when it alone carries meaning.
- A customer's `AvatarImage` sits next to their name, *Lena Okafor*. The name is already there, so `alt=""`. In a row of avatars with no names beside them, each `alt` is the person's name.
- A bar chart of monthly revenue has a short alternative, such as "Revenue rose each month from January to June", and the figures in a table or a sentence nearby. The figures do not go into `alt`.
- With `next/image`, `alt` is required. Write what the image tells, or `alt=""` when it decorates; never the component's or the file's name to make the type error go away.
- Our own choice: keep an alternative to one or two short sentences, and do not start it with "Image of" or "Picture of". The screen reader already says it is an image.
- Our own choice: do not repeat in `alt` the caption or heading right beside the image. When nearby text already says what the image tells, `alt=""` is right.
- Avoid images of text; [WCAG 2.2, 1.4.5 Images of Text](https://www.w3.org/TR/WCAG22/#images-of-text) covers when they are allowed. When one is used, its alternative holds the same words.
- A spinner beside "Saving invoice …" is decorative; the text says what is happening, as STA-005a asks.
- An emoji that carries meaning in a label, such as a warning sign, needs words that say what it means. One that only decorates is hidden in a `span` with `aria-hidden="true"`.

### Don't

- Write `<img src={url} />` with no `alt` at all. Many screen readers then read the file name or the address.
- Write `alt={file.name}`, `alt="logo"`, `alt="hero"` or `alt="screenshot"`.
- Hide the overdue icon with `aria-hidden="true"` when nothing else on the row says the invoice is overdue.
- Give a decorative divider image `alt="decoration"` instead of `alt=""`.
- Give an `AvatarImage` `alt="Avatar"`.
- Show information as a CSS background image. A background image cannot carry a text alternative.

### Exceptions

- **Icon buttons.** An icon that is itself a button, or the only content of one, is named as ACT-001b says, after what pressing it does.
- **Image links.** An image or icon that is itself a link, or its only content, is named as TXT-003 says, after where it goes.
- **Flags in a language picker.** A flag that is the only label of a language needs a text alternative under this rule. The language name beside it, and the `lang` it carries, are STR-006a.
- **Loading signs.** How a wait is announced is STA-005a and FBK-004. This rule only says the spinner graphic itself is decorative when text says what is happening.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `img`, a Next.js `Image` or a shadcn `AvatarImage` with no `alt` prop.
- An `alt` that is a file name or only names the kind of picture, such as `alt={file.name}`, `alt="logo"`, `alt="image"`, `alt="hero"`, `alt="screenshot"`, `alt="Avatar"` or `alt="decoration"`.
- An inline `svg`, or an icon from a library that does not hide it by default, with neither `aria-hidden="true"` nor a name such as `role="img"` with `aria-label`. Icons that are a button's or link's only content follow ACT-001b and TXT-003.
- An icon with `aria-hidden="true"` that is the only sign of a status, such as a red clock marking an overdue invoice with no word beside it. Ask what a screen reader user would miss.
- Information shown only as a CSS background image, such as a `bg-[url(...)]` class or `style={{ backgroundImage }}`, with no text nearby that says the same.

<a id="str-006"></a>

## STR-006 Name the page's main language in the lang attribute on the html element, and change it when the interface changes language

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-006/

### Rule

Put a `lang` attribute on the `html` element whose value is a valid language tag for the language most of the page is written in. When the interface switches to another language without loading a new page, change the attribute to that language at the same time.

### Why

A screen reader picks its voice and pronunciation from the page's language. When an app written in German says `lang="en"`, every word is read with English rules, and the person hears something close to noise. Braille software, browser translation, spell checkers and font selection lean on the same value. With no attribute at all, each tool falls back to its own default, which may not be the page's language.

This is a requirement. [WCAG 2.2, 3.1.1 Language of Page](https://www.w3.org/TR/WCAG22/#language-of-page) asks that software can tell the default human language of each page ([Understanding 3.1.1](https://www.w3.org/WAI/WCAG22/Understanding/language-of-page.html)). In HTML the Working Group's technique is `lang` on the `html` element, with a valid tag that matches the main language ([H57](https://www.w3.org/WAI/WCAG22/Techniques/html/H57)). A single page app is one web page while it runs, so when its interface turns into another language in place, its main language has changed and the attribute has to follow. That is the criterion read for single page apps, as STR-001 reads 2.4.2 for titles, not something we add. Parts of the page in another language are STR-006a.

### Do

- The booking app *Larkspur* is built in English and also offered in Polish, Portuguese and Korean. Its root layout renders `<html lang={locale}>`, so the English view says `lang="en"`, the Polish one `lang="pl"`, the Portuguese one `lang="pt"` and the Korean one `lang="ko"`.
- With the Next.js App Router and a locale segment, read the locale from the route params in `app/[locale]/layout.tsx` and pass it to `html`. With the Pages Router's built-in `i18n` config, Next.js sets the attribute per locale; a custom `_document.tsx` must not hard code one.
- With react-i18next, Lingui or your own context, set `document.documentElement.lang` whenever the language changes, for example in the `languageChanged` handler or in an effect that depends on the current locale. When the page is rendered on the server, render the right value there too, so the first paint already names the language.
- Change the starter template's `lang="en"` when the product's interface is in another language. Vite and `create-next-app` both ship it.
- Use hyphens, as language tags do: `en-GB`, `pt-BR`. An id with an underscore from an i18n library or a back end, such as `en_US` or `sv_SE`, is converted first. A region part is allowed but not required; `en` is enough.
- Use the language code, not a country code: `sv` is Swedish, `se` is Northern Sami, and `uk` is Ukrainian.
- A visa form shows every label in English and, beneath it, in French. Both carry the same amount of text and English comes first, so `html` says `lang="en"` and each French line is marked as STR-006a says. Had French carried most of the page, `html` would name French.
- Our own advice, not part of 3.1.1: for a right-to-left language, set `dir="rtl"` on `html` at the same moment. Tailwind's `rtl:` variant and CSS logical properties follow the attribute. Radix based shadcn parts do not read it: wrap the app in Radix's `DirectionProvider`, or give each part a `dir` prop, with the same value.
- Our own advice: keep the current locale in one place, so `lang`, the page title (STR-001) and date and number formatting cannot drift apart.

### Don't

- Ship an app whose interface is in Polish with `<html lang="en">` left from the template.
- Render `<html>` with no `lang`, or with `lang=""`.
- Write `lang="en_US"`, `lang="english"` or `lang="cn"`.
- Switch every string to Portuguese when the person picks *Português*, and leave `lang="en"` on `html`.
- Put `lang={locale}` on a `div` around the app instead of on `html`. The `title` and everything else in `head` stay outside it. So does a shadcn `Dialog`, `Sheet`, `Popover`, `DropdownMenu`, `Select` or `Tooltip`, which renders in a portal at the end of `body`, and a Sonner `Toaster` mounted outside the wrapper, as root layouts often do. All of them fall back to whatever `html` says.
- Rely on the HTTP `Content-Language` header alone. It does not replace the attribute.

### Exceptions

- **Parts in another language.** This rule covers only the root. A quotation, an entry in a language picker or any other passage in another language is STR-006a.
- **Linked pages.** `lang` names the language of this page, not of the pages it links to. A link's target language is what `hreflang` is for.
- **XHTML.** `xml:lang` is needed only for pages served as XML. An HTML page needs only `lang`.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `html` element in `index.html`, the root `layout.tsx` or `root.tsx` with no `lang`, `lang=""`, or a value that is not a valid language tag, such as `en_US`, `english` or `cn`. In `_document.tsx`, an `Html` with no `lang` only when `next.config` has no `i18n`.
- A root layout under `app/[locale]/` that renders a literal `lang="en"` instead of the locale from the route.
- A call to `i18n.changeLanguage`, `setLocale` or a similar switch in a project where nothing updates `lang` on `html`. These count: a React-rendered `html` with `lang` from the current locale, `document.documentElement.lang` or `setAttribute("lang", …)`, and a head manager's `htmlAttributes`.
- String literals in JSX mostly in one language while `lang` on `html` names another, such as a German app that kept the starter template's `lang="en"`.
- `lang={locale}` on a wrapper around the whole app, such as the child of `body` in the root layout or a provider that wraps `{children}`, while `html` has none or names another language.

<a id="str-006a"></a>

## STR-006a Mark text in another language than the text around it with its own lang attribute

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/str-006a/

### Rule

When a passage, phrase or word is in another language than the text around it, put `lang` with that language's tag on the element that holds it, such as language picker entries written in their own languages. Proper names, technical terms, words of unclear language and words the surrounding language has taken in need none.

### Why

A screen reader reads everything in the page's language unless the code says otherwise. In an English page, an unmarked "Português" is read with English sounds, and a quoted paragraph in Spanish comes out as a string of wrong syllables. The person may not even notice that the language changed, only that the text makes no sense. Browsers use the same marking to choose glyphs: Chinese, Japanese and Korean characters take different shapes depending on the declared language.

This is a requirement. [WCAG 2.2, 3.1.2 Language of Parts](https://www.w3.org/TR/WCAG22/#language-of-parts) asks that software can tell the language of each passage or phrase, with the four exceptions this rule names ([Understanding 3.1.2](https://www.w3.org/WAI/WCAG22/Understanding/language-of-parts.html)). The Working Group's technique is `lang` on the element whose content is in the other language, with a valid tag ([H58](https://www.w3.org/WAI/WCAG22/Techniques/html/H58)). Text with no marking takes its language from the elements around it and, in the end, from `html` (STR-006), so a page in one language meets this rule with no extra work. *Café* on an English menu is English, and so is *déjà vu* in an English review; only a deliberate switch to French is marked.

### Do

- The booking app *Larkspur* is in English and offers Polish, Portuguese and Korean. Its language picker is a shadcn `DropdownMenu` built from `{ code, label }` entries. Each `DropdownMenuItem` reads *Polski*, *Português* or *한국어* and has `lang={code}`. Where an item is a link to that language's version, it also has `hreflang={code}`.
- Mark the current language's entry and the picker's trigger too, whenever they show a language name that is not the page's own. In the English view, *English* needs nothing; in the Polish view, it gets `lang="en"`.
- When the whole label is in that language, put `lang` on the element that holds it, such as the `a` or the `DropdownMenuItem`, not on a `span` inside it. A screen reader that reads a control's name may lose a language change inside it.
- In an item that mixes two languages, such as *Polski (Polish)* in an English page, mark only the part that differs: `<span lang="pl">Polski</span> (Polish)`. A label in one language is simpler.
- On the page *Reviews*, a guest's review in Spanish sits in a `blockquote lang="es"`. An English phrase inside it switches back with its own `lang="en"`.
- When content comes from data that records its language, such as a product description shown in French because no English translation exists yet, put that language on the element that shows it. If the language is not known, do not guess; leave the text unmarked.
- When a part is marked with `lang` and its menus or dialogs render in a portal, put `lang` on the portalled content as well, or on the text itself.
- Our own advice, not part of 3.1.2: write each entry in the language picker in its own language, *Polski* and not *Polish*, so a person who cannot read the current interface still finds theirs. Also our own advice: a flag may sit beside the name, never replace it. A flag that carries meaning needs a text alternative (STR-005).
- Our own advice: keep an `aria-label` in the same language as its element. Its text cannot carry a language of its own, so a name in another language goes in visible text marked with `lang`.
- Our own advice: mark a name or borrowed word when a screen reader would mangle it badly, especially one from another writing system.

### Don't

- Render the picker's entries *Polski*, *Português* and *한국어* in an English page with no `lang` on any of them.
- Rely on `hreflang` alone. It names the language of the page the link leads to, not of the link's own text.
- Use a country code as a language: `se` for Swedish, `uk` for British English or `cn` for Chinese. Swedish is `sv`, British English is `en-GB` and Chinese is `zh`.
- Show an untranslated French description in an English page without marking it.
- Wrap every brand name, product name or code identifier in a `lang` span.

### Exceptions

- **The four in the criterion.** Proper names of people, places, brands and products; technical terms; words whose language cannot be told; and words that have become part of the surrounding language, such as borrowed words found in its dictionaries.
- **The page's main language.** The language of the whole page is set on `html`, as STR-006 says.
- **Neighbouring rules.** The accessible name of a picker's trigger still contains its visible text (ACT-001b). A flag used as the only label needs a text alternative (STR-005). When the picker shows which language is current, say so in code too, for example with `aria-current` on that entry; NAV-002a covers the current page in navigation.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A language picker built from a list such as `{ code, label }` whose `DropdownMenuItem`, `SelectItem`, `CommandItem` or link renders `label` with no `lang` taken from the entry's code, while the labels are written in their own languages.
- Content that can be shown in another language than the page's, rendered with no `lang` from the language its data records: fallback text shown when a translation is missing, user content in mixed languages, or a translation shown beside its original.
- A `lang` value that is not a valid language tag, such as `en_US` or `cn`.
- A `lang` set only on a section wrapper whose menus or dialogs render in a portal outside it, while that portalled content is in the wrapper's language and has no `lang` of its own.

<a id="tbl-001"></a>

## TBL-001 Build data in rows and columns as a table in code, with its headings marked as headers

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/tbl-001/

### Rule

When values are shown in rows and columns under headings, build them as a table in code. Mark each heading cell as the header of its column or row, so assistive technology can tell which headings every value belongs to.

### Why

A sighted person reads a value by glancing up at its column and across to the start of its row. "7.4" means nothing alone; under *pH*, in the row for *Mill Lane footbridge*, it is a reading. A screen reader user gets that meaning only if the code holds the same ties. In a real table, moving from cell to cell, the screen reader says the heading of the new column or row, and the person can move down one column or along one row. A grid of `div` elements styled to look like a table gives them a run of loose numbers instead.

[WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) requires that relationships shown by the layout can also be read from the code. The Working Group lists a data table whose headings are not marked as headers as a failure ([F91](https://www.w3.org/WAI/WCAG22/Techniques/failures/F91)). That failure accepts several ways to pass: header elements, `scope` on the header cells, `headers` and `id` on the data cells, or the ARIA roles for tables and their headers. So the criterion asks that the headers can be found in code. It does not ask for the `table` element, for `th` or for `scope` as such; those are the techniques in [H51](https://www.w3.org/WAI/WCAG22/Techniques/html/H51) and [H63](https://www.w3.org/WAI/WCAG22/Techniques/html/H63). [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) supports the rule: the roles a table exposes are what lets software treat it as one.

### Do

- A council's page *Water samples* lists one row per site, with the columns *Site*, *pH*, *Nitrate (mg/l)* and *Collected by*. It is built with shadcn's `Table`: the headings are `TableHead` cells inside `TableHeader`, and the values are `TableCell` cells in `TableBody`. `TableHead` renders a `th` and `TableCell` a `td`, so the ties are in place.
- Our own advice, beyond the requirement: give each column heading `scope="col"` and render the cell that names the row as a row header, `<TableHead scope="row">Mill Lane footbridge</TableHead>`, styled like the other body cells with `font-normal`. A screen reader then says the site's name as the person moves along its row. The criterion needs a row header only where the first column is what gives the other cells their meaning, which in a data table it usually is.
- With TanStack Table, map each header group to a `TableRow` of `TableHead` cells. Give each one `colSpan={header.colSpan}`, and render `flexRender(header.column.columnDef.header, header.getContext())` inside it, or nothing when `header.isPlaceholder` is true. Map the rows of `table.getRowModel()` to `TableRow` with `TableCell`, or with `TableHead scope="row"` for the column that names the row.
- Give every header cell text, also over a column of checkboxes or row actions. When the column needs no visible heading, put "Select" or "Actions" in an `sr-only` span, so the column still has a name.
- Keep the header row and the body in one table. To keep the headings in view while the body scrolls, let the table scroll in its own area of limited height and make `TableHeader` sticky with `sticky top-0 bg-background`. shadcn's `Table` wraps the `table` in a `div` with `overflow-x-auto`, so a sticky header there sticks to that `div`, not to the page. Give that wrapper a limit such as `max-h-96` and `overflow-auto` in your copy of `table.tsx`; the `className` you pass to `Table` goes to the `table`, not to the wrapper.
- When a group heading spans several columns, such as *Nitrate (mg/l)* over *Upstream* and *Downstream*, plain `th` is not enough. Use `scope="colgroup"` on the group heading or tie each cell to its headings with `headers` and `id`.
- Leave an empty value as a cell, so the columns stay in line in code. Our own advice: write "Not measured" or a dash, which is read as text, rather than leaving the cell blank.
- If the table is too wide for a narrow screen, give it its own scroll area as LAY-001 says, and keep the table structure inside it. shadcn's `Table` already renders a scrolling wrapper, but with no `tabIndex`, role or name, so add the focus and the name LAY-001 asks for in your copy of `table.tsx`.
- If a narrow layout turns each row into a card, put the heading text next to each value in the card's markup, such as "pH: 7.4", so each value still carries its label. Our own advice: do not rely on text added with CSS `content` for this, since screen readers do not all read it.
- A table built from `div` elements with `role="table"`, `role="row"`, `role="columnheader"`, `role="rowheader"` and `role="cell"` meets the criterion too. Our own advice is to use the native elements, which shadcn's `Table` already renders: one wrapper without its role breaks the whole ARIA structure, and the native one cannot break that way.
- In a long table that renders only the rows in view, our own advice is to set `aria-rowcount` on the table and `aria-rowindex` on each row, so a screen reader can say where in the full list the person is.

### Don't

- Build the *Water samples* grid from `div className="grid grid-cols-4"`, with the heading row as one more `div` in `font-medium text-muted-foreground`.
- Render the TanStack header group as a `TableRow` of `TableCell`, so every heading is a `td`.
- Put the headings in one `Table` above a second, scrolling `Table` for the body, so no value is tied to its heading.
- Leave the header cell over the row checkboxes empty.
- Set `display: block` or `display: flex` on `table`, `tr` or `td` to make the table fit a phone. Some browsers then drop the table semantics.
- Use a table to lay out a form or a page. A table for layout has no `th` and no `caption`.
- Turn rows into cards on a phone and drop the headings, leaving "7.4", "12" and "R. Okafor" with nothing to say what they are.

### Exceptions

- **Content that is not a grid of values.** A set of cards in which every value carries its own visible label, such as "Collected by R. Okafor", already holds the tie in its text and is outside this rule. Choosing a table or cards is not part of it.
- **One record.** Labels beside the values of a single record can be a description list (`dl`) or a two-column table with row headers. Both meet the criterion.
- **Interactive grids.** A grid that people edit in place and move through with the arrow keys has its own roles and keyboard model, and this rule does not cover it.
- **Neighbouring rules.** Sorting by a column is TBL-002, actions in a row are TBL-003 and the table's title is TBL-004. Reflow is LAY-001, the order of the columns in code is LAY-002, and the names of controls inside cells, such as a checkbox on each row, are FRM-010.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Values in rows and columns under headings built from `div`s, such as `grid grid-cols-4` with a heading row in `font-medium`. Is it a table of values? Cards whose values each carry a visible label, and a full set of ARIA table roles, are left alone.
- A header row rendered with `TableCell` or `td` instead of `TableHead` or `th`, such as a TanStack header group mapped to `TableCell`.
- A `TableHead` or `th` with no text, such as over a column of checkboxes or row actions. Text in an `sr-only` span counts.
- The headings in one `Table` and the body in a second `Table` below it, often to keep the headings in view while the body scrolls.
- `display: block` or `flex` (classes such as `block` or `flex`) on `table`, `tr`, `th` or `td`, or a narrow card layout that drops the heading text beside each value.

<a id="tbl-002"></a>

## TBL-002 Put a keyboard sort control in a sortable header, and expose its order in code

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/tbl-002/

### Rule

When a column's header sorts the table, make the sort a button or link inside the header cell that works from the keyboard. Expose the sorted column's order in code, ascending or descending, so the direction is never shown by an arrow icon alone.

### Why

A heading that sorts when clicked is a control, even if it looks like text. A keyboard user cannot reach a header cell with a click handler, and a screen reader announces it as a column heading, not as something to press. And when an arrow is the only sign of the order, a person who cannot see it does not know whether the fastest runner is at the top or the bottom.

Three criteria make this a requirement. [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) asks that sorting works from the keyboard. [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) asks that the control has a role and a name in code. [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) asks that what the arrow tells sighted people is in the code too. A button or link inside the `th` meets the first two and keeps the cell a header, which TBL-001 needs. The order can be given with `aria-sort` on the sorted column's `th`, or as text inside the control. The criteria do not choose between them. [1.1.1 Non-text Content](https://www.w3.org/TR/WCAG22/#non-text-content) supports the rule: an arrow that shows the order carries information, and once the order is in code, the arrow is decoration and needs no text of its own. The criteria do not ask that sorting is offered in the header at all; a product can offer it elsewhere, such as in a *Sort by* select.

### Do

- A club's page *Spring 10k results* has the columns *Runner*, *Club*, *Finish time* and *Age group*. *Club* and *Finish time* can be sorted. Each of their `TableHead` cells holds a shadcn `Button variant="ghost"` with the heading as its text and an icon after it. *Runner* and *Age group* hold plain text. Using a `button` rather than a link is our own choice; a link that loads the sorted page, such as `?sort=time`, meets the rule too.
- With TanStack Table, set `aria-sort` on the `TableHead` from `header.column.getIsSorted()`: `"asc"` gives `aria-sort="ascending"`, `"desc"` gives `"descending"`, and `false` gives no attribute. Put `onClick={header.column.getToggleSortingHandler()}` on the button, not on the cell. Our own advice: use `aria-sort` rather than text in the button, so the button's name stays "Finish time" whatever the order.
- Set `aria-sort` on one column at a time, and remove it from a column when another one is sorted.
- The page opens sorted by *Finish time*, fastest first. That column already has `aria-sort="ascending"` and an up arrow when the page loads.
- Our own advice: change the icon with the state, such as lucide's `ArrowUp` for ascending, `ArrowDown` for descending and `ArrowUpDown` for a sortable column that is not sorted. Give the icon `aria-hidden="true"`, since `aria-sort` already carries the order.
- If a third press clears the sort, remove `aria-sort` and show the unsorted icon again. Whether the product offers that third press is its own choice.
- Our own advice: keep focus on the same button while the rows re-render, so the next Enter reverses the order and the next Tab goes on from there. Keep a stable `key` on the header cells, so React does not replace the button that has focus.
- Our own advice, beyond the rule: say the new order in a status message, such as "Sorted by finish time, fastest first", as FBK-004 describes.
- When a narrow layout turns the table into a list, offer the sort as a select with the visible label *Sort by* (FRM-001). Its chosen value then shows and exposes the order.

### Don't

- Put `onClick` on the `TableHead` or on a `div` inside it, so the sort works only with a pointer.
- Give the `th` itself `tabIndex={0}` and `role="button"`. The cell stops being a header, and TBL-001 is broken.
- Show the same `ArrowUpDown` icon on *Finish time* whether it is sorted or not, with no `aria-sort`.
- Give the button the `aria-label` "Sort by finish time". This is our own advice: the name contains the visible words, so ACT-001b is met, but it adds an instruction that is read out on every visit while `aria-sort` already says how the column is sorted. Keep the name to the visible heading.
- Put `aria-sort` on the button instead of the header cell.
- Rebuild the header row after each sort so focus drops to the start of the page.

### Exceptions

- **A sortable column that looks plain at rest.** The rule does not ask that a column that can be sorted shows it before the person hovers or focuses it. Showing a sign at rest is a design choice. Once a column is sorted, its state shows and is in code.
- **Several sort columns at once.** Sorting by more than one column at once is outside this rule.
- **Neighbouring rules.** The header cells themselves are TBL-001. Keyboard operation and the focus indicator in general are KBD-001, and this rule is the table case with the state added. The button's role is ACT-009, its name ACT-001b, and an announcement of the new order is FBK-004.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `onClick` that sorts on a `TableHead`, a `th`, or a `div` or `span` inside it, such as `onClick={header.column.getToggleSortingHandler()}` on the cell, with no `button` or link holding the handler.
- A `th` or `TableHead` given `tabIndex={0}` or `role="button"` to make it sortable.
- A sortable table where no `TableHead` sets `aria-sort` from the sort state, such as from `header.column.getIsSorted()`, and the sort control's text does not say the order either, so an arrow icon is the only sign.
- `aria-sort` on the sort `button` instead of the header cell, or on more than one column at once unless the table sorts by several columns together (see Exceptions).

<a id="tbl-003"></a>

## TBL-003 Give every row action its own control the keyboard reaches, and show hidden actions on focus

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/tbl-003/

### Rule

Give every action a table row offers its own control the keyboard reaches, such as a link, a button or a menu item. A click on the row may be a shortcut, never the only way. An action hidden until the pointer hovers the row is visible whenever it has focus.

### Why

KBD-001 already asks that the keyboard can do everything the pointer can, and that focus can be seen. This rule is that rule applied to table rows, because two patterns there break it so often. The first is a row that opens its record on click and has no link or button: a keyboard user cannot open the record at all. The second is a cell of buttons that appears only on hover: a keyboard user can tab onto the buttons but cannot see them, and does not know what Enter will do.

The law decides both. [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard) is not met when an action works only through a pointer event; the Working Group lists pointer-only handlers as a failure ([F54](https://www.w3.org/WAI/WCAG22/Techniques/failures/F54)). [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) is not met when a scripted element acts as a control without the role of one, and a row that opens its record on click acts as a link; the failure for links emulated with event handlers covers it ([F42](https://www.w3.org/WAI/WCAG22/Techniques/failures/F42)). Both failures allow a pointer handler when the same function is also offered in a way that meets the criterion, which is why a row click may stay as a shortcut. [2.4.7 Focus Visible](https://www.w3.org/TR/WCAG22/#focus-visible) is not met when a control has focus while it cannot be seen. [1.4.13 Content on Hover or Focus](https://www.w3.org/TR/WCAG22/#content-on-hover-or-focus) supports the rule where a hover opens a popover of actions; TXT-002a covers that case. The criteria do not forbid hiding actions from pointer users at rest, and neither does this rule.

### Do

- A helpdesk's table *Open tickets* has the columns *Ticket*, *Requested by*, *Priority* and *Actions*. The ticket's title in the first cell, such as *Printer on floor 3 jams*, is a link (`<a href>` or Next `Link`) to the ticket. *Assign* and *Close ticket* are buttons in the last cell, which also comes last in the code (LAY-002).
- Add a click on the row as a shortcut to the same ticket if you want one. Let the handler ignore clicks that start on a control, for example by returning when `event.target.closest("a, button, input, label")` is set, and when the person has selected text.
- When the actions show only on hover, show each one when it has focus. With Tailwind, put the hiding classes on each button, not on the cell: `opacity-0 group-hover:opacity-100 focus-visible:opacity-100`, where the `TableRow` has the class `group`. A button inside a cell that is itself at `opacity-0` stays invisible whatever its own classes say. Our own advice, which goes further: add `group-focus-within:opacity-100` to the buttons as well, so all the row's actions are on screen while any control in the row has focus, and the person sees what is coming before tabbing onto it.
- Our own advice, beyond the rule: keep the actions on show at rest. If you hide them, show them always on screens without hover, for example with `[@media(hover:none)]:opacity-100`, since a phone has no hover to reveal them.
- With more actions than fit, put them in a `DropdownMenu` on each row. Give its icon-only trigger a name as ACT-001b asks. Our own advice: include the row in it, such as "Actions for Printer on floor 3 jams", so the triggers on different rows can be told apart.
- A checkbox to select the row stops the click from reaching the row's handler, with `onClick={(e) => e.stopPropagation()}`, so ticking it does not open the ticket. Its name is FRM-010's.
- Keep every action button at least 24 by 24 CSS pixels in a dense table, as ACT-006 asks.
- When *Close ticket* removes the row, offer *Undo* as DST-001a says.

### Don't

- Give `TableRow` an `onClick` that opens the ticket and `cursor-pointer`, with no link in the row.
- Put `role="link"` on the `tr`. The row stops being a row, and its name becomes the text of every cell.
- Put `tabIndex={0}` on the `tr` and handle Enter. The row takes focus but has no control role, so a screen reader does not say it can be activated, and 4.1.2 is still not met.
- Wrap the whole row in an `a`, which is not valid inside a table, or stretch a link over a row that also holds buttons, so it covers them.
- Hide the action cell with `opacity-0 group-hover:opacity-100` and nothing for focus, so a keyboard user tabs onto *Close ticket* without seeing it.
- Render the buttons only while `onMouseEnter` has set a state, so they are not in the page at all for a keyboard user, unless the actions are offered elsewhere.
- Name every row's menu trigger "Open menu".

### Exceptions

- **Actions offered elsewhere.** An action that is also offered on the record's own page, which the row's link reaches, need not be in the row. The row's link must still be there.
- **The keyboard in general.** Keyboard operation and the focus indicator are KBD-001. This rule adds nothing to it beyond the table case.
- **Neighbouring rules.** Where a row's buttons sit is ACT-003b, their names ACT-001b, their size ACT-006, the selection checkbox's name FRM-010 and Undo after a removal DST-001a. Tooltips are TXT-002b. The table's structure is TBL-001. That the row's link and buttons have a control role, and the row none, is ACT-009 in general.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `onClick` on `TableRow` or `tr`, often with `cursor-pointer`, where no cell in the row holds an `a`, `Link` or `button` for the same action. With TanStack, look in the column definitions too: `flexRender` often renders the link there.
- `role="link"`, `role="button"`, or `tabIndex={0}` with an `onKeyDown`, on a `tr` or `TableRow`.
- Row actions hidden with `opacity-0` and `group-hover:opacity-100` with no focus class such as `focus-visible:opacity-100` or `group-focus-within:opacity-100` on each control. Hiding classes on the cell hide its buttons whatever their own classes say.
- Row actions rendered only while state set by `onMouseEnter` or `onPointerEnter` is true, unless the same actions are on the record's own page that the row's link reaches.
- An `a` wrapped around a whole `tr`, or a link stretched over the row, such as with `absolute inset-0`, while the row also holds buttons.

<a id="tbl-004"></a>

## TBL-004 Give every data table a visible title and tie it to the table in code

Guideline, our choice. Verdict: Insufficient evidence (1 of 3 judges spoke). Status: proposed. https://blackwoodblake.com/design-system/patterns/tbl-004/

### Rule

Give every data table a visible title that says what its rows have in common. Tie that title to the table in code, as its `caption` or through `aria-labelledby`.

### Why

A table without a title starts with its headings, and the person has to read a few rows to work out what it is about. With two tables on a page, they also have to work out which one they are in. A screen reader user often lists the tables on a page or jumps from one to the next; without a name, each one is announced as just "table".

No WCAG criterion asks that a table has a title. When it has one, [WCAG 2.2, 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) asks that the title is in code as what it looks like, such as a heading or a caption. A heading just above the table already meets that. Using the title as the table's name, with the `caption` element as in [H39](https://www.w3.org/WAI/WCAG22/Techniques/html/H39) or with `aria-labelledby`, is part of our guideline, not something the criterion asks. [2.4.6 Headings and Labels](https://www.w3.org/TR/WCAG22/#headings-and-labels) asks that a title, once there, describes what it heads. [4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) and LAY-001 ask for a name on a scroll area that takes focus; the same title can name it.

### Our reasons

Only Carbon of the three judges has spoken, so the verdict is Insufficient evidence (1 of 3 judges spoke), and this guideline is our choice. Carbon supports it, and so does GOV.UK, an expert witness who does not vote. Asking for a title on every data table, and not only tying one where it exists, is our choice too. We make it for three reasons.

- **One set of words serves everyone.** The title a sighted person reads above the table is the name a screen reader says on arrival. Nobody has to keep a hidden name and a visible one in step.
- **Tables can be told apart.** In a list of the page's tables, each one says what it holds, so the person can go straight to the one they want.
- **It costs little.** The page usually has a heading over the table already. Tying it in code is one attribute.

### Do

- A warehouse dashboard has two tables. The first has the title *Stock below reorder level*, put in shadcn's `TableCaption`. The second has the title *Deliveries expected this week*. A screen reader's list of tables then reads both titles.
- shadcn's `Table` places the caption under the table in muted text. To use it as the title, show it above the table, for example with `className="caption-top mt-0 mb-2 text-left text-base font-semibold text-foreground"` on `TableCaption`.
- When the title is already a heading above the table, such as an `h2` with `id="deliveries-title"` inside `CardTitle`, give the `Table` `aria-labelledby="deliveries-title"` instead of a second, matching caption. The heading markup itself follows STR-002a.
- When a table is the only content of the page *Returns waiting for inspection*, the page's `h1` can be its title through `aria-labelledby`. No second visible title is needed.
- Keep a short note such as "Counted at 06:00" next to the title. Our own choice: tie it to the table as a description with `aria-describedby`, or put it in the caption after the title.
- When a filter narrows the rows, keep the title and show a line such as "Showing 12 of 230 items" next to it. If that line changes while focus stays on the filter, announce it as FBK-004 says.
- When the table sits in its own scroll area under LAY-001, use the same title to name that area, for example with `role="region"`, `tabIndex={0}` and `aria-labelledby`. shadcn's `Table` passes its props to the `table`, not to its scroll wrapper, so add these in your copy of `table.tsx` or on an outer wrapper.

### Don't

- Show *Stock below reorder level* as a heading above the table with nothing in code that ties the two.
- Give the table an `aria-label` that differs from the visible title, such as "Inventory grid" under the heading *Stock below reorder level*.
- Give two tables on one page the same title, so they cannot be told apart, or none, so both are announced as "table".
- Write a caption that repeats the column headings, or one such as "Table of data".
- Keep shadcn's sample caption as a footnote under the table while the real title sits in a heading that is not tied to it.

### Exceptions

- **No visible title.** Where the design truly has no room for one, an `aria-label` on the table that says what its rows have in common is the fallback. It meets less of this guideline, since only screen reader users get the title.
- **Tables for layout.** A table used only to lay out a page gets no `caption`; TBL-001 covers when a table is a data table.
- **A product that chooses otherwise.** This is a guideline. A table that has a visible title still marks it in code as a heading or caption, which is what 1.3.1 asks. Tying it to the table as its name is our guideline.
- **Neighbouring rules.** The table's headers are TBL-001, the heading markup over it is STR-002a, and its scroll area is LAY-001.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A data `Table` or `table` with no `TableCaption` or `caption` inside and no `aria-labelledby` or `aria-label` on it. Tables used only for layout are left alone.
- A heading right above a table, such as an `h2` inside `CardTitle`, with no `id` that the table's `aria-labelledby` points to and no `caption` in the table.
- An `aria-label` on a table that differs from the visible title shown above it, such as "Inventory grid" under *Stock below reorder level*. An `aria-label` alone is the fallback only where the design has no visible title.
- A title that does not say what the rows have in common, such as "Table of data" or a list of the column headings, or two tables on one page with the same title.

<a id="txt-001a"></a>

## TXT-001a Say what went wrong, what it concerns and what to do next

Rule. Verdict: Unanimous (3 of 3). Status: decided. https://blackwoodblake.com/design-system/patterns/txt-001a/

### Rule

Every message about a problem says in plain words what went wrong, names the thing it concerns by the name the person sees, and gives a next step: the fix when it is known, otherwise a retry, a wait or where to get help.

### Why

A problem stops people in the middle of a task. If the message only says that something failed, they have to guess what broke, where, and whether their work is lost, and some give up. A message that names the thing and the way forward lets them carry on. When a value someone entered is caught automatically, much of this is what [WCAG 2.2, 3.3.1 Error Identification](https://www.w3.org/TR/WCAG22/#error-identification) and [3.3.3 Error Suggestion](https://www.w3.org/TR/WCAG22/#error-suggestion) ask for. Those criteria do not reach a server that does not answer, a session that has expired or a missing permission. Asking the same of every problem message is our design choice.

### Do

- A receipt is too large to upload. Write "The file *receipt-march.pdf* is 18 MB. Upload a file of 10 MB or less." It names the file, says what is wrong and what to do.
- A field *Start date* holds "3 June". The message "Write the date in numbers, for example 2027-06-03" is enough on its own: the instruction makes the fault plain.
- A message shown at the field, row or panel it concerns, and tied to it in code, names the thing by that place. The *Start date* message above need not repeat the field's name. Anywhere else, name the thing in words.
- A control placed with the message counts as the next step when its label says what it does, such as a button *Try again* or a link *Sign in* right after "This email address already has an account."
- The time slot a person picked was booked by someone else while they filled in the form. Write "The Friday 2:30 pm slot is no longer free. Choose another time below."
- A card payment is declined. Write "Your bank declined the card ending in 4821. You have not been charged. Try another card or contact your bank." Saying whether anything was charged or kept saves people from worry and from doing the work twice.
- Saving a report fails because the service does not answer. Write "The report *Quarter 3* could not be saved. Your changes are still here. Try again in a moment." and add a button *Try again*.
- Give the time when you know it: "Exports are paused for maintenance until 10 pm. Try again after that."
- The person may not delete a project. Write "You cannot delete the project *Spring campaign*. Ask the project's owner for access."
- A code helps support staff, so add it after the plain words: "If this happens again, contact support and give the code B-4031."
- A heading or a count may sit above the specific messages, such as "2 things need fixing" with one line for each field right beneath it.

### Don't

- Show only "Invalid value" at the field *Start date*. A bare verdict says neither what is wrong nor how to fix it.
- Show only a code, such as "B-4031", when a report cannot be saved.
- Use one catch-all line for every fault, such as "That didn't work", when the person needs to know what failed and what it concerns.
- Repeat the field's purpose instead of the fault. A field *Membership number* holds six digits instead of seven, and the message says "Type your membership number". The same words are right when the field is empty.
- Name the thing by an internal name the person never sees: "billing_zip is missing" instead of *Postcode*.
- Stop after the fault: "Payment declined." with no word on what to do next.
- Show the heading "This form has errors" on its own, with no specific lines beneath it.

### Exceptions

- **Sign-in and other security checks.** When naming the exact field would reveal which accounts exist, name the pair and still give a next step: "That member number and PIN do not go together. Check both and try again." A password reset says what happens next without revealing whether the address has an account: "If that address is registered with us, an email will reach you within a few minutes." The same holds where a hint would give away the answer, as in a test.
- **The note next to an unavailable button.** Under ACT-005, that note may only point the person to a field, such as "Check the postcode to continue", as long as the message at that field follows this rule once it appears.
- **Placement and timing.** Where a field's message is shown is set by FRM-002a, when it appears and clears by FRM-002b, and where focus goes when a form is sent with problems by the guideline FRM-011. Problems inside a dialog follow DLG-002. Where a failed action is shown and how long it stays is set by FBK-002, and how a message is announced by FBK-004. This rule covers only the words.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A problem message that is only a verdict or a code, such as "Invalid value", "Error", "Something went wrong" or "B-4031".
- zod's default texts left in place at a field, such as "Required" or "String must contain at least 1 character(s)" in zod 3, or "Invalid input" in zod 4, instead of a message that says what is wrong or what to do.
- A message that names an internal key, such as "billing_zip is missing", or that sits away from its thing, such as in a toast, without naming the file, field or item by its visible name.
- A message that stops after the fault, such as "Payment declined.", with no fix, retry, wait or place to get help in its text or a control beside it. Leave alone sign-in and security messages that name only the pair (see Exceptions).

<a id="txt-002a"></a>

## TXT-002a Let people close, hover and keep content that appears on hover or focus

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/txt-002a/

### Rule

Content that appears on hover or keyboard focus can be closed without moving the pointer or focus, usually with Escape. If hover opens it, the pointer can move onto it without it closing. It stays until the hover or focus that opened it ends, the person closes it, or it is no longer true.

### Why

A tooltip, a hover card or a link preview can cover what the person is reading or about to click. If the only way to get rid of it is to move the pointer, someone who uses a screen magnifier loses their place, and a keyboard user has to Tab away from the control they meant to use. If the content closes as soon as the pointer leaves the trigger, a person who needs a large cursor or high zoom cannot move onto it to read it. If it closes on a timer, slow readers miss it. [WCAG 2.2, 1.4.13 Content on Hover or Focus](https://www.w3.org/TR/WCAG22/#content-on-hover-or-focus) requires all three conditions. Whatever closes the content must itself work from the keyboard, which supports [2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard). TXT-002b covers when a tooltip opens and what it may hold.

### Do

- An icon button with the accessible name "Copy link" shows the tooltip "Copy link" on hover and on focus. Pressing Escape hides the tooltip while focus stays on the button, so the next Enter still copies the link.
- A name in a comment thread, such as *Priya Shah*, opens a hover card with her role and team. The card sits right against the name, so the pointer can slide onto it and rest there while the person reads.
- A link to the document *Budget 2027* shows a preview on hover. The preview stays as long as the pointer is on the link or the preview, however long that takes.
- A meeting in a shared calendar opens a hover card that names the room, *Oak room*. When the organiser cancels the meeting, the card closes, because what it showed is no longer true.
- A short delay before closing, after the pointer has left both the trigger and the content, is fine. It makes the path from trigger to content forgiving.
- When focus opened the content, close it as soon as focus moves on, so it never lingers over the element that now has focus. KBD-002 covers what may hide the focused element.
- Inside a dialog, let the first Escape close only the open tooltip or hover card, and the next one close the dialog, as DLG-001 does for other popups.
- If you use shadcn's `Tooltip` or `HoverCard`, check in your own build that Escape closes the content, that the pointer can reach it without a gap closing it, and that no wrapper or custom delay changes this.

### Don't

- Hide a hover card only when the pointer moves away, with no key that closes it.
- Leave a gap between the trigger and the tooltip, so the content closes on the way there.
- Close a link preview after a fixed number of seconds while the pointer still rests on it.
- Make Escape close the whole dialog while a tooltip inside it is still open.
- Keep a tooltip that focus opened on screen after focus has moved on, so it covers the newly focused field.

### Exceptions

- **Content the browser draws.** A tooltip the browser draws and the author does not restyle, such as the one from the `title` attribute, is not covered. That is no reason to choose it: it does not open on keyboard focus, and under ACT-001b it must not be a button's name.
- **Errors and content that covers nothing.** The need to close without moving does not apply when the content reports an input error, or when it covers nothing that matters, not even its own trigger. It must still be hoverable and stay. FRM-002a already asks for field errors as visible text at the field.
- **Out of scope.** Content opened by a click, a tap or Enter, such as a toggletip, a popover or a menu, is not covered. Neither is an element that is hidden until it gets focus, such as a skip link, or a modal dialog.
- **Not decided here.** Whether content that appears on hover may hold links or buttons is not covered by this rule.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Open each tooltip and hover card by hover and by keyboard focus, press Escape, and see whether it closes while the pointer and focus stay where they are.
- Move the pointer from the trigger onto the content and rest there, and see whether it stays open on the way and for as long as the pointer is on it.
- Hover content built by hand with `onMouseEnter` and `onMouseLeave`, closed when the pointer leaves the trigger alone, with no Escape key handler, or closed by a `setTimeout` while still hovered.
- Radix settings that change this: `disableHoverableContent` on `Tooltip` or `TooltipProvider`, or `closeDelay={0}` on a `HoverCard` that sits apart from its trigger.
- Leave alone the browser's own `title` tooltip, content opened by a click, tap or Enter such as `Popover` or `DropdownMenu`, and Escape for content that reports an input error (see Exceptions).

<a id="txt-002b"></a>

## TXT-002b Open tooltips on focus too, and keep what people need on the page

Rule. Verdict: Unanimous (2 of 2). Status: decided. https://blackwoodblake.com/design-system/patterns/txt-002b/

### Rule

A tooltip opens when its trigger gets keyboard focus, not only when the pointer rests on it. It holds only extra help. Anything the person needs to finish the task is visible on the page without hovering or focusing.

### Why

A tooltip that only opens on hover does not exist for someone who uses a keyboard, and touch screens have no hover at all. Tooltips are also easy to miss and gone the moment the person moves on, so they must remember what it said. That is fine for a hint they can do without. It fails when the hint is the only place that says how to finish. Opening on focus supports [WCAG 2.2, 2.1.1 Keyboard](https://www.w3.org/TR/WCAG22/#keyboard), which asks that all functionality works from a keyboard. We record 2.1.1 as support, not as a requirement, so this rule rests on the judges. How the tooltip closes, stays and can be hovered is set by TXT-002a.

### Do

- An icon button with the accessible name "Share" shows the tooltip "Share" both when the pointer rests on it and when the person Tabs to it.
- The term *Net amount* in an invoice summary has a tooltip "The total before tax". The term can take focus, so a keyboard user can open the tooltip as well.
- A field *Project code* shows "Six letters or digits, for example KX4721" as text under the field. A tooltip on the label could add where to find the code, but the format stays on the page.
- A chart's data point shows its exact value in a tooltip, and the same values are in a table or a list next to the chart.
- If you use shadcn's `Tooltip`, check in your own build that the tooltip appears when you Tab to the trigger, and that the trigger can take focus, for example a `Button` rather than a plain `span`.

### Don't

- Show a tooltip only on mouse hover, so Tab reaches the button but no help appears.
- Put the only note that a booking cannot be changed after 6 pm the day before in a tooltip on an info icon.
- Put the only explanation of a price or a deadline the person must act on in a tooltip.
- Add a tooltip to a word that cannot take focus, so only pointer users can open it.

### Exceptions

- **The name of an icon-only button.** A tooltip on an icon-only button may show its name, in the same words as its accessible name, such as the tooltip "Share" on a button named "Share". The accessible name itself is set on the button, as ACT-001b says.
- **Other rules cover these cases.** Field errors follow FRM-002a, the reason a button is unavailable follows ACT-005, the meaning of a required marker follows FRM-005, and labels follow FRM-001.
- **Actions, not information.** This rule covers information. Actions that appear on hover, such as row buttons, are covered by KBD-001, and in a table row by TBL-003.
- **The full text of a truncated label.** A tooltip may show text cut off by an ellipsis only on the terms LAY-003a and LAY-003b set.
- **Not decided here.** Whether a tooltip may hold links or buttons is not covered by this rule.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- `TooltipTrigger asChild` around an element that cannot take focus, such as a plain `span`, `div` or icon with no `tabIndex`.
- A tooltip built by hand that opens on `onMouseEnter` or `onPointerEnter` with no `onFocus`. Tab to the trigger and see whether it appears.
- A tooltip, often on an info icon, that holds something needed to finish the task, such as a format, a deadline or a price rule. Ask: could the person finish without opening it? A tooltip repeating an icon-only button's name is fine.
- A chart whose exact values appear only in tooltips, when the person needs those values and no table or list on the page holds them.

<a id="txt-003"></a>

## TXT-003 Make every link's destination clear from its text, its name or the sentence it sits in

Rule. Verdict: Requirement. Status: decided. https://blackwoodblake.com/design-system/patterns/txt-003/

### Rule

Let people tell where each link goes or what it opens from its visible text, its accessible name, or its text with the list item, table cell, paragraph or sentence around it; an added name keeps the visible words. A vague phrase with nothing around it naming the destination is not enough.

### Why

Many people meet a link without the page around it. A screen reader user may jump from link to link, or pull up a list of every link on the page. Someone scanning reads the link and little else. If the link only says "More" or "Here", they have to guess, follow it to find out, or give up. Words that name the destination let everyone decide before they go.

This is a requirement. [WCAG 2.2, 2.4.4 Link Purpose (In Context)](https://www.w3.org/TR/WCAG22/#link-purpose-in-context) asks that a link's purpose can be told from its text alone or from its text together with context that software can tie to it: the same sentence, paragraph or list item, the same table cell, or the header of that cell. Words added to the link's accessible name count too. A heading above the link may help people, but on its own it is not the context 2.4.4 counts, so do not lean on it. Context placed somewhere else on the page, such as a side note, does not count.

When you add words to a link's name, [2.5.3 Label in Name](https://www.w3.org/TR/WCAG22/#label-in-name) asks that the visible words stay in the name, so a person using speech control can say what they see. Put the visible words first where you can. This is the same point ACT-001b makes for buttons.

Link text that makes sense with no context at all is our aim, as in [2.4.9 Link Purpose (Link Only)](https://www.w3.org/TR/WCAG22/#link-purpose-link-only). That criterion is Level AAA. We recommend it, but it is not part of this rule's requirement.

### Do

- In a list of invoices, each row links its number: *Invoice 2291*, *Invoice 2292*. The link text says where it goes.
- In a list of team members, each list item reads "Dana Ruiz, editor" and ends with the link *Profile*. The list item says whose profile it opens. Better still: *Dana Ruiz's profile*.
- In a table of monthly reports, each row has a link *Download* in the same cell as the month and the file type, *March, CSV*, or under a column header the cell is tied to in code (TBL-001). Better still: *Download March report (CSV)*.
- A card on a status page shows the link *Details* and gives it the name "Details: outage in the Frankfurt region". The visible word comes first in the name.
- In a sentence like "Your trial ends on 3 December. *See plans and prices* to keep your projects.", the link names the page it opens.
- Treat *More*, *Here*, *Click here*, *Read more*, *Learn more*, *Details*, *View* and *Continue* as link texts that always need context in the same sentence, list item or cell, or added words in the name. The list is our own and is not complete.
- Write the destination first and any generic lead-in after it, so a person scanning a list of links reads the telling words first.
- In shadcn, keep the words that name the destination inside the link element itself. When a short visible word must stay, add the rest with a visually hidden `span` inside the link, or with `aria-labelledby` pointing to the text that names the destination.
- A link that is only an image or an icon gets a text alternative that names where it goes, such as "Company home page" for a logo link.

### Don't

- End every card in a grid of recipes with the same link *Continue* when nothing in the card's own text, list item or cell says which recipe it opens.
- Rely on a heading above a group of *View* links as the only clue to where each one goes.
- Give a link that shows *Details* the `aria-label` "Outage report for Frankfurt". The word on screen is no longer in the name, so a speech command for it does nothing.
- Rely on `aria-describedby` alone for the context. The usual ways put the words in the link's name, with `aria-labelledby`, `aria-label` or visually hidden text, and a description is often not read when someone browses a list of links. Prefer visible context in the same sentence, list item or cell, or words in the name.
- Leave a link that holds only an icon with no name, so a screen reader announces just "link".
- Show the context only visually, for example by position next to a photo, with nothing in the text or the name.

### Exceptions

- **Purpose unclear to every reader.** 2.4.4 does not apply when the purpose of a link would be unclear to any reader, sighted or not, from the link and everything the page shows with it. Our choice, beyond the requirement: we do not use this exception for a link we could describe, and we describe it instead.

This rule is about anything that is a link in code. Labels on buttons follow ACT-001a and ACT-001b. A link styled as a button is still a link and follows this rule; which of the two to build is ACT-009a and ACT-009b, and the role itself ACT-009. A link whose meaning comes from the sentence before it meets this rule only when that sentence shares the paragraph, table cell or list item with the link, or is tied to it in code. The sign-in link in TXT-001a meets it when the sentence and the link sit together in one message. Opening a new tab, naming file types and marking links to other sites are left to separate rules. How a link in running text looks is VIS-003b.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Link` or `<a>` whose text is generic, such as *Read more*, *Learn more*, *Details*, *View*, *More*, *Here* or *Continue*. Ask: do its name, or the same sentence, paragraph, list item or table cell, say where it goes?
- An `aria-label` on a link that drops its visible words, such as `aria-label="Outage report for Frankfurt"` on a link that shows *Details*.
- A link that holds only an icon or an image, such as a logo inside `<Link href="/">`, with no `aria-label`, `sr-only` text or `alt` naming where it goes.
- Generic links whose only context is a heading above the group, an `aria-describedby`, or their place next to a photo.

<a id="vis-001"></a>

## VIS-001 Give text at least 4.5:1 contrast against the colour it is actually drawn on

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-001/

### Rule

Text people need to read reaches 4.5:1 against the colour it is drawn on, or 3:1 when it is large. Measure after opacity, tints, overlays and images have done their work, in every state. Text in an inactive control, decoration and logos are exempt; see Exceptions.

### Why

Faint text is a common reason a page is hard to read. It costs everyone something in bright light, on a cheap screen or late in the day, and it shuts out people with low vision altogether. [WCAG 2.2, 1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum) requires 4.5:1 between text and its background, and 3:1 for large text, which is about 24 px regular or about 18.5 px bold. The figures are not rounded: 4.49:1 fails. What counts is the colour the browser paints, so `opacity`, an alpha colour such as `text-foreground/60`, a translucent fill, a backdrop blur, a gradient and a photo all change the result. A pair of tokens that passes on paper can fail once one of them is laid on top. Text that shows on hover or focus, placeholder text and the labels and values in a chart are text too. The exemption is tied to being inactive, not to looking inactive: a control that still works must keep its text readable however it is styled.

Where a product has a light and a dark theme, we measure in both. People meet either one, so we treat each as the page; that is our way of applying the criterion, not words in it. Text that is used only as a symbol, such as an × on a close button, is judged as a graphic at 3:1 under [1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast), which is VIS-004.

### Do

- Use `text-muted-foreground` as it is for secondary text, such as the publish date under each episode in a podcast host's *Episodes* list. Justified's contrast test (`npm test` in `packages/tokens`) checks it on the page and on `muted` in both themes. If the date should weigh less, make it smaller or move it, and leave its colour alone.
- Know what the tokens promise. The test covers each `*-foreground` on its own fill, the status colours and `primary` as text on the page, and `muted-foreground` on the page and on `muted`. Every other combination is yours to measure, also when it is made of tokens.
- Measure the composite. On a show page where the title *Marrowfield Hours* sits on the cover photo, put a scrim such as `bg-black/60` under the title and check the title's colour against the lightest spot of the photo behind the letters, not against the average.
- Check soft fills. `text-destructive` on `bg-destructive/10` is a pair the test does not cover. With Justified's own values it measures about 5.6:1 in the light theme and 7.0:1 in the dark one. Before using such a pair, VIS-002 asks you to add it to the tokens and the test, so it is measured again whenever a colour changes.
- Check hover and selected states. A table row with shadcn's `hover:bg-muted/50` and `data-[state=selected]:bg-muted` keeps every cell readable on the new fill, its `text-muted-foreground` cells included: about 6.8:1 on the hover fill in the light theme and 7.3:1 in the dark one, and the selected fill is a tested pair. A product that changes the fills measures again.
- Keep placeholder text at `placeholder:text-muted-foreground`, as Justified's `Input`, `Textarea` and `NativeSelect` do, and measure it again if the field sits on a tinted panel.
- Fade a control only when it cannot be used. The `disabled:opacity-50` in Justified's `Button`, `Checkbox`, `RadioGroup`, `Switch` and field controls applies only to a control that is off. A control marked `aria-disabled="true"` that does nothing when pressed counts as inactive too; the note that ACT-005 puts beside it is ordinary text and must pass.
- Give chart text the same 4.5:1: axis labels, legend names and values printed on bars.
- Aim a little above the minimum for thin or light font weights. They can look fainter than their colour suggests. This is our own advice.

### Don't

- Put `opacity-50` or `opacity-60` on a timestamp, a helper line or an empty-state sentence. `muted-foreground` at 50 % on the page measures about 2.3:1 in the light theme and 2.9:1 in the dark one.
- Add opacity to a token that already passes, as in `text-muted-foreground/70` (about 3.5:1 on the light page) or `text-foreground/50` (about 3.4:1 on the light page).
- Fade a whole card, row or button that still works to say "older", "not chosen" or "loading in the background". The text inside fails, and the exemption does not apply because the element is not inactive.
- Use raw palette classes such as `text-gray-400` or `text-slate-500` without measuring them in each theme. A block of `bg-blue-50 text-blue-600` with no `dark:` variant keeps its own contrast, but it stays a light block on the dark page, where text and parts around it were never checked against it. Which colours to use at all is VIS-002.
- Put white text over a photo with no scrim and check it only against the photo's darkest part.
- Set text in a sticky header with `bg-background/70 backdrop-blur` and test it only over an empty page, not over the content that scrolls beneath it.
- Offer a high-contrast theme the person has to switch on, and let the default fall short. The web has no system setting a page can count on to switch it for them, so we ask the default presentation to reach the level; that is our own choice.
- Count a 20 px heading in `font-medium` as large text. It needs 4.5:1.

### Exceptions

- **Inactive controls.** Text in a control that cannot be used at that moment. When to switch a control off at all is ACT-004 and ACT-005.
- **Decoration and logos.** Text that is pure decoration, text no one can see, incidental text inside a photo with a lot else in it, and a logo or brand name. A logo set faint by the product's own choice, and not by its brand rules, is not exempt.
- **Visited links.** The colour may change after a visit, but each link colour still needs 4.5:1 against the page. How a link stands out from the text around it is VIS-003b.
- **Neighbouring rules.** Which token goes on which fill is VIS-002. Borders, icons and chart marks are VIS-004, which also measures them in every state. The focus indicator is KBD-001. The danger button's text is in DLG-005, and the required marker in FRM-005.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Text classes that fade a colour, such as `opacity-50` or `opacity-60` on a timestamp, helper line or empty state, `text-muted-foreground/70` or `text-foreground/50`, unless the element is a control that is off (`disabled:opacity-50`, see Exceptions).
- A card, row or button that still works but carries `opacity-*` to look older, unchosen or busy; the text inside it is not exempt.
- Raw palette text such as `text-gray-400` or `text-slate-500`, or a soft pair like `text-destructive` on `bg-destructive/10`, that no test covers. Measure it in both themes.
- Run the page in the light and the dark theme, including hover, selected and placeholder states, and measure each piece of readable text against the colour painted behind it: 4.5:1, or 3:1 at about 24 px regular or 18.5 px bold.
- Text over a photo, a gradient or `bg-background/70 backdrop-blur`: scroll content beneath it and measure against the lightest spot behind the letters, not the average.

<a id="vis-002"></a>

## VIS-002 Use each colour token only for the role and the pairs it was made for

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-002/

### Rule

Use a `*-foreground` token only on its own fill, `border-input` for the edges of controls, and a state colour such as `ring`, `destructive` or `accent` only for its state. Never use raw palette classes such as `text-gray-500` for something that carries meaning.

### Why

A token is a promise about where a colour goes. `primary-foreground` was chosen to be read on `primary`, `input` to mark the edge of a field, `ring` to show focus. Justified's contrast test checks those pairs in both themes, and a theme change reaches every place that uses them by name. A colour borrowed for another job keeps none of that. It was never measured where it now sits, it does not follow the theme, and when the palette changes it breaks without anyone noticing. A colour that has one meaning also keeps that meaning: once red marks a sale price, it no longer warns of an error. No WCAG criterion asks for tokens. What the law asks is the measured result, in VIS-001 for text and VIS-004 for borders and graphics. Using colours by role is how the judges keep that result true across themes and later changes, and it keeps colour cues readable in the sense of [WCAG 2.2, 1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color). Following the pairs does not prove contrast on its own; only measuring does.

### Do

- Pair each `*-foreground` with its own fill: `text-card-foreground` on `bg-card`, `text-popover-foreground` on `bg-popover`, `text-primary-foreground` on `bg-primary`. `foreground` and `muted-foreground` go on `background`, and `muted-foreground` also on `muted`.
- Use the status colours as Justified tests them: `text-destructive`, `text-success`, `text-warning` and `text-info` as text on the page, and each status fill under its own `*-foreground`. An order in a plant nursery's shop that could not be charged reads "Payment failed" in `text-destructive`.
- Edge every field with `border-input`: an `Input`, a custom select, a combobox trigger, a date picker button. Their edge is the only sign of where they are. Keep `border-border` for dividers and the edge of a `Card`, where nothing depends on seeing it.
- Keep `ring` for the focus indicator that KBD-001 describes. Show a chosen plan or an active tab some other way, as VIS-003a says.
- Keep `bg-accent` for items that are hovered, highlighted, pressed or selected, which is how shadcn's menus and `Toggle` use it. Give a static panel `bg-muted` or `bg-card`, so an item that turns `bg-accent` inside it still shows. Whether hover and press looks exist at all is VIS-008; when `bg-accent` draws both hover and selected, VIS-008b asks the selected item for a cue the hover does not use.
- When the product needs a colour it does not have, such as a soft badge of `bg-primary/10` with `text-primary` for *Ships in 2 days*, add it to the tokens with a name for its role and add the pair to the contrast test, so it is measured in both themes. This step is our own choice.
- Give brand colours the same treatment: a token with a role and a tested pair, not a one-off class.
- Treat an inverse surface, such as a dark tooltip in the light theme, as a pair like any other.

### Don't

- Use raw palette classes such as `text-gray-500`, `bg-slate-100`, `text-blue-600` or `border-gray-200`, or a hex value in `style`. Such a colour has no role, so nothing says where it may go. It does not follow the theme, and nobody has tested it.
- Put a foreground on someone else's fill: `text-primary-foreground` on `bg-muted`, `text-muted-foreground` on `bg-primary`, `text-accent-foreground` on `bg-destructive`. Each is tested only against its own partner.
- Use `text-destructive` for a sale price or a *New* label, `bg-success` as a brand accent, or `text-warning` for a heading. DLG-005 keeps the destructive button for actions that destroy something.
- Mark a selected card with `border-ring` or `ring-2 ring-ring`. Selection then looks like focus.
- Draw an `Input` override, a custom select or a combobox trigger with `border-border`. It measures about 1.4:1 against the light page and 1.5:1 against the dark one, made for a divider, not for the only edge of a control; VIS-004 gives the law's side.
- Mix systems in one pair, as in `bg-card dark:bg-zinc-900`. The pair now depends on two palettes, and the test sees only one.
- Reuse chart colours for status, or status colours for chart series in a chart that is not about status. shadcn's `--chart-1` to `--chart-5` are a role of their own; Justified does not define or test them.

### Exceptions

- **Colours that carry nothing.** An illustration or a photo is outside the rule. A colour that people read, or that marks a control, a state or a boundary, is inside it.
- **Text over a photo or video.** Text in `text-white` or `text-black` on a photo or a video, laid on a scrim such as `bg-black/60`, may keep that colour. No token is made to pair with a picture, and the picture looks the same in both themes. VIS-001 asks for the text to be measured against the lightest spot behind it. This is our own choice.
- **Loading signs.** A spinner, such as shadcn's `Spinner`, counts as an icon. Beside a word that says what is happening it only decorates (STR-005), so its colour carries nothing; as the only sign of a wait, it takes a token like any icon that carries meaning. This is our own choice.
- **Neighbouring rules.** The contrast a pair must reach is VIS-001 for text and VIS-004 for borders and graphics. The second cue next to a colour is VIS-003a. The focus ring itself is KBD-001. Hover and press looks are VIS-008, and a lasting state kept apart from them is VIS-008b.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Raw palette classes such as `text-gray-500`, `bg-slate-100`, `text-blue-600` or `border-gray-200`, or a hex colour in `style`, on text, a control, a state or a boundary. Leave alone illustrations, photos, white or black text on a scrim over them, and spinners (see Exceptions).
- A `*-foreground` class on an element whose fill is not its partner, such as `text-primary-foreground` with `bg-muted`, or `text-muted-foreground` with `bg-primary`.
- An `Input`, select trigger, combobox trigger or date picker button whose `className` sets `border-border`, where `border-input` belongs.
- `border-ring` or `ring-ring` with no `focus-visible:` or `focus:` prefix, used for a selected item instead of focus, and `text-destructive`, `bg-success` or `text-warning` used for something that is not that status, such as a sale price or a heading.
- A pair that mixes token and palette, such as `bg-card dark:bg-zinc-900`, or a `--chart-*` colour used to show status.

<a id="vis-003a"></a>

## VIS-003a Never let colour be the only sign of what something means or which state it is in

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-003a/

### Rule

Never let colour be the only sign of what something means or which state it is in, such as a status, an error or a selection. Add text, an icon, a shape or a pattern. A lightness difference of 3:1 counts too, except where people must know what a particular colour means.

### Why

Many people see some colours differently, red and green most often. Others meet the page in grey: in forced-colours mode, on a dim screen, in sunlight or on a printout. For all of them a status that is only a green or a red dot says nothing. [WCAG 2.2, 1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) requires that colour is not the only visual means of giving information, showing an action, asking for a response or telling elements apart. The cue has to be visible: text that only a screen reader hears does not meet it. A difference in lightness can be the cue when the two colours differ by 3:1 or more, but not when the person has to recognise the colour itself, as with red for failed and green for passed. Then text, an icon or a shape is needed. In Justified this is always the case for statuses: `success`, `warning` and `destructive` are all tuned to read as text on the page, so they end up close in lightness, about 1.0:1 to 1.3:1 against each other in both themes. We measure in both themes, as VIS-001 explains. Colour is welcome as an extra. The rule asks for a second cue, not for less colour. That the meaning also reaches assistive technology is a matter for [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) and, for messages, FBK-004.

### Do

- Show a selected option by more than its tint. On a pricing page with three plan cards, the chosen card gets a check icon and the text "Selected" as well as `bg-accent`, the fill VIS-002 gives to selected items. In a toggle group, the pressed item can swap fill and text, which differs by far more than 3:1.
- Give every status a word. In a build server's *Builds* table, the *Status* column reads "Passed", "Failed" or "Running", and each badge may carry an icon too (`CircleCheck`, `CircleX`, `Loader`). The colour is extra.
- Keep the sign on numbers that rise or fall. "+4.2 %" and "−1.3 %" keep their plus and minus signs, and an arrow up or down may stand beside them.
- Tell chart series apart without colour. In a line chart of *Weekly sign-ups* by plan, name each line at its end, or give the lines different dash patterns or marker shapes. A table of the same numbers below the chart also works.
- Mark free and booked slots in a calendar with a word or a symbol, not only green and red cells.
- Use different icons for different states: a filled check for done and an empty circle for not done, not one icon in two colours.
- Give the second cue enough contrast to be seen; an icon or a separating stroke needs 3:1 (VIS-004). An icon beside a word is clearer than an icon on its own, which is our own advice.
- Run a grayscale check of a new screen: everything that mattered should still be clear.

### Don't

- Show a status as `<Badge className="bg-green-500" />` with no text, or as a coloured `size-2 rounded-full` dot in a table cell.
- Use `variant="destructive"` and `variant="secondary"` badges that both read "Active", or that show only a number, so that colour carries the difference.
- Mark a field as wrong with `aria-invalid:border-destructive` and nothing else. The message in text is what meets the criterion; FRM-002a says where it goes.
- Show which tab is active only by `text-foreground` against `text-muted-foreground`. They differ by about 2.5:1 in the light theme and 2.1:1 in the dark one, short of 3:1. Add an underline bar or a weight change.
- Show a chart's legend as coloured squares only, and rely on a tooltip on hover to tell the lines apart. The chart at rest must already make sense.
- Write "Overdue items are shown in red." The instruction depends on colour as much as the items do.
- Put the meaning in an `sr-only` label and leave the screen with a colour only.

### Exceptions

- **Colour that carries nothing.** Decoration, brand colour and category colours on tags that also show their name are outside the rule.
- **Visited links.** A visited link may differ from an unvisited one by colour alone. Links in running text are VIS-003b, which comes first where both apply.
- **Colour as the data.** In a heat map or a map coloured by value, a pattern on every cell is rarely practical. Give the values another way instead: on the cells, in a table, or in a legend that names each step together with values the keyboard can reach.
- **Neighbouring rules.** The error text at a field is FRM-002a, the required marker FRM-005, the current page in a menu NAV-002b, the danger button DLG-005, and focus shown by more than colour KBD-001. The contrast of icons and strokes is VIS-004. A selected or on look kept visible under hover, focus and press is VIS-008b.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Badge`, dot or table cell whose only content is a colour, such as `<Badge className="bg-green-500" />` or a `size-2 rounded-full` span with no text or distinct icon beside it.
- Badges or icons that differ only by `variant` or colour while their text, icon and shape are the same.
- A field marked wrong only by `aria-invalid:border-destructive`, with no visible message; or a meaning given only in an `sr-only` span.
- Active tab, selected card or chart series told apart only by colour, such as `text-foreground` against `text-muted-foreground` or legend squares with no names. Look at the screen in grayscale and ask whether each state still reads.
- Instructions that name a colour, such as 'shown in red'. Leave alone decoration, tags that show their name, and visited links (see Exceptions).

<a id="vis-003b"></a>

## VIS-003b Make a link in running text stand out from the words around it by more than colour

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-003b/

### Rule

A link in running text stands out from the words around it at rest, not only on hover or focus: by a cue that is not colour, such as an underline, or by 3:1 lightness against the surrounding text. Justified's tokens close the 3:1 route, so a cue is needed; our own choice is an underline.

### Why

A link that differs from its sentence only by hue is invisible to many people who see colours differently, and hard to find for anyone on a dim or glaring screen. They read past it and never learn it was there. [WCAG 2.2, 1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) covers it, because "this word is a link" is information. The Working Group's failure [F73](https://www.w3.org/WAI/WCAG22/Techniques/failures/F73) fails a link in text that only its colour sets apart, even if an underline appears on hover or focus, since nobody hovers over words they cannot find. Its technique [G183](https://www.w3.org/WAI/WCAG22/Techniques/general/G183) shows the other route: 3:1 in lightness between the link and the text around it, while each still reaches 4.5:1 against the page under [1.4.3 Contrast (Minimum)](https://www.w3.org/TR/WCAG22/#contrast-minimum). In Justified that route is closed. `primary`, the link colour, measures about 2.2:1 against `foreground` in the light theme and 2.1:1 in the dark one, and even less against `muted-foreground`. We measure in both themes, as VIS-001 explains. So a link in Justified's body text meets the criterion only with a cue that is not colour, and the underline is the plain one.

### Do

- Underline every link in a sentence or paragraph. On a course platform's lesson page, "Download the worksheet for this lesson" sits in a paragraph as `<a className="text-primary underline underline-offset-4">`. Justified's `Button variant="link"` already has the underline.
- Underline links in help text as well. Under the field *Display name* on a learner's settings page, the `text-muted-foreground` line "Shown on certificates. Read how we use your name." has its last sentence as an underlined link.
- Put the underline in the shared mapping when Markdown or MDX renders the content, so every link in an article gets it, and not in each page by hand.
- Give a Next.js or React Router `Link` inside text the same classes as any other link in text. The router does not add an underline.
- Use a bottom border or a thicker underline if the design wants one, as long as it is visible at rest and is not only a change of colour.
- Add a change on hover and focus, such as `hover:decoration-2`, as an extra. A link that already stands out at rest does not need it to meet the criterion, but it helps people see what they are about to press.
- A product with its own link colour that differs from its text by 3:1 or more in lightness, with both at 4.5:1 on the page, meets the criterion without an underline. We still recommend one, because an underline does not depend on how well someone sees lightness. This is our own advice.
- Bold also passes the criterion, as weight is not colour. We prefer the underline, since bold is also used for emphasis; our own choice.

### Don't

- Style a link in a paragraph, a `FormDescription`, an `AlertDescription` or a dialog's text with `text-primary` alone. Tailwind's base styles remove the underline from every `a`, so a bare link in text has none.
- Use `text-primary hover:underline` in running text. The underline appears only for people who already found the link.
- Copy `no-underline` from a navigation pattern into an article.
- Rely on the focus ring (KBD-001) to show that a word is a link. It shows where focus is, not what is a link at rest.

### Exceptions

- **Links the setting shows.** A menu, a footer list, a table of contents, a list where every item is a link, or a card that is a link as a whole need no underline, though one is allowed. What a current-page marker in a menu needs is NAV-002b. A link that sits in the middle of other words, such as in a table cell next to plain text, counts as running text.
- **Visited links.** A visited link may differ from an unvisited one by colour alone. Each colour still needs 4.5:1 against the page (VIS-001).
- **Links styled as buttons.** A link drawn as a button is a button to the eye and is outside this rule.
- **Neighbouring rules.** What a link says is TXT-003. Colour as the only sign elsewhere is VIS-003a, the wider rule; this narrower one comes first for links in text.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `<a>` or router `Link` inside a `<p>`, `FormDescription`, `AlertDescription`, `DialogDescription` or a table cell beside plain text, with no `underline` or other cue beyond colour, such as `font-semibold`. Leave alone links styled as buttons, lists of links (see Exceptions) and `prose` text that underlines links.
- A link in running text with `hover:underline` or `focus:underline` but no `underline` at rest, or with `no-underline`.
- The `a` mapping passed to an MDX or Markdown renderer (such as `components={{ a: ... }}`) that does not add `underline`.

<a id="vis-004"></a>

## VIS-004 Give the edges and state marks of controls, and the parts of graphics people need, 3:1 contrast

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-004/

### Rule

The parts people need to see to find a control and tell its state, and the parts of a graphic they need to understand it, reach 3:1 against the colours next to them. Inactive controls, decoration and graphics whose information is also given in text are exempt.

### Why

A text field nobody can see is a field nobody fills in. A checkbox whose box fades into the card, a switch whose track blends with the panel, or a chart whose lines are pale on white leaves people guessing what is there and what state it is in. [WCAG 2.2, 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) requires 3:1 for the visual information needed to identify a control and its state, and for the parts of a graphic needed to understand it. It is measured against the colours that touch the part. It does not ask for a border on everything: a button with readable text is found by its text, so its container need not reach 3:1. A text field has no text until someone types, so its edge, or a fill that stands out from the page, is what shows it. State marks count too: the tick in a checkbox, the dot in a radio button, the thumb and track of a switch. These may be measured against another part of the control, such as the tick against the box's fill. The criterion does not compare a control's states with each other; a state that differs only by hue is VIS-003a. It does test the parts people need in each state, so a hover or a press may be faint itself, but it may not make an edge people need, a state mark, or a focus or selection cue drop below 3:1. The exception for controls the browser draws unchanged hardly ever applies in a shadcn app, where every control is styled by the author. Where a product has a light and a dark theme, we measure in both. People meet either one, so we treat each as the page; that is our way of applying the criterion, not words in it.

### Do

- Edge fields with `border-input`, as Justified's `Input`, `Textarea`, `NativeSelect`, `Checkbox` and `RadioGroup` do. The contrast test checks `input` against the page at 3:1 in both themes. Measured further, it gives about 3.3:1 on `muted` and 3.7:1 on `card` in the light theme, and 3.5:1 and 4.2:1 in the dark one, so a field on those panels still passes. Which border token to use is VIS-002.
- Use Justified's `Switch` as it is: the track is `bg-input` when off and `bg-primary` when on, with a thumb in the page colour, and both states keep 3:1.
- Give an icon-only button's icon 3:1 against what is behind it. On an energy dashboard's toolbar, the *Export readings* button with a download icon keeps the icon in `text-foreground` and its name in code (ACT-001b).
- In a bar chart of *Daily use in kWh*, give each bar 3:1 against the chart's background.
- On an account page, a storage meter split into *Photos*, *Videos* and *Documents* shows each segment at 3:1 against the track. Neighbouring segments either differ by 3:1 from each other, or have a 2 px gap in the background colour between them, so each part can be seen. The meter alone tells how full the account is, so it needs the contrast; the exact sizes may also stand in text next to it.
- Check a product's own chart palette in both themes; shadcn's `--chart-1` to `--chart-5` are not in Justified's test.
- Give a status dot 3:1 against the page. Justified's status colours are tested at 4.5:1 as text on the page, so as dots on the page they pass. If a product's own status colour is too light as a dot, darken it, or give the dot an edge that reaches 3:1 against the page.
- Draw the indicator of a selected tab or row, such as an underline bar or a check, at 3:1 against what is next to it, when that indicator is how people see the state.
- Measure the centre of a part drawn with a gradient against what surrounds it.
- Measure the parts people need in every look the control has: at rest, hovered, pressed, selected and focused. A custom select trigger keeps `border-input` on hover, a checkbox keeps its box edge when the pointer is on it, and a switch's thumb still stands out from its track while pressed.

### Don't

- Edge an `Input`, a custom select, a combobox trigger or a date picker button with `border-border`. It measures about 1.4:1 against the light page and 1.5:1 against the dark one.
- Make a field `border-transparent bg-muted/50`, or `border-0 bg-transparent` in a toolbar or a table cell, so that only the placeholder shows where it is. The placeholder is not the field's edge and is gone once someone types.
- Draw an unchecked checkbox with `border-muted-foreground/30`, put a `bg-muted` switch track on a `bg-muted` card, or draw a slider rail in `bg-secondary` on the page.
- Put `opacity-50` on an icon button or toggle that still works to mean "off" or "less important". The exemption is for inactive controls only.
- Draw an icon-only button's icon in `text-muted-foreground/50`, or a light icon on a tinted toolbar.
- Add a `dark:` override for a control's fill and forget its border.
- Rely on a tooltip or a hover highlight to make chart lines visible. The chart at rest must pass.
- Give a select trigger, a field or an icon-only outline button `hover:border-transparent`, so the edge people find it by is gone while the pointer is on it.
- Put `active:opacity-70` on a checkbox, a switch or an icon button. While it is pressed, the edge, icon or marks people need fade with it.
- Let a hover paint over the focus ring, as with `hover:ring-0`, or lay a hover fill close to the colour of a selection bar or check.

### Exceptions

- **Inactive controls.** A control that cannot be used at that moment. When to switch a control off at all is ACT-004 and ACT-005.
- **Information in text.** A graphic whose information is also given as text, such as values printed on each bar or a table of the same data, need not reach 3:1 in its parts. The text then follows VIS-001.
- **Decoration and pictures.** Decoration, photos and illustrations people do not need in order to understand the content.
- **Hover and press.** A hover look, or the look while a control is being pressed, need not reach 3:1 against the control at rest, since the criterion does not compare a control's states with each other; the explanation says this of hover, and treating the pressed look the same is our reading. Neither may make an edge people need to find the control drop below 3:1 against the page or panel around it, nor a state mark or a focus or selection cue drop below 3:1 against what now touches it. A toggle that is on is not covered: that is a state people must identify. Whether to show hover and press looks at all is VIS-008.
- **Text.** Text, including axis labels and values in a chart, is VIS-001.
- **Neighbouring rules.** The focus indicator is KBD-001, and focus seen through a translucent layer KBD-002. States and statuses told apart by colour only are VIS-003a.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- An `Input`, `Textarea`, select trigger, combobox trigger or date picker button whose border is `border-border`, `border-transparent` or `border-0`, also under `hover:` or `active:`, unless its fill alone stands out from the page by 3:1.
- Control parts drawn faint, such as a checkbox with `border-muted-foreground/30`, a `bg-muted` switch track on a `bg-muted` card, or a slider rail in `bg-secondary`.
- An icon button or toggle that still works with `opacity-50` or `active:opacity-70`, or an icon in `text-muted-foreground/50`. Leave alone a control that is off (see Exceptions).
- A `dark:` override that changes a control's fill but not its border.
- Chart lines, bars, meter segments and status dots in the product's own or `--chart-*` colours: measure each against its neighbours at 3:1 in both themes, unless the same values also show as text.

<a id="vis-005"></a>

## VIS-005 Let people pause, stop or hide content that moves or updates by itself

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-005/

### Rule

When something starts by itself and shares the screen with other content, give a way to pause, stop or hide it if it moves, blinks or scrolls for more than five seconds. If it updates by itself, such as an auto-playing carousel, give that way, or a way to set how often, at any length. Essential motion is exempt.

### Why

Motion pulls the eye whether the person wants it to or not. A logo strip that never stops, a slide that changes while someone is still reading it, or a card that floats up and down beside a form makes it hard to read and hard to think, most of all for people with attention or reading difficulties and for people who use a screen magnifier, who may see little else. [WCAG 2.2, 2.2.2 Pause, Stop, Hide](https://www.w3.org/TR/WCAG22/#pause-stop-hide) requires the way out. It is Level A, so it sits inside AA. It has two parts. Moving, blinking and scrolling need a control only when all three hold: it starts by itself, it lasts more than five seconds and other content is on screen with it. Content that updates on its own needs a control however long it runs, or a way to set how often it updates. The criterion covers every part of the page, decoration included.

The Working Group's Understanding page for 2.2.2 counts motion that starts on hover, on focus or when scrolled into view as starting by itself; only a deliberate press does not. Its techniques let the person pause and resume from the same place, and list a scrolling strip with no pause as a failure ([G4](https://www.w3.org/WAI/WCAG22/Techniques/general/G4), [F16](https://www.w3.org/WAI/WCAG22/Techniques/failures/F16)). These are the Working Group's reading of the criterion, not its text. Reduced motion is a separate rule, VIS-006.

### Do

- A pricing page has a shadcn `Carousel` of customer quotes with `plugins={[Autoplay({ delay: 5000 })]}` from `embla-carousel-autoplay` 8, the version shadcn's `Carousel` uses. Before the slides in reading order sits a button *Pause quotes*. Pressed, it calls the plugin's `stop()`, its label becomes *Play quotes*, and the carousel stays still until the person presses it again. The label follows the plugin's state through `emblaApi.on("autoplay:stop")` and `emblaApi.on("autoplay:play")`, so it is right also when a drag has stopped the autoplay. The button can be reached with Tab and shows focus (KBD-001).
- Our own reading of the criterion, as the safest one: make the control a visible button that keeps its state. `stopOnMouseEnter`, `stopOnFocusIn` and `stopOnInteraction` are welcome as extras, but none is a control the person can find and see the state of, and with `stopOnInteraction: false` the first two start the motion again as soon as the pointer or focus leaves. The `CarouselPrevious` and `CarouselNext` buttons are not a pause either.
- A logo wall under the hero runs as `animate-[marquee_40s_linear_infinite]`. A small button *Pause logos* next to it sets `animation-play-state: paused`, so the strip stops where it is and starts again from there.
- A hero background `<video autoPlay muted loop playsInline>` gets a visible button *Pause video* over its corner. Or it plays once, stops within five seconds and leaves its last frame.
- A "New" badge with `animate-pulse [animation-iteration-count:2]` pulses twice, for four seconds, and then stays still. That ends inside five seconds, so it needs no control. `animate-pulse` alone loops forever.
- A framer-motion card that floats with `animate={{ y: [0, -8, 0] }}` and `transition={{ repeat: Infinity }}` either stops within five seconds or is covered by the page's motion control.
- A dashboard whose numbers refresh every 30 seconds has a switch *Update automatically*, on by default, with its label visible beside it (FRM-001). Turned off, the numbers hold until the person presses *Refresh now*. A select for how often it updates also meets the criterion.
- One control for the whole page that stops every moving part is allowed, and is kinder than many small ones when a page has several. Our own advice: put it early, near the top, so a keyboard user meets it before the motion.
- Hiding passes too: a *Close* on an animated promotion banner that removes it meets the criterion.
- Our own advice, beyond the requirement: do not auto-advance a carousel at all. Let the slides change only when the person presses an arrow or swipes. Then this rule does not apply, and people can read each slide for as long as they need.

### Don't

- Add Embla `Autoplay` to a shadcn `Carousel` and rely on `stopOnMouseEnter` and `stopOnFocusIn`. Someone reading from a distance, using a magnifier or not yet at the carousel has nothing to press, and nothing shows that it can be stopped.
- Rotate testimonials, tips or headlines on a `setInterval` with no pause.
- Run an animated gradient (`animate-gradient` on `bg-[length:200%_200%]`), a particle background or an `animate-spin` blob behind the content forever, on the grounds that it is only decoration.
- Start a looping marquee with `whileInView` and `repeat: Infinity` when it scrolls into view, with no control. Scrolling it into view does not count as asking for it.
- Pause the motion only while it has focus and start it again as soon as focus leaves.
- Our own reading: do not treat `motion-reduce:animate-none` as the control. Many people who are bothered by motion never turn that setting on. Honour it as VIS-006 asks, and give the control as well.

### Exceptions

- **Short motion.** Moving, blinking or scrolling that starts by itself and stops within five seconds needs no control. This allowance does not cover content that updates on a timer.
- **Started by the person.** A video the person pressed play on, a carousel that moves only when its arrows are pressed or it is swiped, and an update the person asked for with *Refresh now* do not start by themselves.
- **Essential motion.** Motion is essential when taking it away would change what the content is, such as an animation the person is editing in an animation tool. Decoration is never essential.
- **Nothing else on screen.** Motion that is the only thing on screen, with nothing else to read or use, is outside the criterion. In a shadcn app that is rare beyond the very first load.
- **Loaders.** Spinners, progress bars and skeletons are STA-001's, including how 2.2.2 applies to them. A spinner that starts because the person pressed a button does not start by itself.
- **Flashing.** Rapid flashing, above three flashes within one second, is a matter for [WCAG 2.2, 2.3.1 Three Flashes or Below Threshold](https://www.w3.org/TR/WCAG22/#three-flashes-or-below-threshold). A pause button does not make such flashing acceptable, because harm can come before anyone presses it.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Load the page without touching it and watch for at least five seconds. Anything that keeps moving, blinking or scrolling, or any content that changes by itself, needs a visible control to pause, stop or hide it.
- Embla `Autoplay` on a `Carousel`, `setInterval` rotating content, an `infinite` CSS animation such as `animate-pulse` or a marquee, `repeat: Infinity` in framer-motion, or `<video autoPlay loop>`, with no pause, stop or hide button beside it. Leave alone loaders such as `Skeleton` and motion that ends within five seconds.
- A pause that relies only on `stopOnMouseEnter`, `stopOnFocusIn` or `motion-reduce:`, or that starts the motion again when focus or the pointer leaves.
- A dashboard or feed that refreshes on a timer with no switch to stop it and no setting for how often. Leave alone loaders, which are STA-001 (see Exceptions).

<a id="vis-006"></a>

## VIS-006 Swap movement for a fade or no motion when the person asks for reduced motion

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-006/

### Rule

When the person's device or browser asks for reduced motion, replace movement across the screen, such as sliding, zooming, scaling, parallax and bouncing, with a short fade or an instant change. Stop motion that only decorates and show its final state. Keep motion that is essential.

### Why

For some people, things that slide, zoom or drift on a screen bring on dizziness, nausea or a migraine that can last the rest of the day. They tell their system once, with a setting such as Reduce Motion on Apple devices or the animation switch in Windows and Android, and the browser passes that on to every page as `prefers-reduced-motion: reduce`. A page that ignores it makes them pay for its effects. Asking for less motion is not asking for none: a fade in place does not move anything across the view, and it still shows that something changed, which a hard cut can hide. No Level AA criterion requires this, so the rule rests on the judges. [WCAG 2.2, 2.3.3 Animation from Interactions](https://www.w3.org/TR/WCAG22/#animation-from-interactions) asks for it at Level AAA. That is a further aim, not a requirement here. A control that lets everyone pause moving content is VIS-005, and keeping meaning when motion goes is VIS-007.

### Do

- Put one rule in the base stylesheet under `@media (prefers-reduced-motion: reduce)` that turns off movement and keeps opacity. With `tw-animate-css`, reset its enter and exit variables rather than setting `transform: none` or `animation: none`, which would also stop transforms the layout needs or remove the fades: `--tw-enter-translate-x`, `--tw-enter-translate-y` and `--tw-enter-rotate` to `0`, `--tw-enter-scale` to `1`, and the same for the `--tw-exit-*` set. shadcn's `Dialog`, `Popover` and `DropdownMenu` then fade in place, and a `Sheet` fades in instead of sliding the width of the screen.
- In your own components, pair every movement class from `tw-animate-css` or `tailwindcss-animate` with a reduced form, for example `animate-in fade-in motion-safe:slide-in-from-bottom-4`, so the panel fades in place when the setting is on.
- With framer-motion or Motion, wrap the app in `<MotionConfig reducedMotion="user">`. It then drops transform and layout animation and keeps fades and colour changes. Use `useReducedMotion()` where you build your own variants, such as an `AnimatePresence` page transition that slides in with `initial={{ x: 300 }}`.
- Turn off parallax made with `useScroll` and `useTransform`, and slide-ups on `whileInView`. The content is simply in place.
- Stop decorative loops, floating cards, animated gradients and digits that roll up to a number, and show the end state at once.
- Our own reading, since no judge names it: make scrolling instant under reduced motion. Write `motion-safe:scroll-smooth` instead of `scroll-smooth`, and pass `behavior: "auto"` to `scrollIntoView` when the setting is on.
- Read the setting with a listener, not once on mount, so a change takes effect without a reload. On the server the setting is unknown, so start from the reduced form or from CSS, not from a guess in script.
- End every reduced animation on its final, visible state. A card that waits at `opacity-0` for a keyframe must still appear when the keyframe is off.
- Keep essential motion, in a calmer form if you can. A loader still shows that work goes on, as STA-001 asks; a slower spin or a static bar with "Loading invoices" is fine. A video the person chose to play still plays.
- Check that a `Dialog` still closes and leaves the page when its exit animation is cut, and that focus moves as DLG-006 asks without waiting for any animation.

### Don't

- Use `animate-in slide-in-from-right zoom-in-95` in a custom panel with no `motion-reduce:` or `motion-safe:` variant.
- Leave `MotionConfig reducedMotion="user"` out, so every `motion.div` in the app slides and springs whatever the person has set.
- Set `scroll-smooth` on `html` and smooth-scroll to every anchor for everyone.
- Paste a snippet that sets every duration to almost zero, so the fades the setting allows go too and content jumps.
- Hide content with `opacity-0` until an animation that is now off reveals it, so it never appears.
- Treat the setting as the pause control for content that moves by itself. That control is VIS-005, for everyone.

### Exceptions

- **Motion the person drives.** Content that moves because the person scrolls, or a card that follows their finger or pointer in a drag, is their own movement and stays. Motion added on top of scrolling, such as parallax, is not.
- **Essential motion.** Motion that is the content itself, such as a video the person started or an animation being edited, stays.
- **A product's own switch.** A motion setting inside the product, on top of the system one, is welcome but not required by this rule.

### How to check

Checked by running the page: the break shows only when it runs. Each item is a sign the rule may be broken; code that follows the rule never matches.

- Turn on reduced motion (in browser dev tools, emulate `prefers-reduced-motion: reduce`), open dialogs, sheets, menus and page transitions, and see whether anything still slides, zooms, scales or bounces instead of fading or changing at once.
- `slide-in-from-*`, `zoom-in-*` or `spin-in-*` from `tw-animate-css` or `tailwindcss-animate` with no `motion-safe:` or `motion-reduce:` variant and no reduced-motion rule in the base stylesheet.
- A framer-motion or Motion app with no `<MotionConfig reducedMotion="user">`, or own variants with `x`, `y` or `scale` that ignore `useReducedMotion()`; parallax with `useScroll` and `useTransform`.
- `scroll-smooth` on `html` or `behavior: "smooth"` in `scrollIntoView` with no reduced form.
- With reduced motion on, look for content that never appears because it waits at `opacity-0` for an animation, and for decorative loops that keep running.

<a id="vis-007"></a>

## VIS-007 Never let motion be the only sign of what happened

Rule. Verdict: Unanimous (2 of 2). Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-007/

### Rule

Never let an animation be the only way the interface says something. Whatever it means, such as an error, a change, a new item or that something is live, is also shown in text, an icon or a state that stays on screen when the motion has ended or is turned off.

### Why

Motion is easy to miss. A screen reader does not report it, a person who looked away for a second never sees it, and once it ends it is gone. When reduced motion is on, VIS-006 takes it away on purpose. If the shake was the only sign of a wrong password, or the bounce the only sign that something reached the cart, those people are left guessing. Motion is good at drawing the eye to a change; the change itself has to be there to find. No WCAG criterion says that motion must not be the only cue, and this rule does not claim one. Two criteria cover parts of it. Under [WCAG 2.2, 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG22/#non-text-content), an animation that carries information needs a text alternative with the same purpose. Under [4.1.3 Status Messages](https://www.w3.org/TR/WCAG22/#status-messages), a change shown without moving focus must reach assistive technology, as FBK-004 describes. The idea mirrors VIS-003a, where colour must not be the only means of showing something.

### Do

- A sign-in form shakes its `Card` when the password is wrong. The error text "The email or password is not right. Check both and try again." also shows at the field with `FormMessage`, as FRM-002a and TXT-001a ask, and stays after the shake ends.
- The cart icon in a shop's header bounces when an item is added. Its badge changes from 2 to 3 and stays at 3, and a status message "Added to cart" is announced (FBK-004).
- A new row in an orders table flashes and fades. It also gets a "New" `Badge` that stays until the person leaves the page, so the row can still be found once the flash is over.
- A file flies into the *Archive* folder in the sidebar. The folder's count goes up, the file is gone from the list, and the status message "Moved to Archive" is announced.
- A pulsing dot in a meeting's header has the word *Live* beside it, and *Recording* when that is what it means.
- Each step of a setup wizard slides in from the side. A step indicator "Step 2 of 4" above the form says where the person is, so the slide is not the only sign of going forward or back.
- After a pointer drag in a reorderable list, the list's new order and the mark on the landing place (ACT-008) are the lasting form. A keyboard move is also announced in words, as ACT-007b asks.
- An item removed with an `AnimatePresence` exit animation is gone from the list, and a status message names what was removed.
- A highlight that should show under reduced motion is a class that stays, such as a tinted background, with only its fading in left to the animation.

### Don't

- Shake an `Input` with a custom `animate-shake` keyframe or `x: [0, -8, 8, 0]` when its value is wrong, and leave `FormMessage` out.
- Replace the toast with a check mark that draws itself in a Lottie animation, with no text and no status message.
- Use `animate-ping` on a dot as the only sign that a colleague is online.
- Mark the row that just changed only with a keyframe that fades from yellow, so a blanket reduced-motion rule (`animation: none`) leaves no mark at all.

### Exceptions

- **Polish on what is already said.** Motion that adds nothing new, such as a dialog that fades in with its title, needs nothing more.
- **Motion that follows the hand.** In a drag, the motion is feedback to the person's own movement. Where the item ends up is the lasting form.
- **Progress.** A loader whose progress is also given as a value or in text is fine. An indeterminate one needs a name, as STA-001 asks.
- **Content shown on hover.** Content that animates in on hover or focus follows TXT-002a and TXT-002b.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A shake, such as a custom `animate-shake` or `x: [0, -8, 8, 0]`, on a form or field with no `FormMessage` or other error text that stays.
- `animate-ping`, `animate-pulse` or a keyframe flash used as the only sign that something is live, online, new or changed, with no word, badge or lasting class beside it.
- A Lottie or SVG animation, a bounce or an `AnimatePresence` exit that stands for a result, such as saved, added or removed, with no text, changed count or status message.
- Turn on reduced motion, repeat the action, and ask whether the screen still shows what happened. Leave alone motion that only adds polish to what is already said, and drags (see Exceptions).

<a id="vis-008"></a>

## VIS-008 Show a change on everything people can press, while it is pressed and while the pointer is over it

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-008/

### Rule

Everything that does something when pressed, including a clickable card, row or list item, changes its look while it is pressed and, where the pointer can hover, while the pointer is over it. A control that is off shows neither change.

### Why

A press that changes nothing on screen leaves people unsure whether it was taken, so they press again, or give up on a control that works. A change under the pointer tells them, before they click, that this is the thing that will respond, and that the card they are pointing at is one target and not three. The same looks on a control that is off promise an action that is not there. No WCAG criterion asks for hover or pressed looks. The explanation of [WCAG 2.2, 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) treats an author's hover look as an extra, since the pointer itself already shows where it is, so this rule rests on the judges. That Apple's stance carries to the web is our own reading. A hover look confirms what the element at rest should already show: that it can be used. It does not replace that.

### Do

- In a project dashboard, each project is a `Card` with a link to the project stretched over it (`after:absolute after:inset-0` on the link, `relative` on the card). The card gets `hover:bg-accent hover:text-accent-foreground` and a pressed look such as `active:shadow-inner`, and keeps its `border` at rest so it looks like one target before anyone points at it. Which fill to use is VIS-002; text on the new fill follows VIS-001.
- Give every pressable element an `active:` style as well as a `hover:` one. Tailwind v4 applies `hover:` only on devices that can hover, so on a phone a tap shows nothing unless there is an `active:` style, which applies on touch too.
- On a phone, a tile in *Today's tasks* shows its pressed look as soon as the finger lands on it. It has no hover look there, and needs none. Check the press on a real phone: a browser may hold the pressed look back for a moment inside an area that scrolls.
- On a file card, the icon buttons *Download*, *Share* and *Rename* each have a hover fill and a pressed look. Their names in code are ACT-001b, and their size is ACT-006.
- Build menus and command lists from shadcn's `DropdownMenu`, `Select` or `Command`, which light the item under the pointer and the keyboard. If you must build a list by hand, give each item the same highlight.
- Keep a control that is off still. Tailwind's `disabled:` variant matches only the native attribute, so a menu item or button with `aria-disabled="true"` keeps its `hover:` and `active:` classes. Scope them with `not-aria-disabled:hover:bg-accent` and `not-aria-disabled:active:…`. Avoid `pointer-events-none` for this: it also blocks a tooltip that says why the control is off.
- Our own choice: show the pressed look at once on the press, with no delay. Any motion in the change follows VIS-006.
- Our own advice: make a pressable element look usable at rest, with a border, a link style, a chevron or a button shape, so nobody has to sweep the pointer over the page to find out.

### Don't

- Put `onClick` on a `Card` or a `div` row and give it only `cursor-pointer`. The cursor is not a change of the element, and a touch screen has no cursor at all.
- Strip a ghost `Button` of its hover with `className="hover:bg-transparent"` and put nothing in its place.
- Map a list of plain `div` items in place of a `DropdownMenu`, so the item under the pointer looks like every other item.
- Give a static summary `Card` or a decorative picture `hover:shadow-lg`. It invites a click that does nothing. This is our own advice; the rule itself only keeps the looks off a control that is off.
- Let a menu item marked `aria-disabled="true"` light up on hover and darken on press like the items that work.

### Exceptions

- **Row highlight as a reading aid.** A table row that lights up under the pointer to help the eye follow it, as shadcn's `TableRow` does with `hover:bg-muted/50`, is fine, and so is a row whose actions appear on hover, which TBL-003 covers.
- **Whole containers.** A bar, a dialog, a sheet or a panel as a whole takes no hover or pressed look. The controls inside it do.
- **Controls the browser draws.** A native control left with the browser's own styling keeps the browser's own response.
- **Touch only.** Where the device has no pointer that can hover, only the pressed look applies.
- **Neighbouring rules.** The focus indicator and keyboard reach are KBD-001. Content or actions that appear on hover are TXT-002a, TXT-002b and TBL-003. The contrast of a control's edge and marks while it is hovered or pressed is VIS-004. Which token draws the change is VIS-002. A selected or on state kept visible under hover and press is VIS-008b. A control that is off is off in code too, as VIS-008a says. What a button shows after the press while its action runs is STA-005a.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `Card`, `li`, `div` or `tr` with `onClick`, a link wrapped round it or stretched over it, and no `hover:` or `active:` look, counting `group-hover:`, `group-active:` and `has-[]:` looks. For `Button` and other `cva` components, check the definition in `components/ui/`, not each usage.
- A `className` on a `Button`, menu item or command item that sets `hover:bg-transparent`, or replaces the `focus:` or `data-[highlighted]:` highlight, with nothing in its place.
- `hover:` or `active:` styles on an element that can carry `aria-disabled="true"`, with no `not-aria-disabled:` scope, so a control that is off still reacts.

<a id="vis-008a"></a>

## VIS-008a Set every state a control shows in code on the control, and change it whenever the look changes

Rule. Verdict: Requirement. Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-008a/

### Rule

When a control shows a state, such as on or off, selected, checked, expanded or unavailable, that state is also set in code on the control itself. Whenever the look changes, the state in code changes with it.

### Why

A screen reader and speech control do not see a filled icon, a coloured border or a rotated chevron. They read the state the control carries in code. A *Mute* button drawn as on but silent in code is announced as an ordinary button, and the person cannot tell whether they are heard. A card drawn as chosen is announced as nothing at all. A state that is set once and never updated is worse: it tells the opposite of what the screen shows. [WCAG 2.2, 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG22/#name-role-value) requires that states the person can change can also be set by software, and that changes are passed on to assistive technology. Its explanation adds that states can be read by software, and names checked, selected and expanded among those states, and custom toggles and disclosures among the controls. [1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships) supports it: what the look tells must also be in the code. The criterion does not say which element or attribute to use.

### Do

- Use the components that set the state for you: shadcn's `Toggle`, `ToggleGroup`, `Checkbox`, `RadioGroup`, `Switch`, `Tabs`, `Accordion`, `Collapsible`, `Select`, `DropdownMenuCheckboxItem` and `DropdownMenuRadioItem`. Each exposes its state in code and as `data-state` for styling.
- In a video call's toolbar, *Mute* is a `Toggle` with the fixed name "Mute", so a screen reader announces it as pressed when it is on. A *Favourite* star built from a `Button` gets `aria-pressed={isFavourite}` and keeps its name.
- Or let the name follow the state instead, as a *Play* button that becomes *Pause*. Use one way or the other, not both: a name that changes and `aria-pressed` together report the state twice.
- On a checkout page, the delivery options *Standard* and *Next day* are cards. Build them as a `RadioGroup` with a `RadioGroupItem` and a `Label` in each card, so the chosen card is checked in code. Reaching them by keyboard is KBD-001.
- In a list of options with `role="listbox"`, put `aria-selected` on the chosen `role="option"` element. In a menu, a checkable item is `menuitemcheckbox` or `menuitemradio` with `aria-checked`.
- In shadcn's `Command`, `aria-selected` marks the option under the cursor, not the chosen value. In a combobox with one choice, the trigger's text names the chosen value; if the open list also marks it with a check, give that option its own state, such as `aria-checked`, or hidden text. In a list where several values can be chosen, every chosen option needs that state.
- The button *Show filters* carries `aria-expanded={open}`, and the value changes every time the panel opens or closes.
- A control that is off is off in code: `disabled`, or `aria-disabled="true"` with a guard that ignores the press. When a control may be off at all is ACT-004, ACT-005 and STA-005b.
- Our own advice: style the state from the attribute, as in `aria-pressed:bg-accent` or `data-[state=on]:bg-accent`, so the look cannot drift from the code.
- Our own advice: use a native element where one exists, such as a checkbox or a `button` with `aria-expanded`, and ARIA only when there is none.

### Don't

- Draw *Bold* as on with `className={bold ? "bg-accent" : ""}` on a plain `Button` and leave `aria-pressed` out.
- Build the delivery cards as `<Card onClick>` with `border-primary` on the chosen one and no checked state.
- Rotate the chevron on *Show filters* and never set `aria-expanded`, or set it on first render and never update it.
- Fade a button with `opacity-50 pointer-events-none` while it is still enabled in code, so Enter runs it and a screen reader calls it an ordinary button.
- Put `aria-disabled="true"` on a control that still looks usable and still does its job when pressed.
- Hard-code `aria-pressed={true}`, or put `aria-selected` on the `li` around a button instead of on the element with the role.

### Exceptions

- **Focus.** Focus is a state too, but the browser sets it. Its visible look is KBD-001.
- **The visible side.** How a state looks is VIS-003a (more than colour), VIS-004 (3:1) and VIS-008b (a lasting state kept visible under hover, focus and press).
- **Narrower rules come first.** The current page in a menu is NAV-002a, which uses `aria-current`, never `aria-selected`, on a link. The sort order of a column sits on its header cell as `aria-sort`, not on the sort button, as TBL-002 says.
- **Neighbouring rules.** A control's role is ACT-009, its name ACT-001b and FRM-010. That a choice control only records the choice is FRM-012b.

### How to check

Checked by reading the code: the break shows for certain in it. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A class switched by a boolean such as `selected`, `active`, `checked` or `open`, as in `cn(…, selected && "bg-accent")`, on an element with `onClick` and no matching `aria-pressed`, `aria-selected`, `aria-checked`, `aria-expanded`, `aria-current`, `aria-sort` on its header cell, or Radix or cmdk `data-state`.
- `opacity-50`, `pointer-events-none` or `cursor-not-allowed` applied by a condition to a button, link or field that gets neither `disabled` nor `aria-disabled` under the same condition.
- A literal state that never changes, such as `aria-pressed="true"` or `aria-expanded={true}`, or a state set on a wrapping `li` or `div` instead of the element with the role.
- `aria-disabled="true"` on a control whose handler still runs its action.

<a id="vis-008b"></a>

## VIS-008b Keep a selected or on state visible while the item is hovered, focused or pressed

Rule. Verdict: Unanimous (3 of 3). Status: proposed. https://blackwoodblake.com/design-system/patterns/vis-008b/

### Rule

A state that lasts, such as selected, checked, on or current, stays visible while the same item is also hovered, focused or pressed. The look of hover, focus or press is never the same as the look of a state that lasts.

### Why

Hover, focus and press come and go with the pointer, the keyboard and the finger. Selected, checked, on and current stay until the person changes them. If the passing look wipes out the lasting one, the selected item turns into any other hovered item the moment the person points at it, which is exactly when they are checking what they chose. If the two looks are the same, the person cannot tell the item they chose from the item under the pointer, or from where the keyboard is. They may leave believing the wrong plan is chosen, or press a toggle again because it seemed already on. No WCAG criterion asks that states combine or differ from each other. [WCAG 2.2, 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) only adds that a hover must not make the cue for focus or selection lose contrast, which VIS-004 carries, and [1.4.1 Use of Color](https://www.w3.org/TR/WCAG22/#use-of-color) supports keeping a cue that does not rest on a tint. The rule rests on the judges.

### Do

- Let the looks add up. In a toolbar's `ToggleGroup` for *Bold*, *Italic* and *Underline*, an item that is on keeps its on look while hovered: scope the hover to items that are off, as in `data-[state=off]:hover:bg-muted`, or give the on state a hover of its own, such as `data-[state=on]:hover:bg-primary/90` where on is `bg-primary`.
- On a pricing page, the chosen plan card carries a check icon and the text "Selected", as VIS-003a asks. Hover changes only the card's fill, so the check and the word are still there under the pointer.
- When the same token draws hover and selected, which VIS-002 allows for `bg-accent`, give the selected item a cue the hover does not use, such as a check, a bar beside it or heavier text. VIS-002 picks the token, VIS-003a asks for the second cue, and this rule keeps the two looks apart and the lasting one in place.
- In a data table with selectable rows, keep the checkbox column. A selected row in `bg-muted` and a hovered row in `bg-muted/50` differ only slightly, and the checked box is what shows the selection under the pointer.
- A selected item that gets focus shows both: the focus indicator that KBD-001 describes and its selected look.
- In `Select`, `Command` and menus, the highlighted row under the pointer or keyboard gets `bg-accent`, and the chosen value shows a check. Keep it that way. The highlight moves; the chosen value must not depend on it.
- In a sidebar, hovering the current page's item does not remove its mark. shadcn's `SidebarMenuButton` draws both `data-[active=true]:` and `hover:` with `bg-sidebar-accent`, so under the pointer any item looks current unless the current one keeps another mark, such as its `font-medium` or a bar beside it. The mark itself is NAV-002b.
- Style the lasting state from the state in code, as in `aria-pressed:` or `data-[state=on]:`. That is VIS-008a's own advice, and it also keeps the selected look from drifting when the hover classes change.

### Don't

- Give the selected item `bg-primary text-primary-foreground` and every item `hover:bg-accent hover:text-accent-foreground`, so the selected item looks like any other once the pointer is on it.
- Mark a chosen card with `ring-2 ring-ring`, the look of focus. VIS-002 keeps `ring` for focus.
- Draw focus as `focus:bg-accent` on items whose selected look is also only `bg-accent`.
- Give *Undo* in a toolbar the same `active:` fill that *Bold* uses for on, so a press on *Undo* looks like a toggle switching on.
- Hide the check on the chosen option with `group-hover:hidden` and show an arrow in its place.

### Exceptions

- **The change itself.** When a press switches a toggle on or off, the lasting look changes, as it should. The rule asks only that hover, focus and press do not hide or imitate it.
- **How far apart.** How much the looks must differ is not set here. A state told by colour alone is VIS-003a, and the contrast of a state mark, also while hovered, is VIS-004.
- **Neighbouring rules.** Whether hover and press looks exist at all is VIS-008. The focus look is KBD-001. The current page's mark is NAV-002b. The state in code is VIS-008a.

### How to check

Checked by judgement: someone has to weigh what the code does. Each item is a sign the rule may be broken; code that follows the rule never matches.

- A `hover:bg-*` or `hover:text-*` class on an item whose selected or on state is drawn only by `bg-*` and `text-*` classes, with no variant that keeps the hover off the selected item and no icon, bar or text for the state.
- The same classes under `hover:`, `focus:` or `active:` as under `data-[state=on]:`, `aria-selected:`, `aria-pressed:` or the conditional selected class, when the state has no other cue.
- The focus look's own classes, such as `ring-ring` or `outline-ring`, used to show a selected, checked or on state.
- A check icon, bar or badge for the state hidden on hover or focus, such as `group-hover:hidden`.

---

Rule texts © Carl Magnus Swahn and Justified contributors, licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Generated from 79 rules and 23 guidelines.
