AGENT SKILL
WCAG 色彩对比度计算
wcag-audit-perceivable-color-contrast
计算文本和非文本元素的 WCAG 对比度比率
- License 许可
- MIT
- 最近更新
- 2026-01-19
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- wcag-audit-perceivable-color-contrast
- description
- Calculate WCAG contrast ratios for text and non-text elements
02 资源文件 1
- 脚本scripts/calculate.js5.1 KB
03 SKILL.md 正文
When to Use
Use this tool when checking color combinations for WCAG compliance, testing text readability, or validating non-text contrast ratios.
Usage
Command Line
node scripts/calculate.js --foreground "#000000" --background "#FFFFFF"
node scripts/calculate.js --fg "rgb(0,0,0)" --bg "rgb(255,255,255)"
node scripts/calculate.js --fg "#FF0000" --bg "#00FF00" --type "non-text"
JSON Input
node scripts/calculate.js --json '{"foreground": "#000000", "background": "#FFFFFF"}'
Parameters
--foreground,--fg: Foreground color (hex, rgb, hsl)--background,--bg: Background color (hex, rgb, hsl)--type: "text" (default) or "non-text"--json: JSON input with color properties
Output
Returns JSON with contrast ratio and WCAG compliance levels:
{
"contrastRatio": 21.0,
"compliance": {
"AA": {
"normal": true,
"large": true
},
"AAA": {
"normal": true,
"large": true
}
},
"colors": {
"foreground": "#000000",
"background": "#FFFFFF"
}
}
Examples
Text Contrast Check
$ node scripts/calculate.js --fg "#000000" --bg "#FFFFFF"
Contrast Ratio: 21.0:1
✅ AA Large Text: PASS
✅ AA Normal Text: PASS
✅ AAA Large Text: PASS
✅ AAA Normal Text: PASS
Non-Text Contrast Check
$ node scripts/calculate.js --fg "#FF6B35" --bg "#F7F3E9" --type "non-text"
Contrast Ratio: 3.2:1
✅ Non-text contrast: PASS
WCAG Standards
- Text AA: 4.5:1 for normal text, 3:1 for large text (18pt+ or 14pt+ bold)
- Text AAA: 7:1 for normal text, 4.5:1 for large text
- Non-text: 3:1 minimum contrast ratio
Learn More
For more information about Agent Skills and how they extend AI capabilities.
04 同仓库更多 Skills
表单输入无障碍审计
wcag-audit-understandable-forms
路由表单输入与数据收集的无障碍需求
★ 1
表单设计无障碍深度审计
wcag-audit-understandable-forms-deep
面向用户输入与数据收集的表单设计无障碍规则
★ 1
文本排版无障碍设计审计
wcag-audit-perceivable-text
路由排版无障碍设计决策与需求
★ 1
字体单位无障碍换算
wcag-audit-perceivable-text-size
结合无障碍上下文,在 px、pt、em、rem 单位之间进行转换
★ 1
文本排版无障碍深度审计
wcag-audit-perceivable-text-deep
面向文本设计与可读性的全面排版无障碍规则
★ 1
音视频多媒体无障碍审计
wcag-audit-perceivable-media
路由音频、视频和多媒体无障碍需求
★ 1