Use when applies to custom ARIA widgets using composite roles: tablist, list, listbox, menu, menubar, tree, treegrid, grid, rowgroup, row, radiogroup. Use when
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-aria-required-children-606807dede02 ,按照其中的说明把「aria-required-children」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Screen readers like NVDA and VoiceOver navigate composite widgets (menus, tabs, trees) by moving between the required child roles. If a tablist contains <div> elements instead of role='tab', the user hears no tabs at all. JAWS announces 'list of 5 items' only when role='listitem' children exist inside role='list'. Without correct nesting, the entire widget becomes opaque to keyboard-only and screen reader users.
tablist → tab, list/listbox → listitem/option, menu/menubar → menuitem, tree → treeitem, grid/rowgroup → rowrole='none' or role='presentation' on purely structural wrapper elements inside the container to avoid invalid nestingIdentify all elements with ARIA container roles (tablist, list, listbox, menu, menubar, tree, treegrid, grid, rowgroup, radiogroup). For each, verify it contains the required owned child roles per the WAI-ARIA spec: tablist must own tab elements; list must own listitem; listbox must own option; menu/menubar must own menuitem, menuitemcheckbox, or menuitemradio; tree must own treeitem; grid must own row (which owns gridcell); radiogroup must own radio. Flag any container roles missing required children.
For each container role missing its required children: (1) Add the correct role to each child element — e.g., add role='tab' to each tab button inside role='tablist'. (2) If wrapper <div> elements exist between the container and the required children for layout purposes, add role='none' or role='presentation' to those wrappers. (3) Prefer native HTML equivalents where possible: <ul>/<li> instead of role='list'/role='listitem', <select>/<option> instead of role='listbox'/role='option'.
WAI-ARIA 1.2 defines 'required owned elements' for composite widget roles — these are the child roles a container must contain for the widget to be valid. Screen readers build their understanding of a widget from this structure. A tablist without tab children means a screen reader user in Forms Mode will find nothing to navigate between. A menu without menuitem children will not be announced as a menu at all in some ATs. This is distinct from aria-required-parent, which checks the inverse direction.
Review the rendered markup and interactive states that affect Ensure ARIA roles contain required child roles. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/en/rules/accessibility/aria-required-children