Understand the accessibility model in React Rating
mainReact Rating uses the aria radiogroup role to provide a consistent experience for both mouse and keyboard users.
Keyboard Interaction
- Selection: Ratings must be confirmed using the
EnterorSpacekeys. Unlike native HTML radio buttons, they cannot be set directly using arrow keys. - Callbacks:
onChangeis triggered by bothEnter/Spaceand mouse clicks.onHoverChangeis triggered by arrow key navigation (← → ↑ ↓), mouse hovering, or when focus moves from/to an element outside the rating component.
Screen Reader Support
- Disabled State: When the component is disabled, the state is announced by screen readers rather than being hidden.
- Labels: The component generates default accessible labels based on the
itemsvalue. These can be customized or switched to visible labels via props (refer to the demo website for implementation details).