Button

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.2.0. AlexaButton was introduced in version 1.1.0.

Use the Other Versions option at the top of this page to see documentation for different versions of AlexaButton. The table of parameters notes the version of alexa-layouts in which each parameter was added.

AlexaButton Parameters

All parameters except type are optional.

Name Type Default Description Version added/updated

accessibilityLabel

String

None

A string describing the button. Voice over reads this string when the user selects the button.

1.1.0

buttonStyle

String

contained

The style of the button. Set to contained, outlined, ingress, or egress. For details about which styles to use, see Button appearance. The theme determines the button colors.

1.2.0

buttonText

String

"buttonText"

The text displayed on the button. This text should indicate the purpose of the button.

1.1.0

entities

Array

[]

Array of entity data to bind to this component.

1.2.0

primaryAction

Command

None

The action to trigger when the user selects the button.

1.1.0

theme

String

dark

Set the dark or light color theme. The selected theme controls the colors used for the component.

1.1.0

touchForward

boolean

false

When true, use the 'touch-forward' text style for the button text. This style displays the button text without italics. When false, assume the user is interacting with the button by voice and use the default 'voice-enabled' text style. For details about styling AlexaButton see Button appearance.

1.2.0

type

String

None

Always set to AlexaButton

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.

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 like contained, 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.

Use the touchForward toggle to set the font style for the button according to how you expect users to interact with the button:

  • Set touchForward to false when you expect users to interact with the button with voice. This setting is the default. The button displays the buttonText in an italic font to signify that the user can speak to trigger the button in addition to using touch. Make sure your interaction model lets users select the buttons by voice.
  • Set touchForward to true when you expect users to interact with the button primarily with touch. The button displays the buttonText in a plain font to signify that the buttons are not "speakable".
The four button styles in voice-forward and touch-forward variants
The four button styles in voice-forward and touch-forward variants

For design guidance for AlexaButton, see Button.

AlexaButton example

The following example shows a button that uses the default contained and voice-forward settings. When the user selects the button, the button runs the SendEvent command to send a UserEvent to the skill.

{
  "type": "AlexaButton",
  "buttonText": "Button with default settings",
  "id": "idForThisButton",
  "primaryAction": {
    "type": "SendEvent",
    "arguments": [
      "AlexaButton"
    ]
  }
}

This following example shows a complete document and data source that displays the four options in buttonStyle and the two settings for touchForward.

For an image that shows the results of this document, see Button appearance, earlier.