# Aria Patterns Applies to files matching `**/*.{html,jsx,tsx,vue,svelte,astro}`. Part of the `kb-path-instructions` skill. ## Dependencies - `web-accessibility-baseline.md` (same folder) - WCAG AA baseline rules this file extends - `semantic-html.md` (same folder) - native HTML alternatives to prefer before reaching for ARIA roles When generating custom interactive widgets, apply these role-specific ARIA patterns. Each pattern defines the required markup structure, required attributes, and mandatory keyboard behavior. These patterns follow the WAI-ARIA Authoring Practices Guide (APG). > **Impact:** Using an ARIA role without its required keyboard pattern creates a widget that is completely unusable by keyboard-only users and confusing to screen reader users who expect specific key behaviors based on the announced role. **Golden rule:** Only use `role="menu"` / `role="tab"` / `role="tree"` / etc. when you also implement the full keyboard interaction pattern for that role. Partial ARIA is worse than no ARIA. ## Required Keyboard Behavior by Role Every role below requires the listed keys to be fully implemented before using that role. Missing any required key makes the pattern non-conformant. | Role | Required Keys | Navigation Pattern | |------|--------------|--------------------| | `tab` / `tablist` | Arrow Left/Right, Home, End; Tab exits into panel | Roving tabindex | | `dialog` | Tab/Shift+Tab (trapped inside), Escape | No - use `tabindex="-1"` on container, manage focus explicitly | | `combobox` | Down/Up Arrow, Enter (select), Escape (close), Tab (accept + move) | `aria-activedescendant` | | `menu` / `menuitem` | Down/Up Arrow, Home, End, Escape, Tab (closes menu) | Roving tabindex | | `tree` / `treeitem` | Down/Up Arrow, Right (expand), Left (collapse), Home, End | Roving tabindex | | `listbox` / `option` | Down/Up Arrow, Home, End, Enter/Space (select) | Roving tabindex | | `grid` / `gridcell` | All four Arrow keys, Home/End (Page Up/Down optional) | Roving tabindex or `aria-activedescendant` | > **Roving tabindex:** Only one item in a composite widget has `tabindex="0"` at any time; all others have `tabindex="-1"`. When focus moves via arrow keys, set the new item to `tabindex="0"` and the previous to `tabindex="-1"`. Tab enters and exits the whole widget as one focus stop; arrow keys navigate internally. See [APG Roving tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex). --- ## Tabs ```html