# Interactable Role (Mobile)

> In mobile apps, interactive elements must expose a programmatically determinable role that assistive technologies can announce.

Source: https://knowledge.evinced.com/mobile/mobile-validations/interactable-role

Interactive elements must expose a programmatically determinable role that assistive technologies can announce.

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

**XML Views**

The clickable `TextView` uses an accessibility delegate to expose itself as a button.

```xml
<TextView
    android:id="@+id/payText"
    android:layout_width="..."
    android:layout_height="..."
    android:text="Pay now" />
```

```kotlin
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
    }
})
```

**Jetpack Compose**

The clickable `Text` sets its role with `semantics`. See the [full list of Jetpack Compose roles](https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/Role).

```kotlin
Text(
    text = "Pay now",
    modifier = Modifier
        .semantics { role = Role.Button }
        .clickable { pay() },
)
```

### Cross Platform

**Flutter (Android)**

The native `ElevatedButton` exposes the button role by default.

```dart
ElevatedButton(
  onPressed: pay,
  child: const Text('Pay now'),
),
```

**React Native (Android)**

The `Pressable` sets its role with `accessibilityRole`.

```tsx
<Pressable accessibilityRole="button" onPress={pay}>
  <Text>Pay now</Text>
</Pressable>
```

## Fail Patterns

### Android

**XML Views**

The `TextView` responds to taps, but it has no role.

```xml
<TextView
    android:id="@+id/payText"
    android:layout_width="..."
    android:layout_height="..."
    android:text="Pay now" />
```

```kotlin
payText.setOnClickListener { pay() }
```

**Jetpack Compose**

The `Text` is clickable, but it has no role.

```kotlin
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.

```dart
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](https://knowledge.evinced.com/a11y-essentials/practical-guides-for-using-screen-readers)

1.  Turn on VoiceOver on iOS, or TalkBack on Android.
2.  Swipe right or left to move to the interactive element.
3.  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

1.  **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 `role` communicates the control type, such as `button`, `link`, or `switch`
-   Correct roles expose relationships within a pattern, such as a `tab` inside a `tablist` or a `menuitem` inside a `menu`
-   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](https://www.w3.org/TR/WCAG22/#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](https://www.w3.org/TR/WCAG22/#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](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |
| EN 301 549 | [11.1.3.1 Info and Relationships](https://www.etsi.org/standards/etsi-301-549) | Same as the WCAG text. |
| Section 508 | [1194.21(d)](https://www.federalregister.gov/documents/2018/01/18/2018-00712/section-508-standards-update#d21) | 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. |

## Personas impacted by this issue

-   [Screen Reader](https://knowledge.evinced.com/a11y-essentials/personas#screen-reader)

## Related Issues

-   [accessible-name](https://knowledge.evinced.com/mobile/mobile-validations/accessible-name)
-   [conflicting-state-in-name](https://knowledge.evinced.com/mobile/mobile-validations/conflicting-state-in-name)
-   [conflicting-traits](https://knowledge.evinced.com/mobile/mobile-validations/conflicting-traits)
-   [conflicting-type-in-label](https://knowledge.evinced.com/mobile/mobile-validations/conflicting-type-in-label)
-   [ignored-by-assistive-technology](https://knowledge.evinced.com/mobile/mobile-validations/ignored-by-assistive-technology)
-   [invalid-range-values](https://knowledge.evinced.com/mobile/mobile-validations/invalid-range-values)
-   [non-interactive-in-focus-sequence](https://knowledge.evinced.com/mobile/mobile-validations/non-interactive-in-focus-sequence)
