Communitygithub.com

无障碍设计 (WCAG 2.2)

使用WCAG 2.2 AA标准设计、实现和审计包容性数字产品。适用于构建或审计必须符合WCAG 2.2 AA标准的UI,或审查键盘、对比度、屏幕阅读器支持方面的更改。

无障碍设计 (WCAG 2.2) 是什么?

该技能确保数字界面对所有用户(包括使用屏幕阅读器、开关控制或键盘导航的用户)具有感知性、可操作性、可理解性和稳健性(POUR)。它专注于WCAG 2.2成功标准的技术实现。该技能涵盖了从UI组件规范定义、现有代码审计到新标准(如目标大小和焦点外观)实施的全流程,并提供了跨平台(Web、iOS、Android)的无障碍技术映射。其核心包括语义化映射、无障碍树、焦点管理及标签提示等概念。通过遵循五步工作流程(标识组件角色、定义感知属性、实现可操作控制、确保逻辑可理解、验证稳健兼容性),用户可以系统性地构建或审核符合无障碍标准的界面,并利用提供的示例和反模式清单避免常见错误。该技能适用于需要无障碍合规的Web、iOS和Android应用开发,并与前端模式、设计系统、SwiftUI模式等技能协同。

兼容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/accessibility

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

无障碍设计 (WCAG 2.2) 是做什么的?

本技能确保数字界面对于所有用户(包括使用屏幕阅读器、开关控制或键盘导航的用户)都是感知的、可操作的、可理解的和稳健的(POUR)。它专注于WCAG 2.2成功标准的技术实现。

使用时机

  • 为 Web、iOS 或 Android 定义 UI 组件规范。
  • 审计现有代码中的无障碍障碍或合规差距。
  • 实现新的 WCAG 2.2 标准,如目标大小(最小)和焦点外观。
  • 将高层设计需求映射到技术属性(ARIA 角色、特质、提示)。

核心概念

  • POUR 原则:WCAG 的基础(Perceivable, Operable, Understandable, Robust)。
  • 语义映射:使用原生元素而非通用容器,以提供内置无障碍支持。
  • 无障碍树:辅助技术实际“读取”的 UI 表示。
  • 焦点管理:控制键盘/屏幕阅读器光标的顺序和可见性。
  • 标签与提示:通过 aria-label、accessibilityLabel 和 contentDescription 提供上下文。

工作原理

第一步:标识组件角色

确定功能目的(例如:这是一个按钮、链接还是标签页?)。在求助于自定义角色之前,尽量使用最语义化的原生元素。

第二步:定义感知属性

  • 确保文本对比度达到 4.5:1(标准)或 3:1(大文本/UI)。
  • 为非文本内容(图片、图标)添加替代文本。
  • 实现响应式重排(放大至 400% 而不丢失功能)。

第三步:实现可操作控制

  • 确保最小 24x24 CSS 像素 的目标大小(WCAG 2.2 SC 2.5.8)。
  • 验证所有交互元素可通过键盘访问,并具有可见的焦点指示器(SC 2.4.11)。
  • 为拖拽操作提供单指针替代方案。

第四步:确保逻辑可理解

  • 使用一致的导航模式。
  • 提供描述性的错误信息和更正建议(SC 3.3.3)。
  • 实现“重复输入”(SC 3.3.7),防止重复询问相同数据。

第五步:验证稳健兼容性

  • 使用正确的名称、角色、值模式。
  • 对于动态状态更新,实现 aria-live 或活动区域。

无障碍架构图

flowchart TD
  UI["UI 组件"] --> Platform{平台?}
  Platform -->|Web| ARIA["WAI-ARIA + HTML5"]
  Platform -->|iOS| SwiftUI["无障碍特质 + 标签"]
  Platform -->|Android| Compose["语义 + contentDescription"]

  ARIA --> AT["辅助技术(屏幕阅读器、开关)"]
  SwiftUI --> AT
  Compose --> AT

跨平台映射

特性Web (HTML/ARIA)iOS (SwiftUI)Android (Compose)
主要标签aria-label / <label>.accessibilityLabel()contentDescription
辅助提示aria-describedby.accessibilityHint()Modifier.semantics { stateDescription = ... }
操作角色role="button".accessibilityAddTraits(.isButton)Modifier.semantics { role = Role.Button }
实时更新aria-live="polite".accessibilityLiveRegion(.polite)Modifier.semantics { liveRegion = LiveRegionMode.Polite }

示例

Web:无障碍搜索

<form role="search">
  <label for="search-input" class="sr-only">搜索产品</label>
  <input type="search" id="search-input" placeholder="搜索..." />
  <button type="submit" aria-label="提交搜索">
    <svg aria-hidden="true">...</svg>
  </button>
</form>

iOS:无障碍操作按钮

Button(action: deleteItem) {
    Image(systemName: "trash")
}
.accessibilityLabel("删除项目")
.accessibilityHint("永久从此列表中移除该项目")
.accessibilityAddTraits(.isButton)

Android:无障碍切换开关

Switch(
    checked = isEnabled,
    onCheckedChange = { onToggle() },
    modifier = Modifier.semantics {
        contentDescription = "启用通知"
    }
)

应避免的反模式

  • Div-按钮:使用 <div> 或 <span> 处理点击事件,但未添加角色和键盘支持。
  • 纯颜色含义:仅通过颜色变化指示错误或状态(例如,将边框变红)。
  • 模态框焦点未限制:模态框未能限制焦点,导致键盘用户可在模态框打开时导航背景内容。焦点必须被限制,并且可通过 Escape 键或明确的关闭按钮退出(WCAG SC 2.1.2)。
  • 冗余替代文本:在替代文本中使用“图片...”或“图像...”(屏幕阅读器已宣布角色“图像”)。

最佳实践检查清单

  • 交互元素符合 24x24px(Web)或 44x44pt(原生)目标大小。
  • 焦点指示器清晰可见且高对比度。
  • 模态框打开时限制焦点,并在关闭时干净释放(Escape 键或关闭按钮)。
  • 下拉菜单和弹出面板关闭时将焦点恢复到触发元素。
  • 表单提供基于文本的错误建议。
  • 所有仅含图标的按钮都有描述性文本标签。
  • 文本缩放时内容正确重排。

参考资源

相关技能

  • frontend-patterns
  • design-system
  • liquid-glass-design
  • swiftui-patterns

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

api-connector-builder

Build a new API connector or provider by matching the target repo

相关技能