React fix

Before and after

Broken — before
// Broken React Tabs: wrapper <div>s and plain <button>s inside role="tablist"
export function ProductTabs({ active, onChange }: { active: string; onChange: (id: string) => void }) {
  return (
    <div role="tablist" aria-label="Product details">
      <div className="tab-wrapper">
        <button type="button" onClick={() => onChange("specs")}>Specs</button>
      </div>
      <div className="tab-wrapper">
        <button type="button" onClick={() => onChange("reviews")}>Reviews</button>
      </div>
    </div>
  );
}
Fixed — after
// Fixed React Tabs: role="tablist" directly owns role="tab" controls + paired tabpanel
interface TabItem {
  id: string;
  label: string;
  content: string;
}

export function ProductTabs({
  tabs,
  activeId,
  onSelect,
}: {
  tabs: TabItem[];
  activeId: string;
  onSelect: (id: string) => void;
}) {
  return (
    <div>
      <div role="tablist" aria-label="Product details">
        {tabs.map((tab) => {
          const selected = tab.id === activeId;
          return (
            <button
              key={tab.id}
              id={`tab-${tab.id}`}
              type="button"
              role="tab"
              aria-selected={selected}
              aria-controls={`panel-${tab.id}`}
              tabIndex={selected ? 0 : -1}
              onClick={() => onSelect(tab.id)}
            >
              {tab.label}
            </button>
          );
        })}
      </div>
      {tabs.map((tab) => (
        <div
          key={tab.id}
          id={`panel-${tab.id}`}
          role="tabpanel"
          aria-labelledby={`tab-${tab.id}`}
          hidden={tab.id !== activeId}
        >
          {tab.content}
        </div>
      ))}
    </div>
  );
}
Live preview

Fixed vs. broken example

Passes aria-required-children
Accessibility tree: role="tablist" directly owns role="tab" (selected, 1 of 2) and role="tab" (unselected, 2 of 2)

Remove extraneous intermediate wrapper <div>s between a composite ARIA parent and its required children—or set role="none" on purely structural wrappers.

Automated test

Playwright + axe-core check

tests/a11y-aria-required-children.spec.ts
import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("React Tabs widget exposes valid tablist -> tab ARIA ownership", async ({ page }) => {
  await page.goto("/products/pro-plan");
  await expect(page.getByRole("tablist", { name: "Product details" })).toBeVisible();
  await expect(page.getByRole("tab")).toHaveCount(2);
  const results = await new AxeBuilder({ page })
    .withRules(["aria-required-children"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A single broken <Tabs> or <DropdownMenu> primitive in src/components/ui/ triggers aria-required-children on every dashboard, settings, and product detail view. A11yDrift clusters every route into one React primitive fix.

Screen readers

What NVDA and VoiceOver announce

When a container declares role='tablist', role='menu', or role='listbox' without directly owning its required child roles (tab, menuitem, option), assistive technologies break arrow-key navigation, item counts ('1 of 3'), and selection state announcements.

NVDA (Windows)

Broken

"Product details, tab control" -> "Specs, button" (item count and selected tab semantics lost)


Fixed

"Product details, tab control, Specs, tab, selected, 1 of 2"

VoiceOver (macOS / iOS)

Broken

"Product details, tab group, 0 items" -> "Specs, button"


Fixed

"Specs, selected, tab, 1 of 2, Product details, tab group"

Common questions

Why does adding a Framer Motion <div> inside role='tablist' break aria-required-children?
WAI-ARIA requires composite containers like tablist, menu, and listbox to directly own their required child roles. An unattributed intermediate <div> inserts a generic container node between parent and child; either render the motion element as the role='tab' button itself or apply role='none' to purely presentational wrappers.
What if my React listbox is temporarily empty while loading results?
An empty role='listbox' with no role='option' children triggers aria-required-children. Render an accessible loading status outside the listbox (or omit role='listbox' until options exist, or include a disabled status option).
Should React navigation links use role='menu' and role='menuitem'?
No—website site navigation should use native <nav><ul><li><a href='...'> markup. Reserve role='menu' / role='menuitem' strictly for desktop-style application action menus with full arrow-key navigation.