interactable-role
Mobile validation
A role tells people and assistive technologies what an element is and how it behaves. When a screen reader announces “button”, users expect an action. When it announces “checkbox” or “switch”, users expect a toggle between checked and unchecked, or on and off. Most native components provide the appropriate role by default. If you extend a component, keep the added behavior consistent with its role. If you make a non-interactive element, such as a text view or an image, respond to taps, explicitly set its role with the platform accessibility API.
Pass Patterns
Android
The clickable TextView uses an accessibility delegate to expose itself as a button.
<TextView
android:id="@+id/payText"
android:layout_width="..."
android:layout_height="..."
android:text="Pay now" />payText.setOnClickListener { pay() }
ViewCompat.setAccessibilityDelegate(payText, object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(
host: View,
info: AccessibilityNodeInfoCompat
) {
super.onInitializeAccessibilityNodeInfo(host, info)
info.className = Button::class.java.name
}
})The clickable Text sets its role with semantics. See the full list of Jetpack Compose roles.
Text(
text = "Pay now",
modifier = Modifier
.semantics { role = Role.Button }
.clickable { pay() },
)Cross Platform
The native ElevatedButton exposes the button role by default.
ElevatedButton(
onPressed: pay,
child: const Text('Pay now'),
),The Pressable sets its role with accessibilityRole.
<Pressable accessibilityRole="button" onPress={pay}>
<Text>Pay now</Text>
</Pressable>Fail Patterns
Android
The TextView responds to taps, but it has no role.
<TextView
android:id="@+id/payText"
android:layout_width="..."
android:layout_height="..."
android:text="Pay now" />payText.setOnClickListener { pay() }The Text is clickable, but it has no role.
Text(
text = "Pay now",
modifier = Modifier
.clickable { pay() },
)Cross Platform
React Native (Android)
The GestureDetector makes the text tappable, but it has no button role.
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: pay,
child: const Padding(
padding: EdgeInsets.all(12),
child: Text('Pay now'),
),
),Try It Yourself
Using a screen reader
New to screen reader testing, or need a refresher?
Review this article first: Practical guides for using screen readers
- Turn on VoiceOver on iOS, or TalkBack on Android.
- Swipe right or left to move to the interactive element.
- Listen for the element's role after its name.
Expected results: The screen reader announces a role that matches the element's behavior, for example “Pay now, button”.
Actual results: The screen reader announces only the element's text, such as “Pay now”, with no role. TalkBack may add “double tap to activate”, which shows the element is actionable but not what it is.
Tip: To hear the role more easily, set the screen reader to announce it before the name. On Android, open TalkBack settings > Advanced settings > Element description order and choose "Type, name, state". On iOS, open Settings > Accessibility > VoiceOver > Verbosity > Controls and choose "Speak Before".
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 Traits.
Expected results: The Traits include a role that matches the element's behavior, such as Button.
Actual results: The Traits show Static Text, or no role at all.
FAQ
How does this issue relate to 1.3.1 Info and relationships?
WCAG 1.3.1 requires that information, structure, and relationships are programmatically determinable or available in text. The role on an interactive element provides that programmatic information so assistive technology can identify what the control is and how it is meant to behave.
If an element lacks a correct role, its function and its relationship to surrounding content may not be exposed. As a result, the structure of the interface is not reliably available to assistive technology.
- A
rolecommunicates the control type, such asbutton,link, orswitch - Correct roles expose relationships within a pattern, such as a
tabinside atablistor amenuiteminside amenu - Missing or incorrect roles hide or misrepresent those relationships, so information cannot be determined programmatically
Providing accurate roles helps satisfy 1.3.1 for interactive elements by ensuring the UI’s structure and relationships are conveyed to assistive technology
How does this issue relate to 4.1.2 Name, role, value?
SC 4.1.2 requires the role of every user interface component to be programmatically determinable. Without a correct role, assistive technologies cannot identify the control or tell users how to interact with it.
Why is this issue marked as Serious?
Without a role, screen reader users may not realize an element is interactive, or may misunderstand what it does. On mobile, screen readers can usually still activate the element with a double tap, so users can operate it once they find it, but they have to guess its purpose. This makes key tasks slower and error-prone, so it is rated serious.
Standards and Regulations
| Standard | Success Criterion | Reference |
|---|---|---|
| WCAG 2.2 | 1.3.1 Info and Relationships (A) | Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. |
| WCAG 2.2 | 4.1.2 Name, Role, Value (A) | For all user interface components, the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to assistive technologies. |
| EN 301 549 | 11.4.1.2 Name, Role, Value | Same as the WCAG text. |
| EN 301 549 | 11.1.3.1 Info and Relationships | Same as the WCAG text. |
| Section 508 | 1194.21(d) | Sufficient information about a user interface element including the identity, operation and state of the element shall be available to assistive technology. When an image represents a program element, the information conveyed by the image must also be available in text. |