tabindex
它能做什么
这项技能检查网页中 tabindex 属性的使用方式。适用于希望页面能与键盘和屏幕阅读器良好配合的开发者和编辑。
适用场景
- ✓当页面中有正值的 tabindex 数字,改变了正常的 Tab 顺序的时候。
- ✓当自定义按钮或控件无法用 Tab 键访问的时候。
- ✓当无障碍审查标记出焦点顺序问题的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/tabindex/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“在我的网站上按 Tab 键时,焦点跳来跳去,顺序很奇怪。请帮我检查 tabindex 设置。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找破坏自然顺序的 tabindex 值并加以修正。自定义控件会被设为 0,使键盘用户能够访问它们。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use appropriate tabindex values
Incorrect tabindex values can create a confusing navigation experience, making it difficult for keyboard users to predict where focus will move next.
Quick Reference
- Stick to
tabindex="0"for custom interactive elements - Use
tabindex="-1"for elements that should only be focusable via script - Avoid positive values (1, 2, 3...) which break natural tab order
Check
Check for any positive tabindex values and ensure custom interactive elements are focusable.
Fix
Remove positive tabindex values and use tabindex="0" or -1 appropriately.
Explain
Explain why positive tabindex values are problematic for keyboard navigation and user experience.
Code Review
Review the rendered markup and interactive states that affect Use appropriate tabindex values. 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/tabindex
常见问题
tabindex 为 0 有什么作用?
它使自定义元素可以通过 Tab 键访问,并按其在页面中的正常位置排列。
为什么正值的 tabindex 是个问题?
它们会把元素移到 Tab 顺序的最前面,使键盘用户难以预测页面的操作顺序。
应该先检查内置按钮和链接吗?
应该。这项技能指出,要先检查原生 HTML 元素,因为它们通常是更好的选择。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Use appropriate tabindex values. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #3044
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。