Frontend accessibility guidelines¶
This guide describes the accessibility decisions frontend code in app/frontend/src/ must make for controls, forms, and dialogs. Design System components provide semantics, IDs, and focus styles for common cases, but using a DS component does not make a feature accessible on its own: names, structure, states, and keyboard flow still depend on how the feature composes it. Verify the rendered DOM and the keyboard flow for every change.
Use native semantics first¶
- Use a
<button>orDSButtonfor actions andDSLink(or a native<a href>) for navigation.DSButtonwithhrefrenders<a role="button">and is announced as a button, so use it only for a navigation that deliberately acts as a button. Do not attach click handlers todivorspan. - Use headings in document order, lists for lists,
DSTableor<table>for tabular data, and<form>with a submit button for forms, so Enter submits. - Add ARIA only when no native element expresses the role or state. A custom widget with
rolemust also implement the keyboard behaviour that role implies. - Give a button outside a form an explicit
type;DSButtondefaults totype="button".
Keep every interaction reachable by keyboard¶
- Every pointer action needs a keyboard path. Tab reaches a standalone control, and Enter or Space activates it. Hover-only and drag-only actions need a focusable alternative.
- A composite widget (tabs, radio group, listbox, menu) is one Tab stop: Tab moves into and out of it, and the keys of its role move inside.
DSTabsgives only the selected tabtabindex="0"and moves with the arrow keys, Home, and End. - Keep the Tab order equal to the DOM and visual order. Do not use a positive
tabindex; usetabindex="0"only for a custom focusable element and-1only for programmatic focus targets. - Escape closes the topmost popover, menu, or dialog.
- When content that holds focus disappears (a deleted row, a closed panel), move focus to a logical neighbor or to the control that opened it, never to
<body>. - Do not remove focus outlines. DS components style
:focus-visible; follow Visual states for custom styles.
Name every control¶
- Visible text is the preferred accessible name. Icon-only controls need a translated
ariaLabelthat describes the action; follow Separate decorative icons from labelled actions. - Names must be unique enough out of context: "Delete comment" rather than repeated "Delete" buttons in a list. Use
ariaDescribedByonDSButtonto point to extra context when the name alone is ambiguous. - Do not put the only name or instruction into a placeholder or tooltip.
Label fields with unique IDs¶
Use a DS field component (DSTextField, DSTextarea, DSSelect, ...) with a label. It renders DSFormField, whose label is linked to the input through the same id. When the design has no visible label, keep label and set hiddenLabel: the caption is hidden visually but stays available to assistive technology.
The field ID comes from useDSFormFieldId (design_system/form_elements/shared/composables/useDSFormFieldId.ts): an explicit id wins, otherwise it generates <name>-<uuid>. Omit id unless other markup must reference the field. If you pass one, you own its uniqueness, for example by including the record ID in repeated rows.
<DSTextField
v-model="subject"
name="subject"
:label="subjectLabel"
:error-messages="subjectErrors"
required
/>
Keep disabled and error states consistent¶
- Disable through the component's
disabledprop, not through a class orpointer-events.DSButtonrenders a nativedisabledbutton; withhrefit removes the link target and setsaria-disabled="true"andtabindex="-1". - Disabled controls cannot receive focus, so do not explain a disabled state only in a tooltip on the control itself. Use visible text or the focusable-wrapper pattern in Tooltip.
- Prefer
readonlyoverdisabledwhen the value must stay focusable and readable. - Report field errors through
errorMessagesorrules, not only by a red border:DSFormFieldrenders each message as text with its own ID. Check that the input exposesaria-invalidand anaria-describedbypointing to the messages; field components differ in this wiring (compareDSUrlFieldwithDSTextField), so fix a gap in the DS component instead of patching DOM from the feature. - After a failed submit, keep the entered values and move focus to the first invalid field or to a summary.
Convey information beyond colour and tooltips¶
- Pair colour with text or a labelled icon for status, priority, and validation. A coloured dot or border alone is not enough.
- Tooltips are supplemental. Never put the only indication of state, an essential instruction, or a control into one (Tooltip).
- Show asynchronous results that do not move focus (saved, failed, loading finished) as visible text near the action, not only as a colour change or an icon swap. Visible text alone is not announced: render it in a live region.
DSAlertsets one by variant (role="status"witharia-live="polite"for info and success,role="alert"witharia-live="assertive"for warning and danger); for custom markup userole="status"for routine results androle="alert"only for urgent errors.
Manage focus in dialogs¶
Use DSDialog (design_system/layouts_and_containers/dialog/). It renders a native <dialog>. The default type="modal" opens with showModal(), keeps Tab inside the dialog (useFocusTrap), and closes on Escape or a backdrop click while closeable is true. type="dialog" is non-modal: it neither traps focus nor closes on Escape.
- Name the dialog with the
headerprop; it is linked througharia-labelledby. A custom#headerslot is not linked automatically, so give the dialog anaria-label(it falls through to<dialog>). - On open, the browser focuses the first focusable element, or a native element marked
autofocus. To start in a DS field instead, call thefocus()method it exposes (for exampleDSTextField) after the dialog opens; anautofocusattribute on a DS field component lands on its wrapper, not on the input. - With
:closeable="false", Escape does not close the dialog and no close button is rendered; the footer must contain a keyboard-reachable way out, such as its action buttons. - After closing, verify that focus returns to the control that opened the dialog, or to a logical neighbor if that control no longer exists.
<DSDialog
v-model:open="isOpen"
:header="dialogTitle"
>
<DSTextField
v-model="name"
name="name"
:label="nameLabel"
/>
</DSDialog>
Verify before merge¶
Test the changed flow without a mouse and inspect the DOM in browser devtools (Elements and Accessibility panels):
- [ ] Tab reaches every standalone control and every composite widget in visual order, the keys of its role move inside a composite widget, and focus is always visible.
- [ ] Enter or Space activates every control; Escape closes the open popover, menu, or dialog.
- [ ] Every control has a meaningful accessible name; icon-only controls have a translated
aria-label. - [ ] Every field label points to an existing, unique ID, and no two elements on the page share an
id. - [ ] Disabled and error states are exposed in the DOM (
disabled,aria-disabled,aria-invalid,aria-describedby) and explained in text. - [ ] Asynchronous results that do not move focus are rendered in a live region.
- [ ] Dialogs have a name, keep focus inside while modal, and return focus after closing.
- [ ] No information depends only on colour, hover, or a tooltip.
Integration tests may assert these attributes and focus moves where the behaviour belongs to the feature. See Testing and the DS guide Design system for component APIs.