Ratings provide insight regarding others' opinions and experiences, and can allow the user to submit a rating of their own.
{{ādemoā: āBasicRating.jsā}}
The rating can display any float number with the value
prop.
Use the precision
prop to define the minimum increment value change allowed.
{{ādemoā: āHalfRating.jsā}}
You can display a label on hover to help the user pick the correct rating value.
The demo uses the onChangeActive
prop.
{{ādemoā: āHoverRating.jsā}}
For larger or smaller ratings use the size
prop.
{{ādemoā: āRatingSize.jsā}}
Here are some examples of customizing the component. You can learn more about this in the overrides documentation page.
{{ādemoā: āCustomizedRating.jsā}}
The rating is implemented with a radio group, set highlightSelectedOnly
to restore the natural behavior.
{{ādemoā: āRadioGroupRating.jsā}}
The accessibility of this component relies on:
name
prop that is unique to the parent form.getLabelText
prop when the page is in a language other than English. You can use the included locales, or provide your own.{{ādemoā: āTextRating.jsā}}
The read only rating has a role of āimgā, and an aria-label that describes the displayed rating.
Because the rating component uses radio buttons, keyboard interaction follows the native browser behavior. Tab will focus the current rating, and cursor keys control the selected rating.
The read only rating is not focusable.