ARIA examples
Each grid on this page holds 10,000 items and shows one of the ARIA patterns from the accessibility guide. Each demo's source link opens its component.
List with item positions
The grid has role="list", and each item has role="listitem", aria-setsize and aria-posinset.
Check it:
- Scroll to the middle of the list, then move the screen reader cursor onto an item. The announced position matches the item's number, for example 4,200 of 10,000.
- Scroll the grid and select an item again. The announced position follows the item, not its place among the rendered elements.
Build it with Add list roles and Set the size and position of each item.
Listbox with a selected option
The grid has role="listbox" and an aria-label, and each item is an option with aria-selected.
Check it:
- Click an option. Its ring appears, and its
aria-selectedchanges totruein the Elements panel of the browser's developer tools. - With a screen reader running, move its cursor onto the option and listen for "selected".
Build it with the listbox and option roles.
Busy placeholders
The page provider takes 1.5 seconds, so scrolling shows placeholders. Each placeholder has aria-busy="true" and keeps its position in the set.
Check it:
- Scroll the grid. Gray placeholders appear before the items load.
- Right-click a placeholder before it loads and choose Inspect. The Elements panel shows
aria-busy="true"on the element, with the samearia-posinsetthe loaded item gets. - Wait 1.5 seconds. The grid replaces the placeholder with the item, which has no
aria-busy.
aria-busy on a list item. Some say "busy" and some say nothing, so move the screen reader cursor onto a placeholder and note what yours says.Build it with Mark placeholders as busy.
Keyboard navigation
Press Tab to enter the grid, then use the arrow keys. The focus ring follows the focused item. The grid scrolls only when the item would leave the view, and only far enough to show it.
Check it:
- Press Tab until the focus reaches the grid. The first item has a focus ring.
- Press the arrow keys. The focus moves one item or one row in that direction.
- Hold the down arrow with a screen reader running. The grid scrolls, and the announced position keeps climbing.
Build it with Keep the focused index in a ref, Scroll to the new item and focus it, and Listen for arrow keys on the grid.
Test it
A screen reader announces facts that hold for every item: its role, its name and its position, for example 4,200 of 10,000. The exact wording and the order vary by screen reader and browser, so check the facts and not a fixed sentence.
macOS VoiceOver
- Press Cmd + F5 to start VoiceOver.
- Move through the page with the VO keys (Ctrl + Option) and the arrow keys.
- Press VO + U to open the rotor and list the page's lists and items.
Windows NVDA
NVDA is a screen reader for Windows that costs nothing to download and use.
- Install NVDA and start it.
- Press Insert + F7 to open the elements list.
- Close it, then use the arrow keys in browse mode to move through the items.
Without a screen reader
- Chrome: open DevTools, then Elements, then the Accessibility pane. Select an item to see its computed role, name and position in set.
- Firefox: open DevTools and use the Accessibility inspector to see the same properties.
Scroll the grid and select an item again. The position in set must match the item's number, not its place among the rendered elements.
Automated
The axe DevTools extension and @axe-core/playwright report missing or invalid roles. A Playwright test can also scroll the grid and read aria-posinset from the items that are rendered after the scroll:
import { test, expect } from "@playwright/test";
test("items keep their position after scrolling", async ({ page }) => {
await page.goto("/examples/aria");
const grid = page.locator('[role="list"]').first();
await grid.evaluate((el) => {
el.parentElement!.scrollTop = 20000;
});
const item = grid.locator("[aria-posinset]").first();
await expect(item).toHaveAttribute("aria-setsize", "10000");
const position = Number(await item.getAttribute("aria-posinset"));
expect(position).toBeGreaterThan(100);
});