SwiftUI Accessibility Labels & Actions

Add accessible labels, values, and hints

Annotate text and buttons with .accessibilityLabel.accessibilityValue, and .accessibilityHint so assistive tech conveys meaning.

Example

Demo.swift

ContentView.swift

App.swift

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")
}
} }

The example above shows a label, value, and hint for a control.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *