Skip to Content
DocumentationRating

Rating

A star-based rating component that allows users to provide feedback or display ratings.

Examples

Basic

Selected: 0 stars

Half Stars

With Labels

PoorExcellent
UnsatisfiedSatisfied
BadGreat

Read Only

Custom Max Stars

API

Rating

The Rating component supports both controlled and uncontrolled modes:

  • Controlled: Pass value and onChange to manage the state externally.
  • Uncontrolled: Omit value and the component manages its own internal state. You can still use onChange to be notified of changes.
PropertyTypeDefaultDescription
valuenumber-Current rating value (0 to maxStars, supports 0.5 increments for half stars). When provided, the component is controlled.
onChange(value: number) => void-Callback function called when the user clicks on a star. Works in both controlled and uncontrolled modes.
maxStarsnumber5The maximum number of stars to display.
readOnlybooleanfalseWhen true, prevents the user from interacting with the rating.
labels[string, string]-Labels to display below the stars. First label appears on the left, second on the right.
size”sm” | “md” | “lg""md”The size of the rating stars.
classNamestring-Additional CSS class names to apply to the root element.
classNameContainerstring-Additional CSS class names to apply to the stars container.
classNameLabelsstring-Additional CSS class names to apply to the labels container.

Star States

StateDescription
emptyStar with transparent background and gray-stroke-emphasis border.
halfStar half filled with feedback-warning-background-soft color.
fullStar fully filled with feedback-warning-background-soft color.
Last updated on