aria-treeitem-name
Skill này làm gì
Skill này kiểm tra các mục trong widget dạng cây có tên rõ ràng và trạng thái mở rộng đúng. Skill dành cho lập trình viên xây trình quản lý file, menu lồng nhau hoặc sơ đồ tổ chức.
Khi nào nên dùng
- ✓Khi bạn xây trình quản lý file, điều hướng lồng nhau hoặc chế độ xem dạng cây.
- ✓Khi các mục cây có tên trống hoặc chung chung như folder hay item.
- ✓Khi mục có thể mở rộng không cho biết đang mở hay đóng.
Liên kết skill
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-treeitem-name/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Cây file của tôi hiển thị các thư mục mà trình đọc màn hình chỉ đọc là item. Hãy sửa lại tên.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent kiểm tra tên của từng mục cây theo thứ tự: aria-labelledby, rồi aria-label, rồi nội dung văn bản hiển thị, và đảm bảo mục có thể mở rộng có trạng thái expanded.
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.
Provide accessible names for tree items
Tree widgets represent hierarchical data (file explorers, nested navigation, organization charts). Screen readers announce each focused treeitem's name, level, and position — e.g., 'src, collapsed, level 1, 1 of 3'. If the name is empty or generic ('folder', 'item'), blind users cannot distinguish between nodes and cannot navigate the hierarchy with confidence. VoiceOver on macOS uses the name to populate the rotor, and NVDA reads it as the user moves through the tree with arrow keys.
Quick Reference
- Every element with
role='treeitem'must have a non-empty accessible name - Text content of the element is used as the name by default — ensure it is descriptive
- Use
aria-labelto override or supplement the visible text (e.g., adding file type context) - Use
aria-labelledbyto compose a name from multiple visible elements within the item - A treeitem with
aria-expandedmust also convey its expanded/collapsed state — this is separate from its name
Check
Find all elements with role='treeitem'. For each, determine its accessible name via the accname computation: check aria-labelledby first, then aria-label, then visible text content. Flag any treeitem with an empty or whitespace-only accessible name. Also check whether treeitems with children have aria-expanded set to 'true' or 'false' (not just absent).
Fix
For each unnamed treeitem: (1) If the element has visible text content that is descriptive, no change is needed — the text content becomes the accessible name. (2) If the visible text is ambiguous (e.g., an icon with no text), add aria-label='Descriptive name'. (3) If the item has multiple text parts (e.g., filename + file size), use aria-labelledby referencing the most descriptive element's id. (4) For expandable treeitems, ensure aria-expanded='true' or aria-expanded='false' is present and toggled on expand/collapse.
Explain
WAI-ARIA 1.2 requires that treeitem elements have an accessible name as part of the tree widget pattern. Screen readers convey position within the tree using: name + level (aria-level or DOM nesting depth) + set size (aria-setsize) + position in set (aria-posinset) + expanded state (aria-expanded). The name is the only user-facing identifier — without it, a user navigating by arrow keys hears only 'treeitem, level 2' with no way to know which node they are on.
Code Review
Review the rendered markup and interactive states that affect Provide accessible names for tree items. 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-treeitem-name
Câu hỏi thường gặp
Trình đọc màn hình nên đọc một mục cây tốt như thế nào?
Skill đưa ví dụ như src, collapsed, level 1, 1 of 3, gồm tên, trạng thái và vị trí.
Trình đọc màn hình dùng tên nào trước?
Skill mô tả việc kiểm tra aria-labelledby trước, sau đó đến aria-label, rồi đến nội dung văn bản hiển thị.
Mục có thể mở rộng có cần trạng thái riêng không?
Có. Skill nói các mục có con cần đặt aria-expanded thành true hoặc false.
Chi tiết
Mô tả gốc của tác giả
Use when applies to custom tree widgets built with role='tree', role='treeitem', and role='group'. Common in file explorers, nested navigation menus, org charts, and any UI where items can be expanded or collapsed to reveal children.
Độ phổ biến
- Sao GitHub
- 75k
- Vị trí xếp hạng
- #2741
- Giấy phép
- MIT
- Cập nhật
- 31/10/2026
Bình luận
- …
Thêm skill từ kho mã này
frontendchecklist
75kKiểm tra mã frontend và trang trực tiếp theo hơn 380 quy tắc về khả năng tiếp cận, tốc độ, SEO và bảo mật, bằng một công cụ dòng lệnh.
frontend-checklist-global
75kKiểm toán một dự án frontend theo đủ 386 quy tắc của Front-End Checklist, và đưa cách sửa cụ thể cho từng vấn đề tìm thấy.
404-page
75kKiểm tra xem trang báo thiếu của bạn có đưa ra các liên kết hữu ích và trả về mã trạng thái 404 thật hay không, để giúp khách bị lạc tìm đường.
about-page
75kKiểm tra xem trang web có trang Giới thiệu rõ ràng giải thích ai điều hành nó hay không, để xây dựng niềm tin với khách và công cụ tìm kiếm.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.