12k
All articles

Building Accessible Components with Angular Aria

Build accessible Angular tabs and multi-select listboxes with Angular Aria. Explore keyboard behavior, signal binding, styling, screen reader checks, and harness tests.

OpenReplay Team
OpenReplay Team
Building Accessible Components with Angular Aria

Angular Aria (@angular/aria) is a set of headless Angular directives that implement WAI-ARIA patterns. The directives handle keyboard interaction, focus management and ARIA attributes, and they ship no styles, so the markup and CSS stay under your control.

If you have ever hand-written roving tabindex logic for a tab strip and then found that Home and End do nothing, or that a screen reader announces your “listbox” as a pile of generic groups, you already know why this package exists.

This guide builds two widgets on the Angular v22 documentation for @angular/aria: a tab set with explicit activation, and a multi-select listbox bound to a signal. It then shows how to check both in DevTools and with a screen reader, and how to cover the tabs with a component harness test. If you work in React, the equivalent library is React Aria.

Key Takeaways

  • Angular Aria launched as a developer preview in Angular v21 and became stable in Angular v22, alongside Signal Forms and the async signal APIs.
  • With selectionMode="explicit", the arrow keys only move focus between tabs, and the user presses Space or Enter to activate one. With selectionMode="follow", a tab is selected as soon as it receives focus.
  • Angular Aria puts inert on hidden tab panels, which takes them out of the accessibility tree. It does not hide them visually, so you need a CSS rule such as [ngTabPanel][inert] { display: none; }.
  • The listbox value is a model signal that always holds an array, so [(value)]="channels" keeps a signal<string[]> in your component in sync with what the user selects.
  • The directives give you roles, states, keyboard behaviour and focus. Accessible names, colour contrast and a visible focus indicator are still your job.

What Is Angular Aria?

Angular Aria is a headless directive library that gives you behaviour without appearance. You write the elements, add a directive, and the directive applies roles, ARIA states, keyboard handlers and focus movement that follow the WAI-ARIA Authoring Practices patterns. It is aimed at teams that run their own design system and don’t want Angular Material’s visual opinions.

The Angular Aria overview documents twelve patterns: Autocomplete, Listbox, Select, Multiselect, Combobox, Menu, Menubar, Toolbar, Accordion, Tabs, Tree and Grid. The package arrived in Angular v21 as a developer preview. In v22 it was promoted to stable: the Angular v22 release page lists Signal Forms, Asynchronous Signals, and Angular Aria among the APIs that are now stable. Angular v22 was released on June 3, 2026.

Angular Aria directives do not make a component compliant on their own. You still have to meet WCAG 2.4.7 Focus Visible, contrast requirements, and give each widget an accessible name.

Install Angular Aria

To install Angular Aria, run one npm command. Angular Aria uses @angular/cdk internally, and the test harnesses depend on @angular/cdk/testing, so install the CDK as well if your project doesn’t already have it:

npm install @angular/aria @angular/cdk

Each pattern has its own entry point, such as @angular/aria/tabs or @angular/aria/listbox. Import only the directives you use into a standalone component’s imports array.

Build Accessible Tabs with Angular Aria

Angular Aria tabs come in two selection modes. In follow mode, focusing a tab selects it. In explicit mode, focus and selection are separate actions. The example below uses explicit mode, which the APG Tabs pattern recommends when a panel cannot be displayed without noticeable latency.

// settings-tabs.ts — imports from '@angular/aria/tabs'
import { Component } from '@angular/core';
import { Tabs, TabList, Tab, TabPanel, TabContent } from '@angular/aria/tabs';

@Component({
  selector: 'app-settings-tabs',
  imports: [Tabs, TabList, Tab, TabPanel, TabContent],
  templateUrl: './settings-tabs.html',
  styleUrl: './settings-tabs.css',
})
export class SettingsTabs {}
<!-- settings-tabs.html -->
<div ngTabs>
  <div ngTabList
       selectionMode="explicit"
       orientation="horizontal"
       selectedTab="profile"
       [softDisabled]="true"
       aria-label="Account settings">
    <div ngTab value="profile">Profile</div>
    <div ngTab value="notifications">Notifications</div>
    <div ngTab value="billing" disabled>Billing</div>
  </div>

  <div ngTabPanel value="profile">
    <ng-template ngTabContent>Profile form goes here.</ng-template>
  </div>
  <div ngTabPanel value="notifications">
    <ng-template ngTabContent>Notification preferences go here.</ng-template>
  </div>
  <div ngTabPanel value="billing">
    <ng-template ngTabContent>Billing details go here.</ng-template>
  </div>
</div>

ngTabList carries all the configuration. Each ngTab is paired with the ngTabPanel that has the same value. Wrapping a panel’s content in ng-template ngTabContent defers rendering until the panel is shown, and the content is removed again when the panel is hidden. Add [preserveContent]="true" to a panel if its content needs to stay mounted, for example a form with unsaved input. Setting [softDisabled]="true" keeps the disabled Billing tab focusable but not activatable. With false, arrow-key navigation skips it.

To use selection-follows-focus instead, change one attribute to selectionMode="follow".

The Angular Aria Tabs guide documents this keyboard map:

KeyExplicit modeFollow mode
Left / Right arrowMoves focusMoves focus and selects
Up / Down arrow (orientation="vertical")Moves focusMoves focus and selects
Home / EndFocuses the first / last tabFocuses and selects the first / last tab
Space / EnterActivates the focused tabNot needed

Style Tabs with ARIA Attributes

Angular Aria exposes state through standard attributes, so you write attribute selectors instead of toggling classes. According to the TabPanel API reference, a hidden panel gets inert, which takes it out of the accessibility tree. It stays visible until your CSS hides it.

/* settings-tabs.css */
[ngTab] { padding: 0.5rem 1rem; cursor: pointer; }
[ngTab][aria-selected='true'] { border-bottom: 2px solid currentColor; font-weight: 600; }
[ngTab][aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
[ngTab]:focus-visible { outline: 2px solid #1a73e8; outline-offset: 2px; }
[ngTabPanel][inert] { display: none; }

The :focus-visible rule applies to every tab state, including the selected one. If you strip outlines anywhere in your design system, put back a focus style that covers selected tabs too.

Build a Multi-Select Listbox with Angular Aria

The Angular Aria listbox’s value is a two-way model, so [(value)] binds it directly to a writable signal. The Listbox API reference types it as ModelSignal<V[]>, which means it is always an array, even for single selection. If you are new to writable signals, read Understanding Signals in Angular first.

// channel-picker.ts — imports from '@angular/aria/listbox'
import { Component, signal } from '@angular/core';
import { Listbox, Option } from '@angular/aria/listbox';

@Component({
  selector: 'app-channel-picker',
  imports: [Listbox, Option],
  template: `
    <div ngListbox
         [(value)]="channels"
         [multi]="true"
         orientation="vertical"
         selectionMode="explicit"
         aria-label="Notification channels">
      @for (o of options; track o) {
        <div ngOption [value]="o">{{ o }}</div>
      }
    </div>
    <p>Selected: {{ channels().join(', ') }}</p>
  `,
  styleUrl: './channel-picker.css',
})
export class ChannelPicker {
  readonly options = ['Email', 'SMS', 'Push', 'Slack'];
  readonly channels = signal<string[]>(['Email']);
}

The <p> underneath updates whenever the selection changes, which shows the model writing back to the signal. For single selection, set [multi]="false". The signal is still a string[], holding at most one item.

The Angular Aria Listbox guide describes the keyboard behaviour, which matches the APG Listbox pattern:

  • Up and Down arrows move focus. With orientation="horizontal", Left and Right do it instead, and the direction reverses automatically in RTL layouts.
  • In explicit mode, Space or Enter toggles the focused option. In follow mode, moving focus changes the selection.
  • Typing a character moves focus to the next option that matches. The delay is configurable through the typeaheadDelay input.

Use a standalone listbox only for lists that are always visible on the page. For dropdowns, use the Select, Multiselect or Autocomplete patterns, which are built on top of the listbox.

/* channel-picker.css */
[ngOption] { padding: 0.375rem 0.75rem; }
[ngOption][data-active='true'] { outline: 2px solid #1a73e8; }
[ngOption][aria-selected='true'] { background: #e8f0fe; }
[ngOption][aria-selected='true']::before { content: '✓ '; }

data-active marks the option the keyboard is currently on. aria-selected marks the chosen options. Style them differently, because sighted keyboard users need to see where they are and what they have picked.

StateAttribute writtenSelector
Selected tabaria-selected="true"[ngTab][aria-selected='true']
Disabled tabaria-disabled="true"[ngTab][aria-disabled='true']
Hidden panelinert[ngTabPanel][inert]
Active optiondata-active="true"[ngOption][data-active='true']
Selected optionaria-selected="true"[ngOption][aria-selected='true']

Check Angular Aria Components in DevTools and a Screen Reader

Verify Angular Aria tabs and listboxes in two passes. First inspect the accessibility tree in the browser, then use the widgets with a real screen reader. Chrome’s Accessibility pane reference explains how to view the tree and the computed role, name and state of each node.

In the Accessibility pane, look for the following:

  1. The tab list has the role tablist and the name “Account settings”.
  2. Each tab has the role tab. Only one reports selected as true, and Billing reports disabled.
  3. Only the visible panel appears with the role tabpanel. Inert panels are missing from the tree.
  4. The listbox has the role listbox, the name “Notification channels”, and is marked as multi-selectable.
  5. Every option has the role option and a selected state that matches the signal.

Next, use the widgets with VoiceOver (Cmd+F5 on macOS) or NVDA on Windows, keyboard only. The exact wording differs between screen readers and versions, but you should hear:

  • On a tab: its label, the “tab” role, whether it is selected, and its position, such as two of three.
  • On Billing: that it is unavailable or dimmed.
  • On entering the listbox: its name and that it supports multiple selection.
  • On each option: its label, its selected state, and its position in the list.

Unit tests rarely catch focus that drops to <body> when panel content is torn down, or a focus ring removed by a global stylesheet. Session replays of keyboard-only users show exactly where focus lands after each keypress.

Test Angular Aria Tabs with Component Harnesses

Angular Aria provides component harnesses so tests talk to the widget the way a user does, without depending on DOM selectors. TabsHarness lives in @angular/aria/tabs/testing and runs in the CDK’s TestbedHarnessEnvironment.

// settings-tabs.spec.ts — imports from '@angular/aria/tabs/testing'
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { TabsHarness } from '@angular/aria/tabs/testing';
import { SettingsTabs } from './settings-tabs';

describe('SettingsTabs', () => {
  let fixture: ComponentFixture<SettingsTabs>;
  let loader: HarnessLoader;

  beforeEach(async () => {
    await TestBed.configureTestingModule({ imports: [SettingsTabs] }).compileComponents();
    fixture = TestBed.createComponent(SettingsTabs);
    await fixture.whenStable();
    loader = TestbedHarnessEnvironment.loader(fixture);
  });

  it('selects a tab explicitly', async () => {
    const tabsHarness = await loader.getHarness(TabsHarness);
    const tabs = await tabsHarness.getTabs();

    expect(tabs.length).toBe(3);
    expect(await tabs[0].isSelected()).toBe(true);

    await tabs[1].select();

    expect(await tabs[1].isSelected()).toBe(true);
    expect(await tabs[0].isSelected()).toBe(false);
  });
});

The SettingsTabs spec tests the component built above: three tabs, with Profile selected first. select() activates Notifications, which is what explicit mode requires. For the listbox, ListboxHarness from @angular/aria/listbox/testing provides isMulti(), getOptions() and per-option isSelected() for the same kind of assertion.

Conclusion

Angular Aria takes over the keyboard, focus and ARIA work for custom widgets. What you keep is markup, attribute-selector styling and accessible names. Add the CSS rule that hides [inert] panels and a visible focus style for every state, bind the listbox to a signal, and check the accessibility tree before you ship. Then apply the same steps to the next pattern your design system needs. Accordion and Toolbar follow the same directive model.

FAQs

What is the difference between Angular Aria, the Angular CDK and Angular Material?

Angular Material ships fully styled Material Design components with accessibility built in, so they need no Angular Aria directives on top. The Angular CDK provides lower-level unstyled primitives such as overlays, drag and drop, ListKeyManager and FocusTrap, and leaves you to put together roles and patterns yourself. Angular Aria sits between the two: it provides complete WAI-ARIA patterns such as tabs, listbox and menu, with no styles.

Can I style Angular Aria components with Tailwind CSS?

Yes. Since v3.2, Tailwind has built-in aria variants, so aria-selected:font-semibold and aria-disabled:opacity-50 match attributes set to 'true'. For the active listbox option, use the arbitrary form data-[active=true]:outline. Don't use the bare data-active variant in Tailwind v4, because it matches whenever the attribute exists, whatever its value. Hide inert tab panels with an arbitrary variant such as [&[inert]]:hidden.

Can I use Angular Aria directives in an NgModule-based app?

Yes. Angular Aria directives are standalone, and since Angular v14 an NgModule can list standalone directives in its imports array. Add the directive classes you need, such as Tabs, TabList, Tab, TabPanel and TabContent, or Listbox and Option, to the module's imports. Every component declared in that module can then use them in its templates.

Should I use Angular Aria in an Angular v21 project?

You can, but in Angular v21 Angular Aria is a developer preview. Angular does not apply its usual deprecation policy to developer preview APIs, so they can change between releases. The v21 release shipped eight patterns. Angular Aria became stable in Angular v22, and the API names in this guide come from the v22 documentation. Upgrading to v22 first means you avoid rewriting code when the preview APIs change.

DevTools for the frontend

Gain Debugging Superpowers

Unleash the power of session replay to reproduce bugs, track slowdowns and uncover frustrations in your app. Get complete visibility into your frontend with OpenReplay — the most advanced open-source session replay tool for developers.

Star on GitHub12k

We use cookies to improve your experience. By using our site, you accept cookies.