Rating
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.
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
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”:
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.
Use the rui-rating
component to display a 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.
Angular wrapper development
Wrapper reference
rui-rating
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”:
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.
Use the jha-rating
component to display a 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.
Component playground
Design
Figma design
Dev Component | Design Component Name |
---|---|
Rating | RUI / Rating Available values for the Size property:
Available values for the Rating property:
|
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
- 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.
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.