ARIA and Accessible Custom Widgets
When and how to use ARIA roles, states and properties, and how to build modals, menus, tabs and comboboxes that assistive tech understands.
Advanced · about 5 hours · difficulty 4/5
Learn first: WCAG and Inclusive Design Principles, Events and Event Delegation
ARIA (Accessible Rich Internet Applications) is a set of attributes that tell assistive technologies what a custom element is, what state it is in and how it relates to other elements. It changes the accessibility tree only; it adds no behaviour.
The first rule of ARIA
Do not use ARIA if a native element does the job. A <button> is focusable, clickable with Enter and Space and announced as a button for free. A <div role="button"> needs tabindex, key handlers and more. "No ARIA is better than bad ARIA": incorrect roles actively mislead users.
The three parts
- Roles: what it is (
dialog,tablist,tab,menu,alert,combobox). - States and properties:
aria-expanded,aria-selected,aria-checked,aria-disabled,aria-invalid,aria-current="page". - Relationships and names:
aria-labelledby,aria-describedby,aria-controls, andaria-labelwhen there is no visible label.
Live regions
aria-live="polite" or role="status" announce dynamic updates such as "3 results found" or "Saved"; role="alert" for urgent errors. The region must exist in the DOM before its content changes.
Common widgets
Follow the ARIA Authoring Practices Guide (APG) patterns for keyboard and ARIA behaviour: disclosure, dialog (modal), tabs, menu button, combobox and listbox. Prefer native <dialog> and <details> where suitable, or a headless library like Radix or React Aria that implements these patterns correctly.
Good enough to move on
You can explain the accessibility tree, pick native elements over ARIA, correctly build a disclosure and tabs widget following APG, and announce async results with a live region.
Key concepts
- The accessibility tree
- First rule of ARIA: prefer native HTML
- Roles, states and properties
- Accessible names and descriptions
- Live regions
- ARIA Authoring Practices patterns
- Headless libraries: Radix, React Aria
Mini project
Build an accessible tabs component and a menu button following the APG patterns (roles, states, arrow-key navigation), plus a search page that announces the result count with a live region.
Check yourself
Why is adding role="button" to a div not enough to make it an accessible button?
Free resources
- ARIA Authoring Practices Guide (W3C WAI)
- ARIA (MDN)