Skip to main content
.accessibilityLabel(label: string): Component;

Parameters

label
string
A string that identifies the accessibility element. This is the primary way screen readers announce the element.

Support

Usage

Button with clear label

Button("→", () => {})
    .accessibilityLabel("Next page")

Icon with descriptive label

Image("star-icon.png")
    .accessibilityLabel("Favorite item")
    .onTapGesture(() => {
        toggleFavorite()
    })

Complex view with simple label

HStack([
    Image("profile.jpg"),
    VStack([
        Text("John Doe"),
        Text("Software Engineer")
    ])
]).accessibilityLabel("John Doe, Software Engineer")

Form field with context

const [email, setEmail] = useState("")

TextField({ placeholder: "", text: email, setText: setEmail })
    .accessibilityLabel("Email address")

Custom control with meaningful label

Rectangle()
    .fill(isEnabled ? Color("green") : Color("gray"))
    .accessibilityLabel(isEnabled ? "Feature enabled" : "Feature disabled")
    .onTapGesture(() => {
        toggleFeature()
    })