Accessibility in server driven SwiftUI
Native widgets inherit VoiceOver. The schema still has to send alt text, button traits, and type that scales.
Accessibility in server driven SwiftUI is native because the widget is a real SwiftUI view, and it is incomplete until the schema sends the labels the platform cannot invent. VoiceOver, Dynamic Type, and button traits come from UIKit and SwiftUI. Alt text, tap actions, and font sizes come from the JSON. Drop either half and the page looks fine to a sighted engineer with default type and fails for everyone else.
Hacker News threads on "What Is Server-Driven UI?" keep returning to the same objection: if this is a WebView, you gave up localisation, dark mode, and accessibility. Native SDUI is the reply. This post is the proof against Flow-UI's sources, not a scoreboard. See atoms for the fields, architecture for where they attach, and what native means for the view-debugger test.
What you inherit from the platform#
A WidgetView is a View. Scrolling is ScrollView physics. Focus, rotor, and the accessibility inspector see the same tree they see in a handwritten SwiftUI page. You do not ship a parallel a11y engine.
That inheritance is a floor. A Rectangle plus onTapGesture is invisible to VoiceOver: no trait, no action, no hint that the control does anything. Flow-UI's envelope layer exists so a backend-declared tap does not become that trap.
Envelope taps become buttons#
EnvelopeGestures on the widget row attaches onTapGesture and onLongPressGesture only when the backend sent those events. When a tap is present, the modifier also:
- Combines children into one accessibility element
- Adds the
.isButtontrait - Registers an accessibility action that dispatches
"tap" - Names a "Long press" action when
long_pressis present
The trait is not a separate JSON key. It rides on the envelope actions object you already send for sighted users. If the widget is tappable with a finger, it is a button to VoiceOver. If it is not tappable, it stays passive. Do not add a fake tap so the row "feels clickable" in a screenshot; you will announce a control that does nothing useful.
Starter widgets that draw their own controls still have to label them. button_row uses FlowButton. stepper_row hides decorative chrome, labels the title, and exposes the count as an accessibility value. Copy that pattern in your product widgets. The envelope cannot see inside a custom body.
Images: alt or decorative#
ImageData.alt is optional on purpose. An image with no alt is treated as decorative and hidden from assistive technology. That is the right default for backdrops, scrims, and repeating merchandise photography that the adjacent title already names. It is the wrong default for an image that carries meaning the text does not repeat: a status glyph, a diagram, a photo that is the content.
FlowImage maps a non-empty alt to an accessibility element with .isImage and that label. Empty or missing alt calls accessibilityHidden(true). CMS authors who leave alt blank are not getting a filename announced; they are getting silence. Train the CMS. Do not invent alt on the client from the URL.
Bare string shorthand { "image": "https://..." } has no alt. Use the object form for anything meaningful.
Type that scales#
Every font in the framework used to be .system(size:), a pinned point size. A page built that way ignored Dynamic Type entirely. Sizes now go through FlowFontScaling in DynamicTypeScaling.swift: the backend point size is mapped to the nearest built-in text style, then UIFontMetrics scales it. Views that render scaled text read @Environment(\.dynamicTypeSize) so SwiftUI re-evaluates when the setting changes.
ThemeDefaults.scalesFontsWithDynamicType defaults to true. Hosts that need pinned sizing, a tightly art-directed banner for instance, can turn it off on their theme. That is an explicit opt-out, not the default.
Icons go through scaledIcon so glyphs keep pace with the text they sit beside instead of staying stubbornly small.
macOS has no UIFontMetrics equivalent in this helper, so sizes stay as sent there. iOS is the surface this article is about.
FlowText and FlowImage pick up theme, scaling, and alt. A raw Text(content.orderNumber.text).font(.system(size: 16)) opts out. The untitled registration is the same as every other widget:
What the schema still has to send#
Native widgets do not invent copy. You still need:
| Field | Where it lives | If you omit it |
|---|---|---|
ImageData.alt | Image atoms | Image is decorative and hidden |
Envelope actions.tap | Widget envelope | No button trait, no activation action |
FontData.size or token | Text atoms | Fallback body font from ThemeDefaults |
Button title | ButtonData | The control has nothing to announce |
| Dark hex or tokens | ColorData | Contrast in dark appearance is guesswork |
Localisation is a backend concern. Flow-UI does not translate. Send the string the user should hear. Dynamic Type scales the font; it does not shorten English.
Do not put essential instructions only in a background image. VoiceOver will skip it if alt is missing, and a large type user may never see the full bitmap.
Custom widgets are where teams regress#
The starter catalogue is eight worked examples. Your order_card is where accessibility usually dies: a HStack of unlabelled icons, a stepper drawn as two tappable Texts, a badge that is colour only.
Rules that match the package conventions:
- Meaningful images take an
alt. - Controls you build yourself get a label.
- Backend font sizes go through the theme so they scale with Dynamic Type.
- Do not apply layout chrome inside the view; the renderer already wraps the body.
If you wrap the whole widget in .accessibilityElement(children: .ignore) and forget a label, you have built a hole. Prefer .combine when the envelope already treats the row as one button.
Dark mode is part of the same story#
Colour contrast is accessibility. ColorData.dark_hex and ThemeProvider tokens are how the page stays readable when appearance flips, without a second payload. That is covered in theming server driven SwiftUI. A 4.5:1 ratio is your bar, not a Flow-UI feature. The framework only resolves what you sent.
WebViews can be accessible. They are a different product: web semantics, web focus, web type. Pick them for documents. Pick native widgets when the page should feel like the rest of the app. SDUI on iOS is native SwiftUI, not WebViews.
Read next#
- Atoms lists
alt,ColorData,FontData, andButtonData. - Architecture is where envelope actions attach to the row.
- What native means in an SDUI stack and SDUI on iOS are the native-versus-WebView pair.
Accessibility in server driven SwiftUI: inherit VoiceOver from the view tree, send alt, declare taps so they become buttons, and let backend sizes scale. The schema is the other half of native.
Related documentation
Related articles
- Production6 min read
Decode diagnostics in production
Surface DecodeDiagnostics in debug overlays and logs. A malformed widget should be a telemetry event, not a blank screen.
- Production6 min read
Swift 6 and MainActor widgets
WidgetView is MainActor. Swift 6 language mode is the default for Flow-UI. Register widgets that are safe to render on the main actor.
- Production6 min read
Theming server driven SwiftUI
Hex colors with dark_hex out of the box. Design tokens through ThemeProvider. Light and dark without a second payload.
More on the blog.
Read the source
Flow-UI is MIT licensed. The schema, renderer and starter widgets live on GitHub.
GitHubGet started with Flow-UI
Install the Swift package, register a widget, and render a page from JSON.
Get started