Image List
The Alexa image list template (AlexaImageList
) displays a scrolling list of images and text. AlexaImageList
is a full-screen template that optionally displays a header, footer, and background. You provide a set of image-based items to display in the list and configure the appearance of the list, such as including dividers and whether to number the items. You can also provide the command to run when a user selects an item from the list.
Compatibility
AlexaImageList
is designed to work with all standard viewport profiles in the alexa-viewport-profiles
package:
- All hub round profiles
- All hub landscape profiles
- All hub portrait profiles
- All mobile profiles
- All TV profiles
If you use AlexaImageList
on an unsupported viewport, you might have unexpected results. For details about viewport profiles, see Viewport Profiles.
Import the alexa-layouts package
To use AlexaImageList
, import the alexa-layouts package.
The latest version of the alexa-layouts
package is 1.7.0. AlexaImageList
was introduced in version 1.1.0.
AlexaImageList parameters
All parameters except type
are optional.
Name | Type | Default | Description | Widget support | Version added |
---|---|---|---|---|---|
|
String |
|
Image/video alignment to apply to background image/video. |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
— |
Color to use as a background color. Used when neither |
Not supported |
1.1.0 | |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
— |
URL for the background image source. Used when |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
|
Image or video scaling to apply to background image or video. |
Not supported |
1.1.0 |
|
— |
The background video source. Provide a source in the same format shown for the |
Not supported |
1.1.0 | |
|
String |
URL for a default image to use for any list items that don't have an |
Not supported |
1.1.0 | |
|
Array |
— |
Array of entity data to bind to this template. |
Not supported |
1.2.0 |
|
String |
— |
URL for attribution image source. Displays when |
Not supported |
1.1.0 |
|
Number |
|
The opacity of the attribution text and attribution image in the header. Set to a number between 0 and 1. |
Not supported |
1.3.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
— |
Attribution text to render in the header. Shown only when no |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
|
An accessibility label to describe the back button to customers who use a screen reader. |
Not supported |
1.1.0 |
|
|
Command to run when the user selects the back button. |
Not supported |
1.1.0 | |
|
String |
|
Optional color value to use as the background color for the Header. |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
— |
Primary text to render in header. |
Not supported |
1.1.0 |
|
Boolean |
|
Toggle to hide the divider that appears at the bottom/right of each 'Horizontal Item Lockup' item to help separate it from the next content. |
Not supported |
1.6.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
String |
— |
Hint text to display in the footer. Use |
Not supported |
1.1.0 |
|
string |
A string description of the hint text. Voice over reads this string when thge user selects this component. |
Not supported |
1.7.0 | |
|
String |
|
Sets a default for the |
Not supported |
1.1.0 |
|
String |
|
Aspect ratio to use for the image bounding box for all the items in the list. Options are square, round, standard_landscape, standard_portrait, poster_landscape, poster_portrait, widescreen. This property works the same as the |
Not supported |
1.1.0 |
|
Boolean |
|
Sets a default for the |
Not supported |
1.1.0 |
|
— |
Sets a default for the |
Not supported |
1.4.0 | |
|
Boolean |
|
Sets a default for the |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
|
Boolean |
|
Sets a default for the |
Not supported |
1.1.0 |
|
String |
|
Sets a default for the |
Not supported |
1.1.0 |
|
Boolean |
|
Sets a default for the |
Not supported |
1.3.0 |
|
String |
|
The language for the text displayed in the template. This language determines the default font used for the text. For example, when set to |
Not supported |
1.4.0 |
|
String |
|
Specifies the layout direction for the content. Set this property to either |
Not supported |
1.4.0 |
|
String |
— |
An identifier to assign to the |
Not supported |
1.2.0 |
|
Array of |
An array of items to display in the list. Each item is an object with the same properties as defined in |
Not supported |
1.1.0 | |
|
— |
Sets a default for the |
Not supported |
1.1.0 | |
|
Any |
— |
An array of speech items. The |
Not supported |
1.2.0 |
|
String |
|
Set the dark or light color theme. The selected theme controls the colors used for the template. |
Not supported |
1.1.0 |
|
String |
— |
Always set to |
Not supported |
1.1.0 |
|
String |
|
Audio track to play on when playing the video. Can be |
Not supported |
1.1.0 |
|
Boolean |
|
When |
Not supported |
1.1.0 |
Provide the list items
The AlexaImageList
template expects an array of items in the listItems
property. Each item is an object with the same properties as those defined in the AlexaImageListItem
responsive component.
The following example illustrates an array of items in a data source called imageListData
.
{
"imageListData": {
"listItemsToShow": [
{
"primaryText": "First list item",
"secondaryText": "Secondary text",
"imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_gruyere.png",
"imageProgressBarPercentage": 90,
"imageShowProgressBar": false,
"ratingSlotMode": "multiple",
"ratingNumber": 2.87,
"ratingText": "(206 ratings)"
},
{
"primaryText": "Second list item",
"secondaryText": "Secondary Text",
"tertiaryText": "Tertiary text",
"imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_gorgonzola.png",
"providerText": "Provider Text",
"imageProgressBarPercentage": 50,
"ratingSlotMode": "multiple",
"ratingNumber": 4.5,
"ratingText": "(500 ratings)"
},
{
"primaryText": "No image, use the default",
"secondaryText": "Secondary text",
"ratingSlotMode": "multiple",
"ratingNumber": 2,
"ratingText": "(50 ratings)"
},
{
"primaryText": "Fourth list item",
"secondaryText": "No progress bar",
"imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/tl_brie.png",
"ratingSlotMode": "multiple",
"ratingNumber": 5,
"ratingText": "(452 ratings)"
},
{
"primaryText": "Fifth list item",
"secondaryText": "With background blur",
"imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/MollyforBT7.png",
"ratingSlotMode": "multiple",
"ratingNumber": 0,
"ratingText": "(206 ratings)"
},
{
"primaryText": "Sixth list item (long text that wraps)",
"secondaryText": "Longer secondary text that truncates",
"imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/sm_blue.png",
"ratingSlotMode": "multiple",
"ratingNumber": 0,
"ratingText": "(206 ratings)"
}
]
}
}
Then, bind this array to the listItems
property with the expression ${imageListData.listItemsToShow}
.
{
"type": "AlexaImageList",
"listItems": "${imageListData.listItemsToShow}",
"defaultImageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/BT7_Background.png",
"imageBlurredBackground": true,
"primaryAction": {
"type": "SendEvent",
"arguments": [
"ListItemSelected",
"${ordinal}"
]
}
}
The specific list item parameters available depend on the version of AlexaImageListItem
. For example, the properties to display a rating require the 1.2.0 or later version of the alexa-layouts
package. For the full set of properties, see AlexaImageListItem
.
Set defaults for the list items
The AlexaImageList
template includes properties that correspond to properties in AlexaImageListItem
. Use these to set default values for those properties.
There are two types of defaults:
-
Defaults you can set or override for an individual item –
AlexaImageList
uses the value provided on the individual item when available, and uses the value provided onAlexaImageList
otherwise.For example, you might set
imageScale
tobest-fit
for the whole list, but then override it tobest-fill
for one item on the list. -
Defaults that always apply to all the items in the list –
AlexaImageList
always uses the value provided onAlexaImageList
for these properties. Any value in a corresponding property on an individual item is ignored.For example, you must set
imageAspectRatio
on the whole list. You can't have a list in which some items display as squares and some as circles. Any value forimageAspectRatio
on a list item is ignored.
The following table lists the properties you use as defaults.
Property | Can override on an item |
---|---|
defaultImageSource |
No |
imageAlignment |
Yes |
imageAspectRatio |
No |
imageBlurredBackground |
Yes |
imageHeight |
No |
imageHideScrim |
Yes |
ImageMetadataPrimacy |
No |
imageRoundedCorner |
Yes |
imageScale |
Yes |
imageShadow |
Yes |
primaryAction |
Yes |
For details about each of these properties, see AlexaImageListItem
.
Specify the action for each list item
AlexaImageList
is interactive. Users can select items on the list. Set the primaryAction
property to the command you want to run when the user selects an item.
When you set primaryAction
on the AlexaImageList
component, AlexaImageList
passes the command to each item on the list.
To override command for an individual list item, set the primaryAction
property on the list item itself.
The following example shows how you to use the SendEvent
command to send your skill a UserEvent
request. This passes the number representing the selected item as part of the SendEvent.arguments
array.
{
"primaryAction": {
"type": "SendEvent",
"arguments": [
"ListItemSelected",
"${ordinal}"
]
}
}
Use the SpeakList command with AlexaImageList
Use the speechItems
parameter on AlexaImageList
when you want to use the SpeakList
command to read the list of items. Set the speechItems
property to an array of items.
The SpeakList
command requires a speech
property on each list item to speak. The speech
property must be set to the output of either the ssmlToSpeech
or textToSpeech
transformer. Therefore, you need to do the following to use SpeakList
with AlexaImageList
:
- Use an object type data source for the array of items to speak. Within this data source, configure either the
ssmlToSpeech
ortextToSpeech
transformer to process the array of items to speak. - Bind the
speechItems
property of theAlexaImageList
to list of items to speak. - Invoke the
SpeakList
command for the list.
Configure a data source for list speech items
- Create an object type data source to use with your document.
-
In the data source, add an array of items to speak to a property within the
properties
object in the data source.The following example shows an object data source that contains an array called
listItemsToShow
. Note that the array of items is within theproperties
object.{ "imageListData": { "type": "object", "objectId": "imageListDataId", "properties": { "listItemsToShow": [ { "primaryText": "First list item", "imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_gruyere.png" }, { "primaryText": "Second list item", "imageSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_gorgonzola.png" } ] } } }
-
Configure the
ssmlToSpeech
ortextToSpeech
transformer with the following settings:inputPath
– The array of items to speak. The transformer expects the path you provide to be within theproperties
object, so you don't need to includeproperties
in the path. When the items in your array are objects, specify the specific field within the object that contains the text or SSML.outputName
– Set to the string "speech". TheAlexaImageList
template includes "speech" when handling the list of items, so you must use this exact string.transformer
– EitherssmlToSpeech
ortextToSpeech
, depending on the format of the items in the array
The following example configures the
textToSpeech
transformer to process theprimaryText
field for each item in thelistItemsToShow
array.{ "transformers": [ { "inputPath": "listItemsToShow[*].primaryText", "outputName": "speech", "transformer": "textToSpeech" } ] }
Bind the speechItems property to the list of items to speak
In your APL document, use a data-binding expression to bind the speechItems
property of AlexaImageList
to your list of items to speak.
Continuing the previous example, the expression is ${imageListData.properties.listItemsToShow}
. This example uses the same primaryText
both for display and for speech.
{
"type": "AlexaImageList",
"listItems": "${imageListData.properties.listItemsToShow}",
"speechItems": "${imageListData.properties.listItemsToShow}"
}
Run the SpeakList command for the list
Run the SpeakList
command when you want Alexa to read the items provided in speechItems
. For example, you might run the command from the onMount
handler to read the items after the device displays the document.
-
Assign the
listId
parameter onAlexaImageList
to an ID unique to your document. You must provide this ID to runSpeakList
.{ "type": "AlexaImageList", "listId": "myImageListWithItemsToSpeak", "listItems": "${imageListData.properties.listItemsToShow}", "speechItems": "${imageListData.properties.listItemsToShow}" }
-
Set the
componentId
property for theSpeakList
command to the ID you provided forlistId
.The following example invokes the command in the
onMount
handler. Alexa speaks the items after the device displays the document.{ "onMount": [ { "type": "SpeakList", "delay": 5000, "componentId": "myImageListWithItemsToSpeak", "start": 0, "count": "${imageListData.properties.listItemsToShow.length}", "minimumDwellTime": 1000, "align": "center" } ] }
The following examples show the complete document and data source. After the device displays the document, Alexa reads the primary text for each of the six items in the list. The SpeakList
command includes the five second delay to allow Alexa to speak the normal speech output for the skill response before reading the list items.
AlexaImageList and dynamicIndexList data sources
The AlexaImageList
template uses a Sequence
. This means you can use a dynamicIndexList
data source. With a dynamicIndexList
data source, you can do the following:
- Display large lists progressively as the user scrolls through the content (lazy loading).
- Update the items the data source after it is already displayed, so you can change the values on the screen without sending an entirely new document.
To use a dynamicIndexList data source with AlexaImageList
- Follow the
dynamicIndexList
structure shown in dynamicIndexList data source. Don't include any other properties not defined in this structure. - Put your list item objects in the
items
array in the data source. - Bind the data source to the
listItems
property ofAlexaImageList
. This binding is equivalent to binding the data source to thedata
property of aSequence
in a custom layout.
The following examples show a document with an AlexaImageList
that uses a dynamicIndexList
data source.
For details about defining a dynamicIndexList
data source, see dynamicIndexList data source.
For details about the directives and requests you use to manage the data source, see Alexa.Presentation.APL Interface Reference.
AlexaImageList example
In this example, selecting a list item sends a UserEvent
request with "ListItemSelected" and the number of the list item in the arguments
array. To test this event, copy the example to your skill.
Related topics
- Alexa Design System Overview
- Responsive Components and Templates
- Alexa Design Guide: Responsive Templates
Last updated: Nov 28, 2023