Button action set to create buttons for other action sets, such as
Button action set does not provide functionality outside of other App Bridge actions. If you need a standard button component in your app, use a Polaris button.
Example codeAnchor link to section titled "Example code"
Create an app and import the
Button action from
@shopify/app-bridge/actions. Note that we'll be referring to this sample application throughout the examples below.
Create a buttonAnchor link to section titled "Create a button"
Create a primary button with the label
Subscribe to click actionAnchor link to section titled "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 actionAnchor link to section titled "Dispatch click action"
Dispatch click action with a payloadAnchor link to section titled "Dispatch click action with a payload"
Attach buttons to a modalAnchor link to section titled "Attach buttons to a modal"
You can attach buttons to other actions such as modals. To learn more about modals, see Modal.
Button styleAnchor link to section titled "Button style"
You can change the style of the button by passing the
style property. Buttons support a single alternate style, the
Update optionsAnchor link to section titled "Update options"
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:
UnsubscribeAnchor link to section titled "Unsubscribe"
unsubscribe to remove all current subscriptions on the button: