Button (1.4.0 - 1.5.0)
(This is not the most recent version of AlexaButton
. Use the Other Versions option to see the documentation for the most recent version of AlexaButton
)
The Alexa button responsive component (AlexaButton
) displays a button the user can select with touch or a controller. You can configure the text displayed on the button, the button appearance, and the command to run when the user selects the button.
Import the alexa-layouts package
To use AlexaButton
, import the alexa-layouts package.
The latest version of the alexa-layouts
package is 1.7.0. AlexaButton
was introduced in version 1.1.0.
AlexaButton Parameters
All parameters except type
are optional.
Name | Type | Default | Description | Version added/updated |
---|---|---|---|---|
|
String |
— |
A string describing the button. Voice over reads this string when the user selects the button. |
1.1.0 |
|
String |
|
The style of the button. Set to |
1.2.0 |
|
String |
|
The text displayed on the button. This text should indicate the purpose of the button. |
1.1.0 |
|
Array |
— |
Array of entity data to bind to this component. |
1.2.0 |
|
String |
|
The language for the text displayed in the button. This language determines the default font and formatting used for the text displayed on the button. For example, when set to |
1.4.0 |
|
String |
|
Specifies the layout direction for the button. Set this property to either |
1.4.0 |
|
— |
The action to trigger when the user selects the button. |
1.1.0 |
|
|
String |
|
Set the dark or light color theme. The selected theme controls the colors used for the component. |
1.1.0 |
|
Boolean |
|
When |
1.2.0 |
|
String |
— |
Always set to |
1.1.0 |
Button appearance
Use the buttonStyle
and touchForward
properties to configure the look of the button. The provided styles format the button consistently with overall Alexa visual design.
buttonStyle
To set the button style, set the buttonStyle
property to one of the following values:
contained
– Use this style for the main action you want the user to take. This style displays a button filled in with a semi-transparent background color.outlined
– Use this style for secondary actions. This style displays a button outlined in a solid color, but with a transparent body.ingress
– Use this style for actions such as "confirm", "yes", and "next". This style uses solid colors likecontained
, but with a different color scheme.egress
– Use this style for actions such as "decline", "no", and "previous". This style uses an outline with a transparent body.
touchForward
Use the touchForward
option to set the font style for the button according to how you expect users to interact with the button:
- Set
touchForward
tofalse
when you expect users to interact with the button with voice. This setting is the default. Make sure your interaction model lets users select the buttons by voice.- The button displays the text in the voice-enabled style to signify that the user can speak to trigger the button in addition to using touch.
- The default voice-enabled style displays the text in an italic font.
- Some language-specific fonts don't support italic text. The button text displays in plain text for these languages. Set the
lang
property to a language or locale string to use language-specific fonts. For example, when thelang
property isar
orar-SA
(Arabic), the button text displays in plain text instead of italics. (APL 1.7 andalexa-layouts
1.4.0 or later).
- Set
touchForward
totrue
when you expect users to interact with the button primarily with touch instead of speech.- The button displays the text in the touch-forward style to signify that the buttons aren't "speakable".
- The default touch-forward style displays text in plain text instead of italics.
- For languages that don't support italics, the button automatically encloses the button text in quotation marks to distinguish the style from the voice-enabled style. For example, when the
lang
property isar
orar-SA
(Arabic), the button encloses the button text in quotation marks. (APL 1.7 andalexa-layouts
1.4.0 or later).
AlexaButton example
The following example displays the four options in buttonStyle
and the two settings for touchForward
. When the user selects the button, the button runs the SetValue
command to update a message in a Text
component.
Related topics
- Alexa Design System Overview
- Responsive Components and Templates
- Alexa Design Guide: Responsive Components
- Alexa Design Guide: Responsive Components
Last updated: Nov 28, 2023