Skip to content

Rating

Ratings provide insight regarding others’ opinions and experiences with a product. Users can also rate products they’ve purchased.

Simple ratings

Controlled
Read only
Disabled
Pristine

Customized ratings

Here are some examples of customizing the component. You can learn more about this in the overrides documentation page.

Custom empty icon
Custom icon and color
10 stars
Custom icon set

Hover feedback

You can display a label on hover to help users pick the correct rating value. The first demo uses the onChangeActive prop while the last one uses the IconContainerComponent prop.

Side
Poor+
Tooltip

Half ratings

The rating can display any float number with the value prop. Use the precision prop to define the minimum increment value change allowed.

<Rating name="half-rating" value={2.5} precision={0.5} />

Sizes

Fancy larger or smaller ratings? Use the size prop.

<Box display="flex" flexDirection="column">
  <Rating name="size-small" value={2} size="small" />
  <Rating name="size-medium" value={2} />
  <Rating name="size-large" value={2} size="large" />
</Box>

Accessibility

(WAI tutorial: https://www.w3.org/WAI/tutorials/forms/custom-controls/#a-star-rating)

The accessibility of this component relies on:

  • A radio group is used with its fields visually hidden. It contains six radio buttons, one for each star and another for 0 stars, which is checked by default. Make sure you are providing a name prop that is unique to the parent form.
  • The labels for the radio buttons contain actual text (“1 Star”, “2 Stars”, …), make sure you provide a getLabelText prop when the page language is not English.