Skip to main content

Rating

Rating component allows users to submit feedback and view average scores on a defined scale, reflecting your product, service or experience.

Also known as: Review, Star rating, Feedback
Salt package@salt-ds/core
Available since1.61.0

By default, the Rating displays five stars, from which users can select a rating.

Use the read-only state when you need to communicate a single user’s or an aggregate rating, and prevent it from being edited. A rating in a read-only state will be submitted with the corresponding form.

Note: If you must use a read-only rating, you should always add an accessible name that makes it obvious the switch is read-only, be that via a visual label or an aria-label if there's no space for a visual label.

Use the disabled state for the Rating component when context or user permissions require it. Showing the component in a disabled state indicates its presence and functionality, even though it’s not available.

A visual label can be added to the Rating component as an optional feature, appearing by default on the right. Applications can define the label of each icon. The label may be a number, text, or a combination (for example, '4/5', '4/5 very good', or 'Very good').

If using a label positioned to the left, set a fixed width to avoid the component jumping when moving between selections.

Rating component is compatible with FormField. However, the component doesn’t include Form Field out-the-box.

The recommended number of rating icons is 5 (e.g., 1–5 stars). However, you can increase or decrease the number of icons. The 5 point scale strikes a balance between giving users enough options to express their feelings and not overwhelming them with too many choices.

It’s recommended to not exceed 10 rating icons for highly detailed feedback as it can be overwhelming, and is unnecessary for most scenarios.

The default star icon can be replaced with other Salt DS icons depending on your use case. Achieve custom icons in code using the semantic icon provider.

If clearing Rating selection is necessary, you can achieve this combining Rating with a Button. Activating the button should reset the rating component, clearing any previously submitted score.

  • A live region or an announcement should be used to provide feedback to screen reader users.
  • The clear button should remain visible and enabled as long as the rating is editable, allowing users to change their input.
  • If the Rating component is set to read-only, the clear button should be hidden, since users cannot modify or clear the rating in this state. This approach ensures clarity and prevents confusion, as users only see actionable controls when interaction is possible.