This page was printed on Dec 12, 2019. For the current version, visit https://help.shopify.com/en/api/embedded-apps/app-bridge/actions/button.
The Button action set is used to build buttons for other action sets, such as TitleBar and Modal.
Create an app and import the Button module from @shopify/app-bridge/actions. Note that we'll be referring to this sample application throughout the examples below.
Create a button
Generate a primary button with the label Save:
Subscribe to click action
You can subscribe to button actions by calling subscribe. This returns a function that you can call to unsubscribe from the action:
Dispatch click action
Dispatch click action with a payload
Attach buttons to a modal
You can attach buttons to other actions such as modals. To learn more about modals, see Modal.
You can change the style of the button by passing the style property. Buttons support a single alternate style, the Danger style:
You can call the set method with partial button options to update the options of an existing button. This automatically triggers the update action on the button and merges the new given options with existing options:
You call unsubscribe to remove all current subscriptions on the button: