Rating
A star-based rating component that allows users to provide feedback or display ratings.
Examples
Basic
Preview
Selected: 0 stars
Half Stars
Preview
With Labels
Preview
PoorExcellent
UnsatisfiedSatisfied
BadGreat
Read Only
Preview
Custom Max Stars
Preview
API
Rating
The Rating component supports both controlled and uncontrolled modes:
- Controlled: Pass
valueandonChangeto manage the state externally. - Uncontrolled: Omit
valueand the component manages its own internal state. You can still useonChangeto be notified of changes.
| Property | Type | Default | Description |
|---|---|---|---|
| value | number | - | 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. |
| maxStars | number | 5 | The maximum number of stars to display. |
| readOnly | boolean | false | When 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. |
| className | string | - | Additional CSS class names to apply to the root element. |
| classNameContainer | string | - | Additional CSS class names to apply to the stars container. |
| classNameLabels | string | - | Additional CSS class names to apply to the labels container. |
Star States
| State | Description |
|---|---|
| empty | Star with transparent background and gray-stroke-emphasis border. |
| half | Star half filled with feedback-warning-background-soft color. |
| full | Star fully filled with feedback-warning-background-soft color. |
Last updated on