Rating

Components > Displaying Data > Rating
Use this component to...
Display a rating value using stars

Overview

Use the rating component to visually illustrate a numeric value that represents how people have rated something. Star ratings have been used for everything from restaurants to movies, and can be used by your application too.

The rating component allows you to specify the total number of stars and the rating value. The value can be between 0 and the total number of stars. The component displays ratings in multiples of 0.5, picking the number of full or half stars that is closest to but not greater than the specified value. So a rating value of 3.6 would display as 3-and-a-half stars.

Rating examples
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0

Development

Web component development

Component reference

rui-rating
rui-rating
Module: rui-rating - Package: @jha/rui-wc

Displays a rating value with stars.

Name Type Default Description
rating number 0 A value between 0 and starCount specifying the rating to display. The component displays values in multiples of 0.5, picking the number of full or half stars that is closest to but not greater than the specified value. So a rating value of 3.6 would display as 3-and-a-half stars.
starCount number 5 A number between 1 and 10 specifying the total number of stars to display.
size string 'small'

Specifies the size of the rating stars:

One of “small”, “medium”, and “large”:

  • “small” = 16x16 pixels
  • “medium” = 20x20 pixels
  • “large” = 24x24 pixels

If isEditable is set to true, the rating size will be forced to Large.

isEditable boolean false By binding isEditable to true, the rating stars become clickable buttons allowing the user to select a rating. When in edit mode, the rating star size is always large. While in non-edit mode, the rating component can display 1/2 stars, but in edit mode, only full star selections are possible.
allowClear boolean false Bind allowClear to true to allow to user to clear their selection. A clear icon button will display at the end of the rating block and clicking it will reset the rating to 0. The clear button will be hidden if isDisabled is set to true.
isDisabled boolean false Binding isDisabled to true will disable the icon buttons and display a disabled appearance. This requires isEditable to be set to true also. If isDisabled is set to true, the clear icon button will be hidden even if allowClear is set to true.

Implementation

Begin by importing the rui-rating module into your application.

Import the module
// import into app.module
import '@jha/rui-wc/components/rui-rating/rui-rating-imports';

Use the rui-rating component to display a rating.

Rating HTML
<rui-rating [rating]="product.rating"></rui-rating>

Set the isEditable property to true to allow users to select a rating. You can also bind allowClear to true to allow users to clear the current selection.

Editable Rating
<rui-rating [rating]="product.rating" [isEditable]="true" [allowClear]="true"></rui-rating>

Angular component development

Component reference

rui-rating
jha-rating
Module: JhaRatingModule - Package: @jha/jharesponsive

Displays a rating value with stars.

Name Type Default Description
jhaRating number 0 A value between 0 and jhaStarCount specifying the rating to display. The component displays values in multiples of 0.5, picking the number of full or half stars that is closest to but not greater than the specified value. So a rating value of 3.6 would display as 3-and-a-half stars.
jhaStarCount number 5 A number between 1 and 10 specifying the total number of stars to display.
jhaSize string 'Small'

Specifies the size of the rating stars:

One of “Small”, “Medium”, and “Large”:

  • “Small” = 16x16 pixels
  • “Medium” = 20x20 pixels
  • “Large” = 24x24 pixels

If jhaIsEditable is set to true, the rating size will be forced to Large.

jhaIsEditable boolean false By binding jhaIsEditable to true, the rating stars become clickable buttons allowing the user to select a rating. When in edit mode, the rating star size is always large. While in non-edit mode, the rating component can display 1/2 stars, but in edit mode, only full star selections are possible.
jhaAllowClear boolean false Bind jhaAllowClear to true to allow to user to clear their selection. A clear icon button will display at the end of the rating block and clicking it will reset the jhaRating to 0. The clear button will be hidden if jhaIsDisabled is set to true.
jhaIsDisabled boolean false Binding jhaIsDisabled to true will disable the icon buttons and display a disabled appearance. This requires jhaIsEditable to be set to true also. If jhaIsDisabled is set to true, the clear icon button will be hidden even if jhaAllowClear is set to true.

Implementation

Begin by importing the JhaRatingModule module into your application.

Import the module
// import into app.module
import { JhaRatingModule } from '@jha/jharesponsive/jha-rating';

@NgModule({
    imports: [
        ...
        JhaRatingModule,
        ...
    ]
})

export class AppModule(){}

Use the jha-rating component to display a rating.

Rating HTML
<jha-rating [jhaRating]="product.rating"></jha-rating>

Set the jhaIsEditable property to true to allow users to select a rating. You can also bind jhaAllowClear to true to allow users to clear the current selection.

Editable Rating
<jha-rating [jhaRating]="product.rating" [jhaIsEditable]="true" [jhaAllowClear]="true"></jha-rating>

Component playground


Design

Figma design

Figma design info
You can find this component in the Components - Rating page in the Figma UI Kit.
Dev Component Design Component Name
Rating

RUI / Rating

Available values for the Size property:

  • Small
  • Medium
  • Large

Available values for the Rating property:

  • Full
  • Half
  • Empty

Add empty, half, and full rating components to display the appropriate number of stars in the rating.

Separate the stars in the rating by 2 pixels horizontally. Vertically center the stars in the rating.

Rating timeline design
Rating timeline design

Adobe XD design

Adobe XD design info
You can find this component in these artboards in the Adobe XD design samples:
  • Sample App - Rating
Dev Component Design Component Name
Rating - regular, full JHA / Rating / Regular / Full
Rating - regular, half JHA / Rating / Regular / Half
Rating - regular, empty JHA / Rating / Regular / Empty

Add empty, half, and full rating components to display the appropriate number of stars in the rating.

Separate the stars in the rating by 2 pixels horizontally. Vertically center the stars in the rating.

Rating timeline design
Rating timeline design

The Adobe XD UI kit includes support for “bright” rating values, which display the stars using the “bright” color.

The development components no longer support this styling, so you should only use the “Rating - regular” design components.


Support options
Have questions on this topic?
Join the Responsive UI team in Microsoft Teams to connect with the community.
See something in this page that needs to change?
Send us feedback on this page.
Last updated Wed Mar 29 2023