Next.js fix

Before and after

Broken — before
// app/components/SiteNav.tsx (Broken: role="menu" wrapping Next.js <Link> anchors)
import Link from "next/link";

export function SiteNav() {
  return (
    <nav aria-label="Primary">
      <div role="menu" className="flex gap-6">
        <Link href="/pricing">Pricing</Link>
        <Link href="/docs">Docs</Link>
        <Link href="/blog">Blog</Link>
      </div>
    </nav>
  );
}
Fixed — after
// app/components/SiteNav.tsx (Fixed: semantic list navigation — no misused ARIA menu role)
import Link from "next/link";

const NAV_ITEMS = [
  { href: "/pricing", label: "Pricing" },
  { href: "/docs", label: "Docs" },
  { href: "/blog", label: "Blog" },
] as const;

export function SiteNav() {
  return (
    <nav aria-label="Primary">
      <ul className="flex list-none gap-6 p-0">
        {NAV_ITEMS.map((item) => (
          <li key={item.href}>
            <Link href={item.href}>{item.label}</Link>
          </li>
        ))}
      </ul>
    </nav>
  );
}
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("Next.js primary nav and command menus pass aria-required-children", async ({ page }) => {
  await page.goto("/");
  const results = await new AxeBuilder({ page })
    .withRules(["aria-required-children"])
    .analyze();
  expect(results.violations).toEqual([]);
});

Template deduplication tip

A header navigation component in app/layout.tsx mistakenly tagged role='menu' fires aria-required-children on every Next.js route. Replacing that invalid ARIA role with native <nav><ul><li><Link> clears every page in one commit.

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 removing role='menu' from a Next.js navbar improve accessibility?
The First Rule of ARIA is not to use ARIA when native HTML works. <nav><ul><li><Link> communicates link count and navigation landmarks cleanly without breaking Tab navigation or failing aria-required-children.
Why do Next.js search autocomplete popovers fail aria-required-children?
If a search dropdown uses role='listbox' and renders a heading or 'No results' <div> inside the listbox, axe-core flags invalid non-option children. Move non-option banners outside the listbox or group options with role='group'.
Does Radix UI / shadcn/ui handle aria-required-children automatically?
Yes—as long as you don't insert extra non-Radix <div> wrappers or interactive buttons inside DropdownMenuContent or TabsList outside the expected primitive slots.