Skip to content

An open source design system that's fully customizable and agent ready

TypeScript
8.6 KB
Raw Blame

Accessibility contract (Swift)

  • Status: draft
  • Relation: extends AST-093 FR3 and FR5. Applies the core accessibility records AST-085 (focusable disabled controls) and AST-086 (status announcements) to VoiceOver and Apple's accessibility settings.

Summary

A VoiceOver user hears the same name, role, state, and messages from an Astryx component on iPhone as a screen-reader user hears on the web: a message that appears is announced once, and one already on screen when it opens is not. People who turn on Reduce Motion, Reduce Transparency, Bold Text, Button Shapes, or Differentiate Without Color get components that honor each setting.

Requirements

  • X1 — Name, role, and state come from the core contract. The contract's accessible name becomes accessibilityLabel, its role becomes the matching trait (.isButton, .isHeader with accessibilityHeading, .isToggle, .isSelected, .isLink), and its value becomes accessibilityValue. A component built on a SwiftUI control keeps that control's own traits and adds none that duplicate them. A custom control that has a system counterpart exposes it with accessibilityRepresentation.
  • X2 — Disabled controls stay reachable (AST-085). A disabled control stays in the VoiceOver order and is read as dimmed. When the contract gives a reason, it is the control's accessibilityHint.
  • X3 — Announcements follow AST-086. A component AST-086 FR11 covers announces its own message with AccessibilityNotification.Announcement once when it appears or its words change after its screen has loaded, and not when it is present as the screen loads, except a message that VoiceOver can reach only through its announcement, which announces even as the screen loads (FR11). Errors and time-critical failures are announced at high priority (FR5), and re-rendering the same message does not announce it again (FR6). Banner, FieldStatus, and a grouped field's status keep their own rules, as FR11 says: Banner's status is visual only and the Banner never announces itself; the app announces an outcome when it happens (component:Banner FR8).
  • X4 — Icons are decorative unless labeled (AST-082 FR17). An icon is hidden from VoiceOver unless it carries a label. An icon-only control requires a label.
  • X5 — One element per thing a person reads. A component that reads as one thing, such as a banner or a list row, is one accessibility element. A label on a container does not merge what the container holds: a text child inside a labelled ancestor keeps its own element and its static-text role, and that element publishes the ancestor's label in place of the child's own words, so the same name is reachable twice and the words the child draws are never read. A component that reads as one thing merges its children explicitly rather than resting on a container label: accessibilityElement(children: .combine), .ignore with a label of its own, and accessibilityRepresentation each do this, as does any equivalent that exposes one element named with the component's own words. Every action reachable only by a gesture (swipe, long press, drag) is also an accessibilityAction.
  • X6 — Settings are honored.
    • Reduce Motion: movement becomes a cross-fade or no animation.
    • Reduce Transparency: translucent surfaces become opaque.
    • Bold Text: weights come from system or text-style fonts, so they follow legibilityWeight.
    • Differentiate Without Color: every state shown by color also has a shape, an icon, or a word.
    • Button Shapes: controls drawn without a visible edge show one.
  • X7 — Targets are at least 44 by 44 points, even when the drawn control is smaller. A control's rendered size follows the environment its ancestor establishes, so a target is measured in the environment the component ships in, at the default and the largest text sizes, and not in isolation.

Acceptance checks

Requirement Check
X1 Unit tests assert each component's label, traits, and value in every state its contract names.
X2 A test disables a focused control and finds it still focused, read as dimmed, with its reason as the hint.
X3 A test shows a covered component's message after load and observes exactly one announcement, at high priority for an error; a time-critical failure is also high priority; a second render announces nothing; the same message present at load announces nothing; a Banner shown after load announces nothing. A message VoiceOver can reach only through its announcement, present at load, announces once.
X4, X5 A UI test runs performAccessibilityAudit() on a screen of every component at the default and largest text sizes, with no failures.
X5 A test places a text child inside a container that carries a label and finds exactly one element, reachable once, whose name is the words the component reads as. The audit does not establish this on its own, so the test asserts it.
X6 Captures under Reduce Motion show no movement; under Reduce Transparency, opaque surfaces; under Bold Text, heavier text in every component; under Differentiate Without Color, every state shown by color also shows a shape, an icon, or a word; under Button Shapes, every control drawn without a visible edge shows one.
X7 The audit's hit-region check passes for every control, measured in the environment the component ships in and at the default and largest text sizes.

Current state

  • On main, the Swift package packages/native/apple holds generated props, the wire, and the logic host, and no SwiftUI views.
  • No Swift component has accessibility tests or an audit.

Open questions

  • OQ1 — Who words the spoken status and state? Recommendation: the library, in its own String Catalog, with the same meaning as core's default strings on the web.

References