Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.62 KB

role-supports-aria-props.md

File metadata and controls

39 lines (29 loc) · 1.62 KB

jsx-a11y/role-supports-aria-props

💼 This rule is enabled in the following configs: ☑️ recommended, 🔒 strict.

Enforce that elements with explicit or implicit roles defined contain only aria-* properties supported by that role. Many ARIA attributes (states and properties) can only be used on elements with particular roles. Some elements have implicit roles, such as <a href="#" />, which will resolve to role="link".

Rule details

This rule takes no arguments.

Succeed

<!-- Good: the radiogroup role does support the aria-required property -->
<ul role="radiogroup" aria-required aria-labelledby="foo">
    <li tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
    <li tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
    <li tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul>

Fail

<!-- Bad: the radio role does not support the aria-required property -->
<ul role="radiogroup" aria-labelledby="foo">
    <li aria-required tabIndex="-1" role="radio" aria-checked="false">Rainbow Trout</li>
    <li aria-required tabIndex="-1" role="radio" aria-checked="false">Brook Trout</li>
    <li aria-required tabIndex="0" role="radio" aria-checked="true">Lake Trout</li>
</ul>

Accessibility guidelines

Resources