Button
Use the Button
action set to create buttons for other action sets, such as TitleBar
and Modal
. The 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 code
Anchor 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 button
Anchor link to section titled "Create a button"Create a primary button with the label Save
:
Subscribe to click action
Anchor 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 action
Anchor link to section titled "Dispatch click action"
Dispatch click action with a payload
Anchor link to section titled "Dispatch click action with a payload"
Attach buttons to a modal
Anchor 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 style
Anchor 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 Danger
style:
Update options
Anchor 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:
Unsubscribe
Anchor link to section titled "Unsubscribe"You call unsubscribe
to remove all current subscriptions on the button: