Fix aria-required-children in Next.js
Next.js apps using custom command palettes, Shadcn/Radix primitives, or marketing navbars frequently trigger aria-required-children when developers add role='menu' to a <nav> containing plain <Link> elements, or inject a non-semantic wrapper inside a role='listbox' search popover.
Before and after
// 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>
);
}// 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>
);
}Fixed vs. broken example
Remove extraneous intermediate wrapper <div>s between a composite ARIA parent and its required children—or set role="none" on purely structural wrappers.
Playwright + axe-core check
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.
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)
"Product details, tab control" -> "Specs, button" (item count and selected tab semantics lost)
"Product details, tab control, Specs, tab, selected, 1 of 2"
VoiceOver (macOS / iOS)
"Product details, tab group, 0 items" -> "Specs, button"
"Specs, selected, tab, 1 of 2, Product details, tab group"
Common questions
Why does removing role='menu' from a Next.js navbar improve accessibility?
Why do Next.js search autocomplete popovers fail aria-required-children?
Does Radix UI / shadcn/ui handle aria-required-children automatically?
Test a URL for aria-required-children
Enter any public URL for a free WCAG 2.2 AA check—no account or credit card required.
Shipping Next.js weekly? Block new aria-required-children regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).