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 React button.
Anchor to Example codeExample 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.
In the following example, config
is a valid App Bridge configuration object. Learn more about configuring App Bridge.
Create a primary button with the label Save
:
Anchor to Subscribe to click actionSubscribe 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:
Anchor to Dispatch click actionDispatch click action
Anchor to Dispatch click action with a payloadDispatch click action with a payload
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:
Anchor to Update optionsUpdate 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:
Anchor to UnsubscribeUnsubscribe
You call unsubscribe
to remove all current subscriptions on the button: