跳到正文
Skillpedia
网站与界面(前端)75k · #2739

aria-toggle-field-name

它能做什么

这项技能检查复选框、单选按钮和开关是否各自都有清晰的名称。适合构建带有开关的表单和设置页面的开发者。

适用场景

  • ✓当你构建复选框、单选按钮或开关时。
  • ✓当开关没有可见的标签,或只有一个图标时。
  • ✓当设置页面中的开关没有为屏幕阅读器作出说明时。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-toggle-field-name/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-toggle-field-name/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查我设置页面上的每个开关,确保屏幕阅读器能读出它的名称。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会确认每个切换控件都有 label 元素、aria-label 或 aria-labelledby,并在缺少名称的地方添加清晰的名称。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Provide accessible names for toggle fields

Toggle fields like checkboxes and switches are unusable for screen reader users if they don't have a label, as the user won't know what they are turning on or off.

Quick Reference

  • Use aria-label, aria-labelledby, or <label> for checkboxes and radios
  • Ensure the label clearly describes the state or action of the toggle
  • Avoid empty or non-descriptive labels for switches

Check

Check all toggle fields (checkboxes, radio buttons, switches) for a valid accessible name.

Fix

Add an accessible name to the toggle field using a label element, aria-label, or aria-labelledby.

Explain

Explain why all interactive toggle controls must have descriptive names for users to understand their purpose.

Code Review

Review the rendered markup and interactive states that affect Provide accessible names for toggle fields. 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-toggle-field-name

常见问题

为什么切换控件需要名称?

这项技能说明,没有名称的话,用户将不知道自己打开或关闭的是什么。

哪些方式可以为切换控件命名?

label 元素、aria-label,或 aria-labelledby。

开关需要特别注意吗?

需要。这项技能提醒,开关上不要使用空白或含糊的标签。

详情

作者的原始描述

Use when reviewing rendered HTML, interactive components, or design-system patterns related to Provide accessible names for toggle fields. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2739
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能