Accessibility

affaan-m/ECC/pi/core/skills/accessibility

作者 affaan-mef648e01899ba3e8dc6371642deaaf64b4477775无许可证275K 个星标收录于 2026年10月9日更新于 2026年10月9日仓库4天前更新

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels, accessibility traits and hints, focus management, contrast, target size, and screen-reader support. Use when building or auditing UI for accessibility compliance, keyboard navigation, or screen-reader support.

AI 生成的概览

指导在 Web、iOS 和 Android 上按 WCAG 2.2 AA 级设计、实现和审计无障碍界面。

功能
该技能提供按 WCAG 2.2 AA 级构建和审计无障碍用户界面的指导。内容涵盖语义角色与标签、焦点管理、对比度、目标尺寸、实时区域和屏幕阅读器支持,并给出 Web(HTML/ARIA)、iOS(SwiftUI)和 Android(Compose)的跨平台映射。它还列出反模式清单和最佳实践检查表。其产出为规范与指导,而非文件或代码成品。
适用场景
适用于为 Web、iOS 或 Android 定义 UI 组件规范,或审计现有代码中的无障碍障碍与合规缺口。也适合实现 WCAG 2.2 的新标准(如最小目标尺寸和焦点外观),或将设计需求映射到技术属性。
运行要求
无需任何工具、软件包或凭据;仅为说明文档,不附带脚本。

Accessibility (WCAG 2.2)

This skill ensures that digital interfaces are Perceivable, Operable, Understandable, and Robust (POUR) for all users, including those using screen readers, switch controls, or keyboard navigation. It focuses on the technical implementation of WCAG 2.2 success criteria.

When to Use

  • Defining UI component specifications for Web, iOS, or Android.
  • Auditing existing code for accessibility barriers or compliance gaps.
  • Implementing new WCAG 2.2 standards like Target Size (Minimum) and Focus Appearance.
  • Mapping high-level design requirements to technical attributes (ARIA roles, traits, hints).

Core Concepts

  • POUR Principles: The foundation of WCAG (Perceivable, Operable, Understandable, Robust).
  • Semantic Mapping: Using native elements over generic containers to provide built-in accessibility.
  • Accessibility Tree: The representation of the UI that assistive technologies actually "read."
  • Focus Management: Controlling the order and visibility of the keyboard/screen reader cursor.
  • Labeling & Hints: Providing context through aria-label, accessibilityLabel, and contentDescription.

How It Works

Step 1: Identify the Component Role

Determine the functional purpose (e.g., Is this a button, a link, or a tab?). Use the most semantic native element available before resorting to custom roles.

Step 2: Define Perceivable Attributes

  • Ensure text contrast meets 4.5:1 (normal) or 3:1 (large/UI).
  • Add text alternatives for non-text content (images, icons).
  • Implement responsive reflow (up to 400% zoom without loss of function).

Step 3: Implement Operable Controls

  • Ensure a minimum 24x24 CSS pixel target size (WCAG 2.2 SC 2.5.8).
  • Verify all interactive elements are reachable via keyboard and have a visible focus indicator (SC 2.4.11).
  • Provide single-pointer alternatives for dragging movements.

Step 4: Ensure Understandable Logic

  • Use consistent navigation patterns.
  • Provide descriptive error messages and suggestions for correction (SC 3.3.3).
  • Implement "Redundant Entry" (SC 3.3.7) to prevent asking for the same data twice.

Step 5: Verify Robust Compatibility

  • Use correct Name, Role, Value patterns.
  • Implement aria-live or live regions for dynamic status updates.

Accessibility Architecture Diagram

mermaid
flowchart TD  UI["UI Component"] --> Platform{Platform?}  Platform -->|Web| ARIA["WAI-ARIA + HTML5"]  Platform -->|iOS| SwiftUI["Accessibility Traits + Labels"]  Platform -->|Android| Compose["Semantics + ContentDesc"]
  ARIA --> AT["Assistive Technology (Screen Readers, Switches)"]  SwiftUI --> AT  Compose --> AT

Cross-Platform Mapping

FeatureWeb (HTML/ARIA)iOS (SwiftUI)Android (Compose)
Primary Labelaria-label / <label>.accessibilityLabel()contentDescription
Secondary Hintaria-describedby.accessibilityHint()Modifier.semantics { stateDescription = ... }
Action Rolerole="button".accessibilityAddTraits(.isButton)Modifier.semantics { role = Role.Button }
Live Updatesaria-live="polite".accessibilityLiveRegion(.polite)Modifier.semantics { liveRegion = LiveRegionMode.Polite }

Examples

Web: Accessible Search

html
<form role="search">  <label for="search-input" class="sr-only">Search products</label>  <input type="search" id="search-input" placeholder="Search..." />  <button type="submit" aria-label="Submit Search">    <svg aria-hidden="true">...</svg>  </button></form>

iOS: Accessible Action Button

swift
Button(action: deleteItem) {    Image(systemName: "trash")}.accessibilityLabel("Delete item").accessibilityHint("Permanently removes this item from your list").accessibilityAddTraits(.isButton)

Android: Accessible Toggle

kotlin
Switch(    checked = isEnabled,    onCheckedChange = { onToggle() },    modifier = Modifier.semantics {        contentDescription = "Enable notifications"    })

Anti-Patterns to Avoid

  • Div-Buttons: Using a <div> or <span> for a click event without adding a role and keyboard support.
  • Color-Only Meaning: Indicating an error or status only with a color change (e.g., turning a border red).
  • Uncontained Modal Focus: Modals that don't trap focus, allowing keyboard users to navigate background content while the modal is open. Focus must be contained and escapable via the Escape key or an explicit close button (WCAG SC 2.1.2).
  • Redundant Alt Text: Using "Image of..." or "Picture of..." in alt text (screen readers already announce the role "Image").

Best Practices Checklist

  • Interactive elements meet the 24x24px (Web) or 44x44pt (Native) target size.
  • Focus indicators are clearly visible and high-contrast.
  • Modals contain focus while open, and release it cleanly on close (Escape key or close button).
  • Dropdowns and menus restore focus to the trigger element on close.
  • Forms provide text-based error suggestions.
  • All icon-only buttons have a descriptive text label.
  • Content reflows properly when text is scaled.

References

Related Skills

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

来源与署名

来源:affaan-m/ECC位于pi/core/skills/accessibility提交ef648e0

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架