Label at Front

Link to Label at Front copied to clipboard

WCAG 2.1 - 2.5.3 Best Practice Impact - Minor

Any active control with text should have a name that begins with that text, including the text children of the control.

Impact

VoiceOver users expect the accessible name announced first when interacting with a control. As a best practice, we recommend having a controls visible text within the name and all other information within the accessible value, hint, or role.

Confirmation

  1. Turn on VoiceOver
  2. Focus the element
  3. One of the following will happen:
    • Inaccessible: VoiceOver will announce other text before announcing the active control's text
    • Accessible: VoiceOver will announce the active control's text first

How to Fix

An issue found by this rule is caused by the visible text missing from the start of the control's accessibility label.

UIKit

In storyboard:

  1. Select the element with a LabelAtFront issue
  2. Ensure that the Inspectors Panel is visible
  3. Select the Identity Inspector.
  4. Under Accessibility, there is a category called "Label". Enter a label that either exactly matches or begins with the visible text.

In code:

Find where the accessibility label has been set, and verify that the accessibilityLabel's value either matches or begins with all the visible text of the component.

button.title = "Login"
button.accessibilityLabel = "Login to Your Account"

SwiftUI

Ensure to set an accessibility label that either matches or begins with all the visible text of the component.

Button(action: {
    openMenu()
}) {
    Text("Menu")
}