Skip to content

Ratings

The ratings component allows users to provide or display a rating using a row of stars. It is commonly used for evaluating products, services, or content.

The component supports both interactive ratings, where users can select a value, and read-only ratings, where the rating is only displayed.

Examples

Basic Ratings

The first example demonstrates a basic interactive ratings component with the default configuration. The stars are interactive, allowing users to choose a rating directly within the component.


Readonly Ratings

The second example demonstrates a read-only ratings component. The rating is displayed but cannot be changed by the user. This is useful for showing previously submitted ratings or aggregated scores. Custom colors are also applied to highlight the selected stars.


Custom Size & Length

This example demonstrates customization of the ratings component, including adjusting the number of rating items, modifying the star size, and setting an initial rating value. The clearable option is disabled, so clicking the currently selected rating will not reset the value, unlike the previous examples.


Props

PropertyTypeDefaultDescription
visiblebooleantrueDetermines whether the ratings component is visible in the scene.
positionnumber[]0 0 0Defines the 3D position of the ratings component in the format [x, y, z].
opacitynumber1Controls the transparency of the ratings component (0 = fully transparent, 1 = fully visible).
colorstring1Defines the color of inactive (unselected) stars.
activecolorstring1Defines the color of active (selected) stars.
sizeenum (small, medium, large)mediumSpecifies the size of the rating stars.
lengthnumber5Specifies the total number of stars displayed in the ratings component.
valuenumber3Specifies the currently selected rating value.
readonlybooleanfalseIf enabled, the rating cannot be changed by the user and is displayed for informational purposes only.
clearablebooleanfalseAllows the user to clear the selected rating by clicking the currently selected value again.

Events

The ratings component emits the following event when interacted with:

EventParametersDescription
rating-changed{ value: number }Emitted whenever the selected rating changes. Returns the newly selected rating value.

Note

You can listen to the rating-changed event to react whenever the selected rating value changes.
The event provides the updated rating value through the event.detail object, allowing you to handle the result in your application logic (for example, saving the rating or updating the UI).

js
el.addEventListener("rating-changed", (event) => {
  console.log(event.detail.value);
});