SwiftUI Accessibility Labels & Actions
Describe controls for assistive technologies with labels, values, hints, and actions.
Add accessible labels, values, and hints
Annotate text and buttons with .accessibilityLabel, .accessibilityValue, and .accessibilityHint so assistive tech conveys meaning.
Example
clike
import SwiftUI
struct A11yLabelsDemo: View {
@State private var count = 0
var body: some View {
VStack(spacing: 12) {
Text("Count: \(count)")
.accessibilityLabel("Current count")
.accessibilityValue("\(count)")
Button("Increment") { count += 1 }
.accessibilityHint("Increases the count by one")
}
}
}
clike
import SwiftUI
struct ContentView: View {
var body: some View { A11yLabelsDemo() }
}
clike
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup { ContentView() }
}
}
The example above shows a label, value, and hint for a control.