A pharmacy dashboard marked ready orders with a green dot. VoiceOver read “Order 1042. Image.” A colleague who works from the keyboard could select the order but could not reach the action that marked it collected. The screen passed design review, and every pixel was where the mockup put it.
The usual repair is a label on the dot. That treats the symptom. The first bug happened earlier, in the view model:
import SwiftUI
struct LegacyOrderRow {
let number: Int
let statusColor: Color // .green, .orange, .red
}The status was turned into a color on its way to the view, and the meaning was thrown away. Nothing downstream could say “ready” any more, because nothing downstream knew. The view could not label what it was never told.
Accessibility in this sense is not a layer on top of the interface. It is a constraint on what data reaches it, and like every architectural constraint, it is cheapest at the boundary where the meaning still exists.
Keep product meaning in the model
A status can drive a localized label, a symbol, a visual treatment, an App Intent, and a VoiceOver description. Keep the state available to all of them, and let each presentation derive what it needs:
enum OrderStatus: Sendable {
case ready, preparing, needsAttention
var title: LocalizedStringResource {
switch self {
case .ready: "Ready for pickup"
case .preparing: "Being prepared"
case .needsAttention: "Needs attention"
}
}
var symbol: String {
switch self {
case .ready: "checkmark.circle"
case .preparing: "clock"
case .needsAttention: "exclamationmark.triangle"
}
}
var tint: Color {
switch self {
case .ready: .green
case .preparing: .orange
case .needsAttention: .red
}
}
}
struct OrderStatusBadge: View {
let status: OrderStatus
var body: some View {
Label {
Text(status.title)
} icon: {
Image(systemName: status.symbol)
.foregroundStyle(status.tint)
.accessibilityHidden(true)
}
}
}The color is still there. It is now a consequence of the status, not its replacement. The words survive color filters, a monochrome display, and someone reading the screen in sunlight. And the component makes the right thing the only thing: OrderStatusBadge cannot be constructed without a status, the same way a Button cannot be constructed without an action. The next screen that uses it inherits the semantics without anyone remembering to add them.
Build the interaction around a command
The second bug was the unreachable action. On the dashboard, “Mark collected” appeared as a swipe action on the row. Swipe actions are invisible to a keyboard and awkward with Switch Control. A second gesture would not fix that. What fixes it is a command with several entry points.
struct Order: Identifiable, Sendable {
let id: Int
let customer: String
var status: OrderStatus
}
struct OrderRow: View {
let order: Order
let markCollected: () -> Void
var body: some View {
HStack {
VStack(alignment: .leading) {
Text("Order \(order.id)").font(.headline)
Text(order.customer).foregroundStyle(.secondary)
}
Spacer()
OrderStatusBadge(status: order.status)
}
.accessibilityElement(children: .combine)
.accessibilityAction(named: "Mark collected", markCollected)
.swipeActions {
Button("Mark collected", action: markCollected)
}
}
}
extension FocusedValues {
@Entry var markSelectedOrderCollected: (() -> Void)?
}
struct OrderCommands: Commands {
@FocusedValue(\.markSelectedOrderCollected) private var markCollected
var body: some Commands {
CommandMenu("Order") {
Button("Mark Collected") { markCollected?() }
.keyboardShortcut("k", modifiers: .command)
.disabled(markCollected == nil)
}
}
}The dashboard publishes the command for whichever order is selected, and only when one is:
struct Dashboard: View {
@State private var orders: [Order] = []
@State private var selection: Order.ID?
var body: some View {
List(orders, selection: $selection) { order in
OrderRow(order: order) { markCollected(order.id) }
}
.focusedSceneValue(
\.markSelectedOrderCollected,
selection.map { id in { markCollected(id) } }
)
}
private func markCollected(_ id: Order.ID) {
guard let index = orders.firstIndex(where: { $0.id == id }) else { return }
orders.remove(at: index) // stands in for the real command
}
}One operation, three ways in. The swipe stays for people who use it. The named accessibility action puts “Mark collected” in the VoiceOver rotor and the Voice Control vocabulary. The command puts it in the menu bar on Mac and iPad, with a shortcut, and routes it to the focused window through focusedSceneValue. A read-only window simply publishes no value, and the menu item disables itself without the operation knowing anything about windows.
The row combines its children so VoiceOver stops once, on “Order 1042, Maria Silva, Ready for pickup,” instead of three times. That is a judgment, not a rule: an element with its own distinct action may deserve its own stop. The test is whether the listener leaves the row knowing the status and how to act on it.
Prefer native controls, because they bring keyboard, Voice Control, Switch Control, and VoiceOver behavior for free. When a control must be custom, say a rating made of stars, accessibilityRepresentation can present it as a slider bound to the same value, so assistive technologies get a control they already understand. The visible version still needs a way for a keyboard user to move and change it.
Let layout follow content
A four-column grid at the default text size becomes unreadable at accessibility sizes. The answer is a layout that chooses, not a font that shrinks:
struct OrderSummary: View {
let order: Order
@Environment(\.dynamicTypeSize) private var typeSize
var body: some View {
let layout = typeSize.isAccessibilitySize
? AnyLayout(VStackLayout(alignment: .leading, spacing: 8))
: AnyLayout(HStackLayout(spacing: 16))
layout {
Text("Order \(order.id)")
Text(order.customer)
OrderStatusBadge(status: order.status)
}
}
}AnyLayout changes the arrangement without changing the view identity, so selection, focus, and reading order survive the switch. Test the transitions that real people make: the longest localization you ship, accessibility text sizes, right-to-left, and a Mac window dragged down to just above its minimum width. Let controls grow around their labels, and keep fixed dimensions for content that has a reason to be fixed.
Reduced motion and increased contrast belong in the components that animate or draw, not in every screen. When a row expands with reduced motion on, the information and the focus destination stay the same. The preference changes how the transition looks, never what it delivers.
Verify what automation can see, and what it cannot
Run an audit on representative screens in a UI test:
import XCTest
final class DashboardAccessibilityTests: XCTestCase {
@MainActor
func testDashboardPassesAudit() throws {
let app = XCUIApplication()
app.launch()
try app.performAccessibilityAudit()
}
}The audit finds missing labels, small hit targets, clipped text, and contrast failures. It cannot find a label that is present and wrong, a focus that lands somewhere unhelpful after a sheet dismisses, or an action reachable only by gesture. Those need a person, and a short, repeatable manual pass: VoiceOver through the main task, Full Keyboard Access through the same task, the largest text size, and one run with the screen turned away.
What to ask of your own code
- Where does the meaning of a status become a color, an image, or a position, and does the meaning survive that step?
- Can a reusable component be created without the information assistive technologies need?
- Is every action reachable without a gesture: by keyboard, by voice, by the rotor?
- When the text size jumps, does the layout change, or does the content get clipped?
- Which checks does the automated audit cover, and who does the rest?
For the pharmacy screen, the acceptance test fits in one sentence: with the display turned away, can you find the ready order and know what to do next? When the component makes that true for one screen, every screen that uses it inherits it. That is the architectural payoff.
References
- Accessibility in SwiftUI
- Performing accessibility audits for your app
- FocusedValue
- accessibilityRepresentation(representation:)
Related editions
- Edition 6 · A11y, or You Can Call It Accessibility
- Edition 14 · Stop Designing for Screens
- Edition 26 · When the Left Inset Is Not the Right Inset
If this edition sharpened your next review, you can buy me a coffee.