Accessibility for mobile developers
full guide
People use your app with VoiceOver, TalkBack, large text, voice control or a switch, often on the go and with one hand. Most of that works if you use the controls iOS and Android give you, and tell the system what your own controls do. This guide helps you build accessible apps and keep them accessible. It is a starting point.
How to build accessible apps
chapter 1
Native controls
Must know: Use the platform’s own controls
A Button in SwiftUI or Jetpack Compose is announced as a button. It works with VoiceOver, TalkBack, Switch Control and a keyboard, and its text grows with the user’s text size. A Text with a tap gesture does none of that.
Style the standard control the way the design asks. That is almost always less work than rebuilding its behaviour.
If you really build your own control, tell the system what it is: .accessibilityAddTraits(.isButton) in SwiftUI, Modifier.semantics { role = Role.Button } in Compose.
Don’t
// SwiftUI
Text("Save")
.onTapGesture { save() }
// Jetpack Compose
Box(modifier = Modifier.clickable { save() }) {
Text("Save")
}Do
// SwiftUI
Button("Save") {
save()
}
// Jetpack Compose
Button(onClick = { save() }) {
Text("Save")
}Mark headings as headings
VoiceOver and TalkBack users jump from heading to heading to find their way around a screen, just like on the web. Big bold text is not a heading for them.
- SwiftUI:
.accessibilityAddTraits(.isHeader). - Jetpack Compose:
Modifier.semantics { heading() }. - Android Views:
ViewCompat.setAccessibilityHeading(view, true).
Give every screen a title and the right language
When a new screen opens, its title tells screen reader users where they are.
- SwiftUI: a
NavigationStackwith a.navigationTitleon every screen. - Jetpack Compose: a
Scaffoldwith aTopAppBaron every screen. For a panel that changes without a new screen, set a pane title:Modifier.semantics { paneTitle = "…" }.
Localise your app properly, so the screen reader uses the right voice. Mark words in another language too: the .accessibilitySpeechLanguage attribute of an AttributedString in SwiftUI, a SpanStyle with a localeList in Compose.
Know what your framework passes on
React Native, Flutter and .NET MAUI translate their components to native controls, but not everything makes it through. Each framework has its own way to set names and roles: accessibilityLabel and accessibilityRole in React Native, the Semantics widget in Flutter, SemanticProperties in .NET MAUI.
Test the app itself on a real phone with VoiceOver and TalkBack, not only the framework’s preview.
Screen readers
Must know: Give every control an accessible name
A screen reader announces the name of every button, link and field. Without a name, an icon button is just “button”, or the file name of the image.
Give icons a label: .accessibilityLabel("Search") in SwiftUI, contentDescription = "Search" in Compose. Don’t put the role in the label, like “Search button”: the screen reader already says it.
If a control has visible text, the name must contain that text. Voice Control and Voice Access users say what they see, like “tap Send”. In SwiftUI you can add other words people might say with .accessibilityInputLabels.
Don’t
// SwiftUI
Button {
search()
} label: {
Image("icon_search")
}
// Jetpack Compose
IconButton(onClick = { search() }) {
Icon(
imageVector = Icons.Default.Search,
contentDescription = null
)
}Do
// SwiftUI
Button {
search()
} label: {
Image("icon_search")
.accessibilityLabel("Search")
}
// Jetpack Compose
IconButton(onClick = { search() }) {
Icon(
imageVector = Icons.Default.Search,
contentDescription = "Search"
)
}Describe images, or hide them
An image that adds information gets a label: .accessibilityLabel("…") in SwiftUI, contentDescription = "…" in Compose.
A decorative image is hidden from the screen reader, so users don’t have to swipe past it:
- SwiftUI:
.accessibilityHidden(true). - Jetpack Compose:
contentDescription = null.
The guide for content designers explains what a good text alternative says.
Group what belongs together
A card with a title, a price and a rating should be one stop for the screen reader, not five.
- SwiftUI:
.accessibilityElement(children: .combine)on the card. - Jetpack Compose:
Modifier.semantics(mergeDescendants = true) { }on the card.
Check the reading order too. The screen reader goes from top left to bottom right, which is not always the order that makes sense. Fix it with .accessibilitySortPriority in SwiftUI, or isTraversalGroup and traversalIndex in Compose, not by moving things around on the screen.
Keep states and values up to date
Selected, expanded, on or off: the screen reader must hear it, not only see a colour change. Standard controls already do this. A Toggle says “on” or “off”, a Slider says its value.
For a control you build yourself:
- SwiftUI:
.accessibilityAddTraits(.isSelected)for a selected state,.accessibilityValue("Expanded")for other states and values. - Jetpack Compose:
selected = trueorstateDescription = "Expanded"inModifier.semantics.
Update the state in the code at the same moment it changes on the screen.
Offer another way for every gesture
Swipe to delete, pinch to zoom and long press for a menu are hard or impossible with a screen reader, a switch or one hand.
Add custom actions, so screen reader users find them in the actions menu:
- SwiftUI:
.accessibilityAction(named: "Delete") { … }. - Jetpack Compose:
customActionswith aCustomAccessibilityActioninModifier.semantics.
Better still, also show a visible button, like Enlarge and Shrink next to an image people can pinch. That helps everyone who can’t do the gesture, not only screen reader users.
Announce changes that don’t move focus
“Added to basket” or “Search in progress”: the screen reader user doesn’t see it appear, so tell them.
- SwiftUI: post an announcement. On iOS 17 and higher with
AccessibilityNotification.Announcement("…").post(), before that withUIAccessibility.post(notification: .announcement, argument: "…"). - Jetpack Compose: make the text a live region with
liveRegion = LiveRegionMode.PoliteinModifier.semantics.
Use polite announcements, which wait until the screen reader is done talking. Interrupt only for something urgent. And don’t announce everything: a screen reader that never stops talking gets turned off.
Move focus when the screen changes
When a dialog opens, focus goes into it, and the screen behind it can’t be reached. The standard dialogs do this for you: .alert in SwiftUI and AlertDialog in Compose. Always give them a cancel or dismiss button.
If you build your own modal view, add .accessibilityAddTraits(.isModal) in SwiftUI. In Compose, a pane title gives the panel a name, but it doesn’t keep focus inside it.
To move focus yourself, for example to a message that just appeared, use @AccessibilityFocusState with .accessibilityFocused in SwiftUI, or a FocusRequester in Compose.
Text size and display
Must know: Let text grow with the user’s setting
Many people use a larger text size. On iOS, the accessibility sizes go well beyond 200%.
- SwiftUI: use text styles, like
.font(.title)or.font(.headline). ATextwithout a font uses the body style and scales by itself. For a custom font, use.font(.custom(name, size: size, relativeTo: .body)). In UIKit, useUIFontMetrics. - Android: set every text size in
sp, preferably once, in yourTypography.
Then make sure the layout can grow with it. Let text wrap instead of cutting it off, don’t give text a fixed height or width, and put the content in a ScrollView or a scrollable Column. The guide for UX and UI designers explains how to design for large text.
Don’t
// SwiftUI
Text("Delivery address")
.lineLimit(1)
.frame(width: 100, height: 100)
// Jetpack Compose
Text(
text = "Delivery address",
maxLines = 1,
modifier = Modifier
.width(100.dp)
.height(100.dp)
)Do
// SwiftUI
ScrollView {
Text("Delivery address")
}
// Jetpack Compose
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
Text(text = "Delivery address")
}Don’t lock the orientation
Some people have their phone or tablet mounted on a wheelchair, in landscape. Support both orientations, unless one is essential, like for a piano app.
- iOS: list all orientations under
UISupportedInterfaceOrientationsinInfo.plist. - Android: remove
android:screenOrientationfrom your manifest.
Then check that every screen still works in landscape, also with a large text size.
Respect the user’s display settings
iOS and Android let people reduce motion, make text bold and choose dark mode. Standard controls follow these settings. Check them where you set something yourself:
- Reduce motion. Turn off animations that aren’t essential. SwiftUI:
UIAccessibility.isReduceMotionEnabled. Android: the animation scalesANIMATOR_DURATION_SCALEandTRANSITION_ANIMATION_SCALEare0. - Bold text. If you set a font weight yourself, check the setting. SwiftUI: the
legibilityWeightenvironment value. Compose:fontWeightAdjustmentin the configuration, on Android 12 and higher. - Dark mode. Give colours and images a dark version in your assets, or check
colorSchemein SwiftUI andisSystemInDarkTheme()in Compose.
Check contrast in light and dark mode
Use the colours from your design system, and check every screen in light and dark mode. A colour that works on white often doesn’t work on black.
Tools find most contrast problems for you: Accessibility Inspector in Xcode, Accessibility Scanner on Android, and the Compose UI checks on previews in Android Studio.
On iOS, people can also turn on Increase Contrast. You can read it with the colorSchemeContrast environment value in SwiftUI.
The guide for UX and UI designers explains which contrast you need.
Touch, keyboard and voice
Must know: Make touch targets big enough
Small targets are hard to hit with a tremor, on a moving train or with a big thumb. WCAG asks for at least 24 by 24 points or dp. Apple recommends 44 by 44 points and Material Design 48 by 48 dp: follow those.
The touch area can be bigger than the icon. Set the minimum size on the button, not on the image inside it:
- SwiftUI:
.frame(minWidth: 44, minHeight: 44). - Jetpack Compose:
Modifier.widthIn(min = 48.dp).heightIn(min = 48.dp).
Support keyboards and switches
People connect a keyboard to a tablet, or use Full Keyboard Access, Switch Control or Switch Access. Every control must be reachable in a logical order, and it must be clear where the focus is.
Standard controls do this. For your own controls:
- SwiftUI:
.accessibilityRespondsToUserInteraction(true)makes an element reachable with Full Keyboard Access,.accessibilitySortPrioritychanges the order. - Jetpack Compose:
Modifier.focusable()makes an element reachable,focusPropertieschanges the order. Show the focus, for example with aborderthat changes inonFocusChanged.
Don’t depend on motion or dragging
Shake to undo or tilt to scroll doesn’t work for someone whose phone is mounted on a wheelchair, or who can’t move it precisely. Dragging is hard with a tremor or a switch.
- Give every action you trigger with motion a button as well.
- Give every slider and every list you can reorder by dragging a way to do it with single taps, like − and + buttons next to a slider.
Forms and login
Give every field a visible label
A placeholder disappears as soon as you type, and is not always read out. Show a label with every field, and make sure the screen reader reads it when the field gets focus.
- SwiftUI: put the
TextFieldin aLabeledContentwith the label. - Jetpack Compose: use the
labelof theTextField. Compose has no built-in way to link a separate text to a field.
The guide for UX and UI designers explains how to design accessible forms.
Make errors reach everyone
Show the error in text, not only as a red line, and say how to fix it: “Enter a date like 01/01/2000.” Then make sure the screen reader hears it.
- SwiftUI: show the message in a
Textand post it as an announcement. - Jetpack Compose: set
isErroron theTextField, show the message in itslabel, and adderror(message)inModifier.semantics.
In Compose, check that androidx.compose.ui.semantics.error is imported. Otherwise Kotlin uses its standard error function, which throws an exception.
Help the keyboard, autofill and password managers
Typing on a phone is hard for many people. Tell the system what a field is for, so it can show the right keyboard and fill it in:
- SwiftUI:
.textContentType(.emailAddress)and.keyboardType(.emailAddress). Use.usernameand.passwordon login fields, so password managers find them. - Jetpack Compose:
keyboardOptionswith the rightKeyboardType, and autofill with the right type for each field.
Don’t make people remember or retype a password or code. Never block pasting into a password or code field, and offer a way in without a password, like a sign-in link by email.
Useful links
Making accessibility part of your work
chapter 2
Accessibility is cheapest to fix in the code you are writing today. Before you open a pull request, try your screen with VoiceOver or TalkBack and with the largest text size.
Build to WCAG 2.2 level AA. WCAG was written for the web, but EN 301 549 applies the same criteria to apps, and WCAG2ICT explains how each one applies to software. The guide for product managers explains which law refers to which version.
In your workflow
Must know: Test on a real device
The iOS Simulator has no VoiceOver, and an emulator doesn’t feel like a phone in your hand. Before you open a pull request, test your screen on a real device:
- With VoiceOver or TalkBack. Swipe through the screen, double-tap to activate, and listen to what you hear.
- With the largest text size, in portrait and in landscape.
- With Voice Control or Voice Access: can you say what you see?
- With a keyboard connected, if your app runs on a tablet.
Set up the accessibility shortcut on your phone, so you can turn the screen reader on and off quickly. The guide for testing explains what to look for.
Use the platform’s inspection tools
You don’t need a screen reader to see what it will say.
- Accessibility Inspector, in Xcode, shows the label, traits and value of each element, and can audit a screen for common problems.
- Accessibility Scanner, an app for Android, scans the screen on your phone and suggests improvements, such as bigger targets or more contrast.
- The Compose UI checks in Android Studio find common problems in your previews while you build.
Let tests catch the easy mistakes
Automated checks find the mistakes a computer can see: a missing label, a target that is too small, too little contrast. Let them run where you already work:
- On iOS, run an accessibility audit in your UI tests with
XCUIAccessibilityAudit. - On Android, add the Accessibility Test Framework for Android to your UI tests.
- Use a linter: SwiftLint and Android Lint have a few accessibility rules.
Tools find only part of the issues. A clean report doesn’t mean your app is accessible.
Include accessibility in code review
Add a few fixed questions to every code review:
- Does every control have a name, a role and the right state?
- Does it still work with the largest text size?
- Can you do everything without gestures, motion or dragging?
Agree with your team that a pull request with known accessibility issues is not done.
Tell users what your app supports
In the App Store, you can add Accessibility Nutrition Labels to your app. They tell people before they download whether they can complete common tasks in your app with VoiceOver, Voice Control, Larger Text, Reduced Motion and other features. Only claim what you have tested, from start to finish.
Publish an accessibility statement for your app too. It says what doesn’t work yet and how people can contact you when they get stuck.
Learning more
Must know: Look it up for your platform
This guide is a starting point. When you need to know how something works on your platform, look it up on Appt. It is the best accessibility resource for app developers I know.
Appt explains each accessibility feature and each WCAG criterion for apps, with code for iOS, Android and cross-platform frameworks. The code examples in this guide follow their samples.