Background
The Alexa background responsive component (AlexaBackground) displays a video, image, or color behind your content.
Compatibility
AlexaBackground is designed to work with the following viewport profiles:
- The following widget viewport profiles in the
alexa-viewport-profilespackage:- Widget Medium (
@hubWidgetMedium)
- Widget Medium (
- All standard viewport profiles in the
alexa-viewport-profilespackage:- All hub round profiles
- All hub landscape profiles
- All hub portrait profiles
- All mobile profiles
- All TV profiles
For details about viewport profiles, see Viewport Profiles.
Differences for widgets
Widgets don't support playing video, so AlexaBackground doesn't support using a video background when used in a widget.
Import the alexa-layouts package
To use AlexaBackground, import the alexa-layouts package.
The latest version of the alexa-layouts package is 1.7.0. AlexaBackground was introduced in version 1.1.0.
AlexaBackground Parameters
The following table shows the parameters you can set on AlexaBackground. Unless otherwise noted, standard viewport profiles support all parameters. The "Widget support" column indicates the widget viewport profiles that support each parameter. For details about viewport profiles, see Viewport Profiles.
All parameters except type are optional.
| Name | Type | Default | Description | Widget support | Version added |
|---|---|---|---|---|---|
|
|
String |
|
Image/video alignment to apply to the background image or video. |
Medium |
1.1.0 |
|
|
Boolean |
|
When |
Medium |
1.1.0 |
|
|
— |
Color to use as a background color. Used when neither |
Medium |
1.1.0 | |
|
|
String |
— |
URL for the background image source. Used when |
Medium |
1.1.0 |
|
|
String |
|
Image or video scaling to apply to background image or video. |
Medium |
1.1.0 |
|
|
— |
The background video source. Provide a source in the same format shown for the |
Not supported |
1.1.0 | |
|
|
Boolean |
|
When |
Medium |
1.1.0 |
|
|
Array |
— |
Array of entity data to bind to this component. |
Medium |
1.2.0 |
|
|
Boolean |
|
When |
Medium |
1.1.0 |
|
|
Boolean |
|
When |
Medium |
1.1.0 |
|
|
String |
— |
Always set to |
Medium |
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 |
Background source priority
You can provide more than one background source (video, image, and color). Alexa chooses the background to show based on this priority:
- Display the
backgroundVideoSourcewhen it's provided. - Display the
backgroundImageSourcewhen thebackgroundVideoSourceisn't provided. - Display the
backgroundColorwhen neither thebackgroundVideoSourceorbackgroundImageSourceare provided. - Use a default background when none of
backgroundVideoSource,backgroundImageSourceorbackgroundColorare provided.
Widgets don't support video, so for a widget, Alexa uses the same priority to choose between backgroundImageSource, backgroundColor, and the default background.
Position other components relative to the background
To display the background on the full viewport behind your other content, place the AlexaBackground layout first in the top-level Container and set the Container height and width to 100%.
For example, the following Container contains three items: AlexaBackground, AlexaHeader, and then a Text component. The plain dark red background fills the entire screen. The header text displays at the top over the background, and the text string displays further down on the screen.
AlexaBackground example
The following example displays a video background. The video starts automatically when the device renders the document and then plays through two times (repeatCount). (This example uses a fictitious backgroundVideoSource. Replace with the URL of the video you want to display).
{
"type": "AlexaBackground",
"backgroundVideoSource": [
{
"url": "https://example.com/fictitious-video-urls/background-video.mp4",
"repeatCount": 2
}
],
"videoAutoPlay": true,
"videoAudioTrack": "none"
}
The following example displays an image background instead of a video.
The following example shows an image background on a widget.
Related topics
- Alexa Design System Overview
- Responsive Components and Templates
- Alexa Design Guide: Responsive Components
Last updated: Dec 06, 2023