Accessibility role - Jetpack Compose

In Jetpack Compose you can use role to set the role of an element.

The following constants are defined for the Role:

  • Button: this element is a button
  • Checkbox: this element is checkbox with two states (checked / unchecked)
  • DropdownList: this element is drop down menu
  • Image: this element is an image
  • RadioButton: this element is a radio button
  • Switch: this element is a switch
  • Tab: this element is a tab which represents a single page of content using a text label and/or icon
  • ValuePicker: this element is a value picker and should support accessibility scroll events

For more information about the mapping, view the Role class, Role.toLegacyClassName() method and populateAccessibilityNodeInfoProperties() method in the Compose source code.

Box(modifier = Modifier.semantics {
    role = Role.Button
})