Developer Programs

Learn

Docs

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: @jkhy/responsive-ui-wc

Displays a rating value with stars.

NameTypeDefaultDescription
ratingnumber0A 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.
starCountnumber5A number between 1 and 10 specifying the total number of stars to display.
sizestring'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.

isEditablebooleanfalseBy 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.
allowClearbooleanfalseBind 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.
isDisabledbooleanfalseBinding 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 '@jkhy/responsive-ui-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 wrapper development

Wrapper reference

rui-rating
jha-rating
Module: JhaRatingModule - Package: @jkhy/responsive-ui-angular

Displays a rating value with stars.

NameTypeDefaultDescription
jhaRatingnumber0A 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.
jhaStarCountnumber5A number between 1 and 10 specifying the total number of stars to display.
jhaSizestring'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.

jhaIsEditablebooleanfalseBy 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.
jhaAllowClearbooleanfalseBind 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.
jhaIsDisabledbooleanfalseBinding 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 '@jkhy/responsive-ui-angular/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 ComponentDesign 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.


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 ComponentDesign Component Name
Rating - regular, fullJHA / Rating / Regular / Full
Rating - regular, halfJHA / Rating / Regular / Half
Rating - regular, emptyJHA / 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.

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 Sep 25 2024