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 buttonCheckbox
: this element is checkbox with two states (checked / unchecked)DropdownList
: this element is drop down menuImage
: this element is an imageRadioButton
: this element is a radio buttonSwitch
: this element is a switchTab
: this element is a tab which represents a single page of content using a text label and/or iconValuePicker
: 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
})