Text List (1.1.0)
(This is not the most recent version of AlexaTextList
. Use the Other Versions option to see the documentation for the most recent version of AlexaTextList
)
The Alexa text list template (AlexaTextList
) displays a scrolling list of text items. This is a full-screen template that can include the header and background. You provide a set of text-based items to display in the list. You can configure the appearance of the list, such as including dividers and whether items should be numbered. You can also provide the command to run when a user selects an item from the list.
Import the alexa-layouts package
To use AlexaTextList
, import the alexa-layouts package.
The latest version of the alexa-layouts
package is 1.7.0. AlexaTextList
was introduced in version 1.1.0.
AlexaTextList Parameters
All parameters except type
are optional.
Name | Type | Default | Description | Version added/updated |
---|---|---|---|---|
|
String |
|
Image or video alignment to apply to the background image or video. |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
— |
Color to use as a background color. Used when neither |
1.1.0 |
|
|
Boolean |
|
When |
1.1.0 |
|
String |
— |
URL for the background image source. Used when |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
String |
|
Image or video scaling to apply to background image or video. |
1.1.0 |
|
String |
|
Audio track to play on when playing the video. Can be |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
— |
The background video source. Provide a source in the same format shown for the |
1.1.0 |
|
|
String |
— |
URL for attribution image source. Displays when |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
String |
— |
Attribution text to render in the header. Shown when |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
String |
— |
An accessibility label to describe the back button to customers who use a screen reader. |
1.1.0 |
|
|
Command to run when the user selects the back button. |
1.1.0 |
|
|
String |
|
Optional color value to use as the background color for the Header. |
1.1.0 |
|
String |
— |
Secondary text to render in header. |
1.1.0 |
|
String |
— |
Primary text to render in header. |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
Array of listItems |
— |
Array of text list items to present in list. |
1.1.0 |
|
Array of commands |
— |
When used with a standard viewport, defines the default action to run for the list items that don't define their own |
1.1.0 |
|
String |
|
Set the dark or light color theme. The selected theme controls the colors used for the template. |
1.1.0 |
|
Boolean |
|
When |
1.1.0 |
|
String |
— |
Always set to |
1.1.0 |
Provide the list items
The AlexaTextList
layout expects an array of items in the listItems
property. Each item is an object with the properties defined in the AlexaTextListItem
responsive component.
For example, you could define an array of items like this:
{
"listItems": [
{
"primaryText": "First item primary text",
"secondaryText": "This is the secondary text",
"secondaryTextPosition": "bottom",
"tertiaryText": "This is the tertiary text",
"tertiaryTextPosition": "bottom",
"ratingNumber": 2,
"imageThumbnailSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_brie.png",
"hideOrdinal": true,
"touchForward": true
},
{
"primaryText": "Second item in the list.",
"secondaryText": "Secondary text for the second item",
"imageThumbnailSource": "https://d2o906d8ln7ui1.cloudfront.net/images/md_gruyere.png",
"tertiaryText": "Tertiary text",
"tertiaryTextPosition": "bottom",
"ratingNumber": 0
},
{
"primaryText": "Third item in the list.",
"imageThumbnailSource": "https://d2o906d8ln7ui1.cloudfront.net/images/sm_blue.png"
},
{
"primaryText": "Fourth item in the list"
},
{
"primaryText": "Fifth item in the list"
},
{
"primaryText": "This list might have many more items"
}
]
}
You can define this in the listItems
array parameter of AlexaTextList
, or in a separate data source.
The specific list item parameters available depends on the version of AlexaTextListItem
. 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 AlexaTextListItem
.
Specify the action for each list item
AlexaTextList
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 AlexaTextList
component, AlexaTextList
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}"
]
}
}
AlexaTextList example
Related topics
Last updated: Nov 28, 2023