← Blog9 min read#aria#accessibility#patterns

ARIA Design Patterns: Combobox, Listbox, Dialog, Menu Roles

Master ARIA roles for combobox, listbox, dialog, and menu - with real code, keyboard patterns, and gotchas senior devs hit in production.

Developer inspecting ARIA accessibility roles in browser DevTools inspector

Why ARIA Patterns Actually Matter (and Why Most Devs Get Them Wrong)

Here's the thing about ARIA: most developers treat it like a magic accessibility wand. Slap role="button" on a <div>, ship it, done. But that's not how the accessibility tree works, and screen reader users notice immediately when a component behaves inconsistently with the WAI-ARIA Authoring Practices Guide 1.2 patterns.

The four patterns this article covers - combobox, listbox, dialog, and menu - are the ones that trip up experienced teams most often. They're interactive, they require keyboard management, and they involve focus choreography that gets subtle fast. In practice, a broken combobox is the most common accessibility regression I see in design system audits. Even well-funded products ship comboboxes that trap keyboard users or don't announce options properly.

Honestly, most of the complexity isn't the role attribute itself - it's the supporting attributes (aria-expanded, aria-activedescendant, aria-modal) and the keyboard event handlers that make the pattern actually work. We'll cover both. You'll also want to cross-reference your implementations against the WCAG accessibility guide if you're targeting AA compliance.

Quick aside: this guide assumes React 18+ and TypeScript, but the ARIA patterns themselves are framework-agnostic. The keyboard interactions are specified by the APG, not by any library.

The Combobox Pattern: More Than Just an Autocomplete

A combobox in ARIA terms is an input element paired with a popup - either a listbox, grid, tree, or dialog. The version you'll build 90% of the time is input + listbox, which is what search bars, tag inputs, and country selectors use. The APG 1.2 spec from 2023 overhauled this pattern significantly, so if you're working from tutorials written before that, toss them.

The structural markup looks like this:

// Combobox.tsx
export function Combobox({ options, label }: ComboboxProps) {
  const [open, setOpen] = useState(false);
  const [activeIndex, setActiveIndex] = useState(-1);
  const inputRef = useRef<HTMLInputElement>(null);
  const listRef = useRef<HTMLUListElement>(null);

  const handleKeyDown = (e: React.KeyboardEvent) => {
    switch (e.key) {
      case 'ArrowDown':
        e.preventDefault();
        setOpen(true);
        setActiveIndex(i => Math.min(i + 1, options.length - 1));
        break;
      case 'ArrowUp':
        e.preventDefault();
        setActiveIndex(i => Math.max(i - 1, 0));
        break;
      case 'Escape':
        setOpen(false);
        setActiveIndex(-1);
        inputRef.current?.focus();
        break;
      case 'Enter':
        if (activeIndex >= 0) selectOption(options[activeIndex]);
        break;
    }
  };

  return (
    <div role="combobox" aria-expanded={open} aria-haspopup="listbox"
         aria-owns="combo-listbox" aria-controls="combo-listbox">
      <label id="combo-label">{label}</label>
      <input
        ref={inputRef}
        aria-labelledby="combo-label"
        aria-autocomplete="list"
        aria-activedescendant={activeIndex >= 0 ? `option-${activeIndex}` : undefined}
        onKeyDown={handleKeyDown}
      />
      {open && (
        <ul id="combo-listbox" ref={listRef} role="listbox"
            aria-labelledby="combo-label">
          {options.map((opt, i) => (
            <li key={opt.value} id={`option-${i}`} role="option"
                aria-selected={i === activeIndex}>
              {opt.label}
            </li>
          ))}
        </ul>
      )}
    </div>
  );
}

Worth noting: aria-activedescendant is the correct pattern here, not tabIndex. You're keeping focus on the input and virtually moving it with the attribute - screen readers follow the active descendant ID to announce the highlighted option. If you move actual DOM focus into the list items, you break the ability to type while navigating. That's a really common mistake.

The aria-haspopup="listbox" on the container tells assistive tech what kind of popup will appear before the user opens it. Using just aria-haspopup="true" was the old pattern - in 2026, be specific. NVDA and JAWS both announce the popup type on focus.

The Listbox Pattern: Simpler, But Still Misused

A listbox is for selecting one or more options from a visible list - think a custom <select> replacement or a region picker. The key distinction: a listbox is always visible (or at least persistently rendered). When it's hidden inside a popup, that's a combobox. Keep those two straight and you'll avoid a whole class of incorrect role usage.

// Listbox.tsx - single-select
export function Listbox({ options, value, onChange, label }: ListboxProps) {
  const listRef = useRef<HTMLUListElement>(null);
  const [focused, setFocused] = useState(value);

  const handleKeyDown = (e: React.KeyboardEvent) => {
    const idx = options.findIndex(o => o.value === focused);
    switch (e.key) {
      case 'ArrowDown':
        e.preventDefault();
        setFocused(options[Math.min(idx + 1, options.length - 1)].value);
        break;
      case 'ArrowUp':
        e.preventDefault();
        setFocused(options[Math.max(idx - 1, 0)].value);
        break;
      case ' ':
      case 'Enter':
        onChange(focused);
        break;
      case 'Home':
        setFocused(options[0].value);
        break;
      case 'End':
        setFocused(options[options.length - 1].value);
        break;
    }
  };

  return (
    <>
      <span id="listbox-label">{label}</span>
      <ul
        ref={listRef}
        role="listbox"
        tabIndex={0}
        aria-labelledby="listbox-label"
        aria-activedescendant={focused ? `lb-opt-${focused}` : undefined}
        onKeyDown={handleKeyDown}
      >
        {options.map(opt => (
          <li
            key={opt.value}
            id={`lb-opt-${opt.value}`}
            role="option"
            aria-selected={opt.value === value}
            onClick={() => { setFocused(opt.value); onChange(opt.value); }}
          >
            {opt.label}
          </li>
        ))}
      </ul>
    </>
  );
}

For multi-select listboxes, add aria-multiselectable="true" to the <ul> and track selected state as a Set. Each option's aria-selected then reflects individual selection, not just focus. That said, multi-select listboxes are genuinely confusing UX for sighted users too - consider whether a checkbox group serves your users better before reaching for this pattern.

Home and End keys are required by the APG. They're the ones developers forget most. If a user presses End and nothing happens, that's a keyboard navigation bug, full stop.

The Dialog Pattern: Focus Trapping Is Not Optional

Dialogs are the pattern where ARIA implementations fail most visibly. The spec is clear: when a dialog opens, focus moves into it. When it closes, focus returns to the trigger. And critically - keyboard focus must not be able to escape the dialog while it's open. That's not a nice-to-have, it's the whole point of aria-modal="true".

// Dialog.tsx
import { useEffect, useRef } from 'react';

const FOCUSABLE = [
  'a[href]', 'button:not([disabled])', 'input:not([disabled])',
  'select:not([disabled])', 'textarea:not([disabled])',
  '[tabindex]:not([tabindex="-1"])'
].join(',');

export function Dialog({ open, onClose, title, children }: DialogProps) {
  const dialogRef = useRef<HTMLDivElement>(null);
  const triggerRef = useRef<HTMLElement | null>(null);

  useEffect(() => {
    if (open) {
      triggerRef.current = document.activeElement as HTMLElement;
      const firstFocusable = dialogRef.current?.querySelector<HTMLElement>(FOCUSABLE);
      firstFocusable?.focus();
    } else {
      triggerRef.current?.focus();
    }
  }, [open]);

  const trapFocus = (e: React.KeyboardEvent) => {
    if (e.key !== 'Tab') return;
    const focusable = Array.from(
      dialogRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE) ?? []
    );
    const first = focusable[0];
    const last = focusable[focusable.length - 1];
    if (e.shiftKey && document.activeElement === first) {
      e.preventDefault(); last.focus();
    } else if (!e.shiftKey && document.activeElement === last) {
      e.preventDefault(); first.focus();
    }
  };

  if (!open) return null;

  return (
    <div role="presentation" style={{ position: 'fixed', inset: 0 }}
         onClick={(e) => { if (e.target === e.currentTarget) onClose(); }}>
      <div
        ref={dialogRef}
        role="dialog"
        aria-modal="true"
        aria-labelledby="dialog-title"
        onKeyDown={trapFocus}
      >
        <h2 id="dialog-title">{title}</h2>
        {children}
        <button onClick={onClose}>Close</button>
      </div>
    </div>
  );
}

One thing that catches teams off guard: aria-modal="true" tells screen readers that content outside the dialog is inert, but it doesn't actually make it inert in the DOM for keyboard users. Older JAWS versions (pre-2024) don't honour aria-modal at all - they let users Tab right out. The only truly robust fix is inert attribute on everything outside the dialog, which has excellent browser support as of Chrome 102 / Firefox 112.

Look, the <dialog> HTML element with showModal() handles most of this for you in 2026. It provides built-in focus trapping, Escape-to-close, and the top-layer rendering context. You should be reaching for native <dialog> first. Custom ARIA dialogs are for cases where you need the animation control or portal rendering that native dialog doesn't give you easily.

Escape key must close the dialog. No exceptions. And if closing the dialog triggers a confirmation ("are you sure?"), that confirmation needs to be its own dialog - don't fight the keyboard pattern.

The Menu and Menubar Patterns: Not the Same as Navigation

This one trips up even experienced devs. The role="menu" pattern is for application menus - think right-click context menus, action dropdowns ("Edit", "Delete", "Duplicate"). It is not for site navigation. Using role="menu" on a nav bar is wrong and will confuse screen reader users who expect arrow key navigation inside menus but Tab navigation on navbars.

// ContextMenu.tsx
export function Menu({ items, triggerRef, open, onClose }: MenuProps) {
  const menuRef = useRef<HTMLUListElement>(null);
  const [activeIdx, setActiveIdx] = useState(0);

  useEffect(() => {
    if (open) {
      menuRef.current?.focus();
      setActiveIdx(0);
    }
  }, [open]);

  const handleKeyDown = (e: React.KeyboardEvent) => {
    switch (e.key) {
      case 'ArrowDown':
        e.preventDefault();
        setActiveIdx(i => (i + 1) % items.length);
        break;
      case 'ArrowUp':
        e.preventDefault();
        setActiveIdx(i => (i - 1 + items.length) % items.length);
        break;
      case 'Home': setActiveIdx(0); break;
      case 'End': setActiveIdx(items.length - 1); break;
      case 'Escape':
        onClose();
        triggerRef.current?.focus();
        break;
      case 'Enter':
      case ' ':
        items[activeIdx]?.action();
        onClose();
        break;
    }
  };

  if (!open) return null;

  return (
    <ul
      ref={menuRef}
      role="menu"
      tabIndex={-1}
      aria-label="Options"
      onKeyDown={handleKeyDown}
    >
      {items.map((item, i) => (
        <li key={item.id} role="menuitem"
            id={`menu-item-${i}`}
            tabIndex={-1}
            aria-current={i === activeIdx ? 'true' : undefined}
            onClick={() => { item.action(); onClose(); }}>
          {item.label}
        </li>
      ))}
    </ul>
  );
}

Notice the menu itself gets tabIndex={-1} and receives focus as a container, not the individual items. Items have tabIndex={-1} too - you route visual focus via aria-activedescendant or by calling .focus() on the item directly. Both approaches work; the aria-activedescendant approach keeps focus on the container and is slightly easier to implement correctly.

Menubar (horizontal application menu, like a desktop app toolbar) extends this with Left/Right arrow navigation between top-level items and Down to open submenus. It's rare on the web in 2026, but if you're building a rich text editor or a spreadsheet UI, you'll need it. The APG has a full menubar example - read it before you write a single line.

One more thing - role="menuitem" is for actions. For checkboxes inside a menu use role="menuitemcheckbox". For radio groups inside a menu use role="menuitemradio" with aria-checked. Don't reach for generic menuitem for everything.

Common Mistakes Across All Four Patterns

After the pattern specifics, the cross-cutting mistakes are worth naming explicitly. First: using display: none vs visibility: hidden vs removing from DOM. When you hide a popup with display: none, it's gone from the accessibility tree - which is correct. visibility: hidden keeps it in the tree but hides it visually, which can leave ghost focusable elements. Always remove interactive popups from the DOM or use display: none when closed.

Second: forgetting to manage aria-expanded on the trigger. The button or input that opens your combobox/dialog/menu needs aria-expanded="true" when the popup is open, aria-expanded="false" when closed. Plenty of implementations set aria-haspopup correctly but never update aria-expanded. Screen reader users rely on that state to know whether opening will happen.

Third: dynamic content inside dialogs and menus that isn't announced. If you load async content into an open dialog, use aria-live="polite" on the container or move focus to the new content. Silence is the worst screen reader experience - the user doesn't know if their action did anything. This pairs directly with building accessible design system components that handle loading states correctly.

Fourth: not testing with actual screen readers. VoiceOver on macOS, NVDA on Windows, TalkBack on Android - they each have quirks. A 30-minute testing session with VoiceOver will surface implementation gaps that automated tools like axe-core won't catch. Automated testing catches roughly 30–40% of accessibility issues. The rest requires human testing.

Testing, Tooling, and Empire UI Components

For automated testing, @testing-library/react with its getByRole queries is your best friend - it queries the accessibility tree, not the DOM, so tests break when ARIA roles break. Pair that with jest-axe to run axe-core assertions inside your unit tests. That setup catches missing labels, incorrect role hierarchies, and aria-required violations without spinning up a browser.

// dialog.test.tsx
import { render, screen } from '@testing-library/react';
import { axe, toHaveNoViolations } from 'jest-axe';
import userEvent from '@testing-library/user-event';
import { Dialog } from './Dialog';

expect.extend(toHaveNoViolations);

test('dialog has no accessibility violations', async () => {
  const { container } = render(
    <Dialog open title="Confirm action" onClose={() => {}}>
      <p>Are you sure?</p>
    </Dialog>
  );
  const results = await axe(container);
  expect(results).toHaveNoViolations();
});

test('Escape closes dialog and returns focus', async () => {
  const user = userEvent.setup();
  const onClose = jest.fn();
  render(<button>Open</button>);
  // focus the trigger first, then open
  await user.keyboard('{Escape}');
  // verify onClose called
  expect(onClose).toHaveBeenCalledTimes(1);
});

Empire UI's interactive components - modals, dropdowns, command palettes, select inputs - are built against these exact patterns. The component library ships with proper ARIA roles, keyboard handlers, and focus management out of the box, so you're not starting from scratch every time. If you're building a design system that needs to pass accessibility audits, that's a serious time-saver.

Worth noting: glassmorphism components on Empire UI include proper contrast ratios baked into the default themes. The translucency makes contrast tricky to get right manually - the pre-built variants are tested against WCAG AA 4.5:1 across the standard palette.

FAQ

What's the difference between role="menu" and role="navigation"?

role="menu" is for application-level action menus - context menus, dropdown actions - and uses arrow key navigation. role="navigation" wraps site navigation links and uses Tab key navigation. Mixing them up breaks the expected keyboard interaction model for screen reader users.

Do I need aria-modal="true" on every dialog?

Yes, if you're building a modal that should block interaction with background content. Without it, some screen readers will let users navigate outside the dialog. Pair it with inert on background content for older JAWS compatibility.

When should I use aria-activedescendant vs moving actual focus?

aria-activedescendant keeps focus on the container (input or listbox) while virtually highlighting an item - use it in comboboxes and listboxes where you want users to keep typing. Move actual focus when the user lands on something they'll interact with directly, like dialog buttons.

Can automated tools like axe-core fully verify ARIA patterns?

No. Axe-core catches structural issues like missing labels or incorrect role nesting, but it can't verify keyboard interactions, focus management, or whether aria-activedescendant points to the right element. Manual screen reader testing is required for full pattern compliance.

Free components in 41 styles
React & Tailwind, copy-paste ready.
Browse β†’

Read next

Building Design Systems That Scale: Engineering Guide 2026 β†’WCAG 2025 Accessibility Guide for React Developers β†’SVG Icon Accessibility: aria-label, role and title Explained Properly β†’React Accessibility (a11y): The 8 Patterns You Keep Getting Wrong β†’