Rating (1.4.0 - 1.5.0)
The Alexa rating responsive component (AlexaRating
) displays a non-interactive graphic to communicate a rating for an item. You can use a default star image or provide your own custom assets for the graphic.
Import the alexa-layouts package
To use AlexaRating
, import the alexa-layouts package.
The latest version of the alexa-layouts
package is 1.7.0. AlexaRating
was introduced in version 1.1.0.
AlexaRating parameters
All parameters except type
are optional.
Name | Type | Default | Description | Version added/updated |
---|---|---|---|---|
|
String |
" |
A string describing the rating. Voice over reads this string when the user selects the item. |
1.4.0 |
|
Any |
|
The graphic to display to represent an 'empty' rating slot (such as an empty star). Used when |
1.1.0 |
|
Array |
— |
Array of entity data to bind to this template. |
1.2.0 |
|
Any |
|
The graphic to display to represent a 'full' rating slot (such as a full star). Used when |
1.1.0 |
|
Any |
|
The graphic to display to represent a 'half' rating slot (such as a half star). Used when |
1.1.0 |
|
String |
|
Specifies the layout direction for the progress bar. Set this property to either |
1.4.0 |
|
String |
|
The type of graphic to use for the rating. Set to |
1.1.0 |
|
Number |
— |
The numeric rating between 0 and 5. Used when |
1.1.0 |
|
String |
|
Determines whether to display a single graphical asset for the rating, or build the rating from multiple image assets. When set to |
1.1.0 |
|
|
The padding to use between each rating slot. Used when |
1.1.0 |
|
|
String |
— |
The text shown besides the rating. |
1.1.0 |
|
Number |
|
The opacity of the text shown next to the rating. Set to a number between 0 and 1. |
1.3.0 |
|
Any |
— |
The graphic to display to represent the rating. Used when |
1.1.0 |
|
— |
The width of the bounding box for the single graphic that represents the rating. Used when |
1.1.0 |
|
|
String |
|
Set the dark or light color theme. The selected theme controls the colors used for the component. |
1.1.0 |
About single and multiple slot modes
AlexaRating
has two different modes for displaying the rating, set in the ratingSlotMode
property:
- Single – Display a single, static graphic. You can provide the either an AVG or image to display and the width to use for the image.
- Multiple – Use a numeric rating between 0 and 5, such as "3.5", to dynamically determine the set of graphics that represent the rating. This option uses three different graphics representing the state of each "slot" – full, half, or empty. For example, for a 3.5 rating, this option displays the "full" graphic three times, the "half" graphic once, and finally the "empty" graphic once.
The AlexaRating
responsive component includes default "star" graphics for the full, half, and empty states. You can use these or provide your own image or AVG.
The following example displays a 3.5 rating with the default star graphics.
{
"type": "AlexaRating",
"ratingSlotPadding": "4dp",
"ratingSlotMode": "multiple",
"ratingNumber": 3.5,
"ratingText": "509 ratings"
}
The following example displays the single graphic defined as "customRating".
{
"type": "AlexaRating",
"ratingSlotMode": "single",
"singleRatingGraphic": "customRating",
"ratingText": "609 ratings"
}
AlexaRating example
This example shows the complete document that shows both the multiple and single rating slot examples.
Related topics
Last updated: Nov 28, 2023