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

custom-element-accessibility

Skill này làm gì

Skill này kiểm tra các phần giao diện tự xây từ đầu, như nút hoặc ô nhập đặc biệt. Skill dành cho lập trình viên tự xây component web.

Khi nào nên dùng

  • ✓Khi bạn đã xây một nút, menu hoặc ô nhập tùy chỉnh từ đầu.
  • ✓Khi người dùng trình đọc màn hình không biết điều khiển tùy chỉnh làm gì.
  • ✓Khi một ô nhập tùy chỉnh không hoạt động bên trong form web thông thường.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/custom-element-accessibility/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/custom-element-accessibility/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

“Bạn có thể kiểm tra xem widget tùy chỉnh của tôi có hoạt động với bàn phím và trình đọc màn hình không?”

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

Cách hoạt động

Agent rà soát code widget để tìm nhãn ARIA còn thiếu, xử lý bàn phím và liên kết với form. Sau đó gợi ý bổ sung để widget hoạt động như một điều khiển gốc.

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.

Make custom elements and Web Components accessible

Custom elements that lack ARIA reflection are invisible to screen readers — a button that looks correct visually may be announced as a generic "group" or not at all. ElementInternals provides the bridge between the shadow DOM and the accessibility tree, and it is also the only standards-compliant way to integrate custom inputs with native HTML forms.

Quick Reference

  • Prefer native <button>, <input>, <select>, and <details> before building a custom widget
  • Use ElementInternals.ariaRole to expose ARIA semantics from the shadow DOM
  • Implement form-associated custom elements with ElementInternals for native form participation
  • Apply roving tabindex for compound widgets (listbox, toolbar, menu)
  • The shadow DOM does not automatically expose ARIA to the accessibility tree without ElementInternals

Check

Inspect these custom element definitions for missing ElementInternals setup, absent ARIA reflection, incomplete keyboard interaction patterns, and lack of form association for input-like components. First verify that the widget truly needs to be custom rather than a native control with styling.

Fix

Add ElementInternals attachment in the constructor, implement ariaRole and ariaLabel reflection, add keyboard event handlers following ARIA authoring patterns, and use formAssociated for custom input elements. Replace the component with native HTML when the native control already supports the required interaction.

Explain

Explain why the shadow DOM does not automatically expose ARIA semantics and how ElementInternals bridges the gap between custom elements and the accessibility tree.

Code Review

Review custom element class files for ElementInternals attachment, ARIA property reflection, keyboard interaction (Tab, Enter, Space, Arrow keys), focus management, and formAssociated static property on input-like elements. Flag cases where a native control would remove the accessibility burden entirely.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/html/custom-element-accessibility

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

Có nên tự xây điều khiển tùy chỉnh không?

Trước hết skill gợi ý kiểm tra xem một điều khiển HTML chuẩn đã được tạo kiểu có làm được việc không. Điều khiển tùy chỉnh chỉ là phương án cuối cùng.

ElementInternals là gì?

Đó là tính năng trình duyệt cho phép component tùy chỉnh chia sẻ ý nghĩa và dữ liệu form với trang. Skill khuyên dùng nó.

Skill kiểm tra những phần nào của widget?

Skill xem role và nhãn ARIA, tương tác bàn phím, và liên kết với form đối với các phần giống ô nhập.

Chi tiết

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

Use when reviewing custom element class definitions or Web Component source code to check for missing ARIA reflection, keyboard handling, and form association.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2806
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ự