Accessibility

From aaione/everything-claude-code-zh · View interactive version

Accessibility is an AI agent skill from the GitHub repository aaione/everything-claude-code-zh. 使用 WCAG 2.2 AA 级标准设计、实施和审计包容性数字产品。使用此技能为 Web 和原生平台(iOS/Android)生成语义化 ARIA 和辅助功能属性。

How to use this skill

Skill file

无障碍功能(WCAG 2.2)

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

何时使用

核心概念

工作原理

步骤 1:识别组件角色

确定功能用途(例如,这是按钮、链接还是选项卡?)。在使用自定义角色之前,先使用最语义化的原生元素。

步骤 2:定义可感知属性

步骤 3:实施可操作控件

步骤 4:确保可理解逻辑

步骤 5:验证稳健兼容性

无障碍架构图

flowchart TD
  UI["UI 组件"] --> Platform{平台?}
  Platform -->|Web| ARIA["WAI-ARIA + HTML5"]
  Platform -->|iOS| SwiftUI["辅助功能特征 + 标签"]
  Platform -->|Android| Compose["语义 + 内容描述"]

  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 = "启用通知"
    }
)

避免的反模式

最佳实践清单

参考资料

相关技能

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.