Rating

The Rating component displays a visual rating scale, allowing users to select or view a rating value. It supports both interactive and read-only modes.

Usage

Default


<Rating 
  value={3}
  onChange={(val) => console.log(val)} 
/>

Props

Data table
TypeDescription
aria-describedbystringReferences the id of an element that describes the rating group.
aria-labelstringAccessible label for the rating group. Prefer `label` when a visible label is needed.
aria-labelledbystringReferences the id of an element that labels the rating group.
classNamestringOptional additional CSS class names for custom styling.
data-testidstringOptional test ID for testing frameworks.
idstringOptional unique id for the rating group.
interactivebooleanIf true, the user can interact with the rating (hover, click, keyboard navigation).
labelstringVisible label for the rating component.
maxnumberThe maximum number of stars available for the rating.
onChange((rating: number) => void)Callback function invoked when the rating changes. Receives the new rating (1-indexed) as its argument.
readOnlybooleanIf true, the rating is read-only and cannot be changed.
requiredbooleanIf true, marks the field as required.
sizeSizeTypeThe size of the rating component. One of: "xs" | "small" | "medium" | "large" | "xl"
starAriaLabelPrefixstringOptional aria-label prefix for each star. Example: "Rating star" -> "Rating star 1 of 5"
stateStateTypeState of the rating. One of: "success" | "error" | "warning" | "disabled" | ""
themeThemeTypeThe theme to use for styling. One of: "primary" | "secondary" | "tertiary" | "quaternary" | "clear"
valuenumberThe current rating value.