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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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.
热度
- GitHub 星标
- 75k
- 排名
- #2739
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。