Has Valid Accessibility Role
Rule requiring React Native components to use a valid accessibilityRole prop
Rule ID: has-valid-accessibility-role
accessibilityRole communicates the purpose of a component to the user of assistive technology.
accessibilityRole can be one of the following:
adjustableUsed when an element can be "adjusted" (e.g. a slider).alertUsed when an element contains important text to be presented to the user.buttonUsed when the element should be treated as a button.checkboxUsed when an element represents a checkbox that can be checked, unchecked, or have a mixed checked state.comboboxUsed when an element represents a combo box, which allows the user to select among several choices.headerUsed when an element acts as a header for a content section (e.g. the title of a navigation bar).imageUsed when the element should be treated as an image. Can be combined with a button or link.imagebuttonUsed when the element should be treated as a button and is also an image.keyboardkeyUsed when the element acts as a keyboard key.linkUsed when the element should be treated as a link.menuUsed when the component is a menu of choices.menubarUsed when a component is a container of multiple menus.menuitemUsed to represent an item within a menu.noneUsed when the element has no role.progressbarUsed to represent a component that indicates the progress of a task.radioUsed to represent a radio button.radiogroupUsed to represent a group of radio buttons.scrollbarUsed to represent a scroll bar.searchUsed when a text field element should also be treated as a search field.spinbuttonUsed to represent a button which opens a list of choices.summaryUsed when an element can be used to provide a quick summary of current conditions in the app when the - app first launches.switchUsed to represent a switch which can be turned on and off.tabUsed to represent a tab.tablistUsed to represent a list of tabs.textUsed when the element should be treated as static text that cannot change.timerUsed to represent a timer.togglebuttonUsed to represent a toggle button. Should be used with accessibilityState checked to indicate if the button is toggled on or off.toolbarUsed to represent a toolbar (a container of action buttons or components).gridUsed with ScrollView, VirtualizedList, FlatList, or SectionList to represent a grid. Adds the in/out of grid announcements to Android's GridView.
Why It Matters
Elements assigned invalid role values are not interpreted by assistive technology as intended by the developer.
When screen readers and other assistive technologies do not know the role of each element, they are not able to interact with it intelligently, nor are they able to communicate the role to the user. An element's features, properties, and methods of conveying information to and/or from the user can't be communicated via assistive technologies when a role value is invalid.
How to Fix the Problem
Ensure the accessibilityRole value is a valid role.
Passing Examples
<TouchableOpacity accessibilityRole="button">
<Text>Increase Count</Text>
</TouchableOpacity>Failing Examples
<TouchableOpacity accessibilityRole="secondary-button">
<Text>Increase Count</Text>
</TouchableOpacity>