Accessibility

Run the Accessibility Test Framework (ATF) over each rendered preview and surface the findings, the semantic hierarchy, the annotated overlay PNG, and a 48 dp touch-target audit as four related kinds.

At a glance

   
Kinds a11y/atf, a11y/hierarchy, a11y/overlay, a11y/touchTargets
Schema version 1
Modules :data-a11y-core (published) · :data-a11y-connector · :data-a11y-hierarchy-android
Render mode a11y (always-on; LocalInspectionMode = false)
Cost low
Token usage ~100 tok inline (e.g. a11y/atf ~370 chars); +~1.5 k per a11y/overlay PNG read. See token usage.
Transport inline (JSON) · path (overlay PNG)
Platforms Android

What it answers

  • a11y/atf — does this preview violate WCAG / Android a11y best practices? Each AccessibilityFinding carries a check id, severity, source, and the node it implicates. Trade-off: a11y mode flips LocalInspectionMode = false so Compose populates real semantics, which means infinite animations tick through rather than parking on the paused frame clock.
  • a11y/hierarchy — what does an assistive technology see? Per-node label, role, states, merged, boundsInScreen. Read it the same way TalkBack would.
  • a11y/overlay — the rendered PNG with finding bounding boxes baked in. Pure-image; transport=path.
  • a11y/touchTargets — every interactive node with its measured bounds vs. the 48 dp Material minimum, with overlap detection between adjacent targets.

What it does NOT answer

  • It is not a substitute for testing with real assistive technology — TalkBack on a real device may surface gestures or focus order issues that a single static frame can’t.
  • It does not opine on copy quality (placeholder text, jargon). Use text/strings for that.
  • Findings are advisory, not pass/fail; severity is the agent’s signal.

Use cases

  • PR review: gate UI PRs on no new ERROR-severity findings; reviewers can paste the overlay PNG inline.
  • Refactor confidence: diff a11y/hierarchy before/after a state-hoisting change to confirm semantics didn’t regress.
  • Density audit: sweep all previews for a11y/touchTargets violations on a Wear watch face where small targets matter most.

Payload shape

AccessibilityFindingsPayload, AccessibilityHierarchyPayload, AccessibilityTouchTargetsPayload, AccessibilityOverlayArtifact (path-only) — defined in :data-a11y-core.

// a11y/atf
{
  "findings": [
    { "checkId": "TouchTargetSize", "severity": "ERROR",
      "label": "Submit", "boundsInScreen": "48,200,144,232" }
  ]
}

// a11y/hierarchy
{
  "nodes": [
    { "label": "Submit", "role": "Button", "states": ["Enabled"],
      "merged": true, "boundsInScreen": "48,200,144,232" }
  ]
}

Enabling

composePreview {
    previewExtensions {
        a11y { enableAllChecks() }   // or enableCheck("TouchTargetSize")
    }
}

When enabled, the renderer also writes build/compose-previews/data/<id>/a11y-atf.json, a11y-hierarchy.json, a11y-overlay.png, and a11y-touchTargets.json on every render of <id>.

The legacy build/compose-previews/accessibility-per-preview/<id>.json location is kept as a back-compat alias for one release, then retires.

Companion products

  • Layout inspectorcompose/semantics for testTag / role / mergeMode without the ATF audit.
  • Stringstext/strings for drawn-text quality next to assistive labels.

See also the agent-facing review guidance in skills/compose-preview/design/A11Y.md.


Apache 2.0 licensed. Source on GitHub.

This site uses Just the Docs, a documentation theme for Jekyll.