accessible-name-starts-with-label
Mobile validation
Many elements have both a visible label and an accessible name, the programmatic name that assistive technologies use. Voice control users activate elements by speaking what they see on screen, and voice control software works best when the spoken words match the start of the accessible name. Make sure the accessible name contains the visible label and, whenever possible, begins with it. The simplest way is to not override the name at all, so it comes from the visible label.
Note: This validation covers names that contain the visible label but don't start with it. When the accessible name does not contain the visible label at all, see the related label-in-name validation.
Pass Patterns
Android
XML Views
The button has no contentDescription, so its accessible name is its visible text, "Order".
<Button
android:layout_width="..."
android:layout_height="..."
android:layout_gravity="center"
android:text="Order" />iOS
The accessibilityLabel "Order items" starts with the visible title, "Order".
let orderButton = UIButton(type: .system)
orderButton.setTitle("Order", for: .normal)
orderButton.accessibilityLabel = "Order items"The button has no accessibilityLabel, so its accessible name is its visible title, "Order".
Button("Order") {
placeOrder()
}Cross Platform
The semanticsLabel "Order items" starts with the visible text, "Order".
ElevatedButton(
onPressed: placeOrder,
child: const Text('Order', semanticsLabel: 'Order items'),
),The accessibilityLabel "Order items" starts with the visible text, "Order".
<Pressable
accessibilityRole="button"
accessibilityLabel="Order items"
onPress={...}
>
<Text>Order</Text>
</Pressable>Fail Patterns
Android
XML Views
The contentDescription "Place order" contains the visible text, "Order", but doesn't start with it.
<Button
android:layout_width="..."
android:layout_height="..."
android:text="Place order"
android:contentDescription="Order" />iOS
The accessibilityLabel "Place order" contains the visible title, "Order", but doesn't start with it.
let orderButton = UIButton(type: .system)
orderButton.setTitle("Order", for: .normal)
orderButton.accessibilityLabel = "Place order"The accessibilityLabel "Place order" contains the visible title, "Order", but doesn't start with it.
Button("Order") {
placeOrder()
}
.accessibilityLabel("Place order")Cross Platform
The semanticsLabel "Place order" contains the visible text, "Order", but doesn't start with it.
ElevatedButton(
onPressed: placeOrder,
child: const Text('Order', semanticsLabel: 'Place order'),
),The accessibilityLabel "Place order" contains the visible text, "Order", but doesn't start with it.
<Pressable
accessibilityRole="button"
accessibilityLabel="Place order"
onPress={...}
>
<Text>Order</Text>
</Pressable>Try It Yourself
Using voice input
New to voice input testing, or need a refresher?
Review this article first: Practical guides for using voice input
- Turn on Voice Control on iOS, or Voice Access on Android. On Android, make sure Voice Access is listening, from the notifications panel.
- Say “Show names” on iOS, or “Show labels” on Android.
- Compare the name shown for each element with its visible label.
Expected results: The name shown for each element starts with the element's visible label.
Actual results: The name shown contains the visible label later in the text, for example “Place order” for a button labeled “Order”.
Using developer tools
- iOS: In Xcode, open Xcode > Open Developer Tool > Accessibility Inspector, select the simulator or device, and point at the element. Check its Label.
- Android: In Android Studio, open the Layout Inspector and select the element. Check its
contentDescriptionfor Views, or its semantics for Jetpack Compose.
Expected results: The accessible name is empty, so the visible label is used, or it starts with the visible label.
Actual results: The accessible name starts with other words, and the visible label appears only later.
FAQ
Why is this issue marked as Best Practice?
The visible label is still part of the accessible name, so voice control users can usually still activate the element. However, the mismatch at the start of the name can make voice commands less reliable, and users may need to try other commands, so it is rated best practice.