Fix aria-required-children in Tailwind CSS
When styling custom Tailwind tabs, radio-card grids, or comboboxes, adding flex wrapper <div>s for spacing or placing role='list' on grids with non-listitem children breaks aria-required-children. Keep role='tab', role='option', or role='listitem' directly beneath their parent container and leverage Tailwind's aria-selected: variant for styling.
Before and after
<!-- Broken Tailwind tab bar: extra flex wrapper <div> inside role="tablist" -->
<div role="tablist" aria-label="Billing interval" class="inline-flex rounded-lg bg-slate-100 p-1">
<div class="flex items-center gap-1">
<button type="button" class="rounded-md bg-white px-3 py-1.5 text-sm font-medium text-slate-900">
Monthly
</button>
<button type="button" class="rounded-md px-3 py-1.5 text-sm font-medium text-slate-600">
Annual
</button>
</div>
</div><!-- Fixed Tailwind tab bar: direct role="tab" children + aria-selected styling -->
<div role="tablist" aria-label="Billing interval" class="inline-flex items-center gap-1 rounded-lg bg-slate-100 p-1">
<button
type="button"
role="tab"
aria-selected="true"
class="rounded-md px-3 py-1.5 text-sm font-semibold text-slate-700 aria-selected:bg-white aria-selected:text-slate-950 aria-selected:shadow-xs"
>
Monthly
</button>
<button
type="button"
role="tab"
aria-selected="false"
tabindex="-1"
class="rounded-md px-3 py-1.5 text-sm font-semibold text-slate-700 aria-selected:bg-white aria-selected:text-slate-950 aria-selected:shadow-xs"
>
Annual (Save 20%)
</button>
</div>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("Tailwind tablist uses direct role=tab children", async ({ page }) => {
await page.goto("/pricing");
const results = await new AxeBuilder({ page })
.withRules(["aria-required-children"])
.analyze();
expect(results.violations).toEqual([]);
});Template deduplication tip
A shared Tailwind pricing-period toggle or filter listbox reused across marketing and app routes generates repeated aria-required-children errors—fixing the one shared markup pattern resolves every page.
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 Tailwind Preflight cause people to add role='list' to <ul>?
Can Tailwind style active ARIA states without extra wrapper classes?
Do I still need arrow-key keyboard support when using role='tablist'?
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 Tailwind CSS weekly? Block new aria-required-children regressions in PRs with our baseline-diff GitHub Action PR gate (≤20 URLs/PR).