Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2735

aria-required-children

Skill này làm gì

Skill này kiểm tra các widget ghép như danh sách tab, menu và cây có đúng phần tử con hay không. Nó dành cho lập trình viên làm tab, danh sách hoặc menu tùy chỉnh từ phần tử div và span.

Khi nào nên dùng

  • ✓Khi bạn làm một bộ tab, menu hoặc listbox tùy chỉnh từ phần tử div.
  • ✓Khi trình đọc màn hình không thông báo số lượng mục trong danh sách hoặc menu.
  • ✓Khi bạn làm một điều khiển danh sách, chọn hoặc điều hướng tùy chỉnh thay vì HTML gốc.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-required-children/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-required-children/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thanh tab tùy chỉnh của tôi dùng các div đơn thuần. Đảm bảo các mục tab có vai trò đúng bên trong tablist.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra mỗi vai trò chứa với các vai trò con nó phải sở hữu, như tab trong tablist hoặc listitem trong list, và thêm vai trò presentation cho các phần tử bao bọc khi cần.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Ensure ARIA roles contain required child roles

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.

Quick Reference

  • Container roles mandate specific owned child roles: tablist → tab, list/listbox → listitem/option, menu/menubar → menuitem, tree → treeitem, grid/rowgroup → row
  • Missing required children break the accessibility tree so screen readers cannot enumerate items or announce counts
  • Use role='none' or role='presentation' on purely structural wrapper elements inside the container to avoid invalid nesting
  • Applies to WAI-ARIA 1.2 required owned elements for composite widget roles

Check

Identify 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.

Fix

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'.

Explain

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.

Code Review

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/rules/accessibility/aria-required-children

Câu hỏi thường gặp

Điều gì xảy ra nếu thiếu vai trò con?

Skill nói trình đọc màn hình có thể không thông báo các mục hoặc số đếm của chúng, làm hỏng việc điều hướng.

Vai trò none dùng để làm gì?

Nó đánh dấu các phần tử bao bọc thuần cấu trúc để không phá vỡ cấu trúc bắt buộc.

Skill nêu những vai trò nào làm ví dụ?

Nó nêu tab trong tablist, listitem trong list, option trong listbox và menuitem trong menu.

Chi tiết

Mô tả gốc của tác giả

Use when applies to custom ARIA widgets using composite roles: tablist, list, listbox, menu, menubar, tree, treegrid, grid, rowgroup, row, radiogroup. Use when reviewing components built with div/span elements that replace native HTML list, select, or nav elements.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2735
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự