Full answer
Accessibility means that people using a keyboard, a screen reader, or other assistive tools can use the app. Angular does not make an app accessible by itself, so the practices belong in your templates.
- Use native elements. A
buttonis focusable, reacts to Enter and Space, and is announced as a button. Adiv (click)is none of these. Useafor navigation andbuttonfor actions. - Label every field.
<label for="email">with a matchingid, oraria-labelfor an icon button. Placeholders are not labels. - Show errors in a way assistive tools can find:
role="alert"oraria-live="polite"on the message, andaria-invalidplusaria-describedbyon the input. - ARIA bindings use attribute binding:
[attr.aria-expanded]="open()". Property binding does not work for ARIA names such asaria-label. - Keep keyboard focus visible and logical. Do not remove outlines without a replacement. After a route change, move focus to the page heading or announce the new title (the router can set the page title for you).
- Announce dynamic updates (a toast, a result count) with a live region. The Angular CDK has
LiveAnnouncerfor this. - Do not rely on colour only. Text contrast should meet WCAG AA (4.5:1 for normal text).
- Images need
alttext, oralt=""when decorative.
Tools: the Angular template compiler does not check accessibility, but ESLint rules from angular-eslint (the template accessibility set) catch many mistakes. Test with a keyboard only, then with a screen reader, and run automated checks such as axe in CI.
ARIA rule: first use a native element. Add ARIA only when no native element has the meaning you need.
typescript
import { Component, signal } from '@angular/core';
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
@Component({
selector: 'app-accessible-form',
imports: [ReactiveFormsModule],
template: `
<h1 tabindex="-1">Join the club</h1>
<label for="name">Full name</label>
<input
id="name"
[formControl]="name"
[attr.aria-invalid]="name.invalid && name.touched"
[attr.aria-describedby]="name.invalid && name.touched ? 'name-error' : null"
/>
@if (name.invalid && name.touched) {
<p id="name-error" role="alert">Please enter your name.</p>
}
<button type="button" [attr.aria-expanded]="open()" aria-controls="help" (click)="open.set(!open())">
Help
</button>
@if (open()) {
<div id="help">Use your name as it appears on your ID card.</div>
}
<button type="button" aria-label="Close dialog">
<span aria-hidden="true">x</span>
</button>
`,
})
export class AccessibleFormComponent {
readonly name = new FormControl('', { nonNullable: true, validators: [Validators.required] });
readonly open = signal(false);
}Angular 20.3, strict template check passes. The error message is linked to the input with `aria-describedby`, and the toggle button reports its state with `aria-expanded`.
Key points
- Native elements first: `button`, `a`, `label`, `nav`, headings.
- Bind ARIA with `[attr.aria-*]`. Connect inputs to labels and errors.
- Manage focus after navigation, and announce dynamic updates.
- Test with the keyboard and a screen reader. Lint templates for common errors.
Common mistakes
- Using a clickable `div` instead of a `button`.
- Binding `[aria-label]` as a property, which does not exist. Use `[attr.aria-label]`.
- Removing the focus outline for looks and leaving no visible focus style.
Follow-ups
- How would you announce that a list finished loading?
- What does `aria-describedby` do on a form field?
- How do you handle focus when a modal dialog opens and closes?
Tips
- Say "native first, ARIA second". It is the sentence reviewers expect.
- Mention keyboard-only testing, which costs nothing.
- Name `LiveAnnouncer` from the CDK for dynamic announcements.
Evaluation rubric
- Prefers semantic HTML and labels.
- Uses attribute binding for ARIA correctly.
- Mentions focus management and testing.