Contextual Save Bar
This is a legacy API. Use the latest version of Contextual Save Bar
instead.
Display the contextual save bar to indicate that a form on the current page contains unsaved information, or when the users is in the process of creating a new object, such as a product or customer. The contextual save bar provides save and discard buttons to a user.

The following are ways to use the contextual save bar:
Anchor to Plain JavaScriptPlain Java Script
Anchor to Example codeExample code
Import the createApp
function from @shopify/app-bridge
and the ContextualSaveBar
from @shopify/app-bridge/actions
. Then use the createApp
function to create an app.
In the following example, config
is a valid App Bridge configuration object. Learn more about configuring App Bridge.
Anchor to Create and showCreate and show
Create a contextual save bar instance with some initial options. Then dispatch a SHOW
action to display it on the page.
Navigation actions (Redirect and History) on Shopify Admin are also blocked while the contextual save bar is visible. If your app contains a title bar, you will not be able to make any updates to the title bar buttons while a contextual save bar is being shown. In addition, all title bar buttons will be disabled automatically while the contextual save bar is displayed. The disabled state of buttons inside the title bar are automatically reset to their previous states when the contextual save bar is hidden. To learn more about the title bar, see Title Bar action.
Anchor to Update optionsUpdate options
You can modify the options at any time using the set
method. If the contextual save bar is visible, the UI will update immediately.
Anchor to HideHide
Dispatch a HIDE
action when you want to hide the contextual save bar.
Anchor to Subscribe to Discard and SaveSubscribe to Discard and Save
Subscribe to the contextual save bar actions (ContextualSaveBar.Action.DISCARD
and ContextualSaveBar.Action.SAVE
) in order to do something when a user clicks the Save or Discard button. The subscribe
method returns a function that you can call to unsubscribe from the action.
To hide the contextual save bar, dispatch a ContextualSaveBar.Action.HIDE
action in the subscribe callback.
Anchor to UnsubscribeUnsubscribe
Call the unsubscribe
method to remove all current subscriptions on the contextual save bar.
Anchor to ReactReact
Anchor to [object Object], hookuseContextualSaveBar
hook
useContextualSaveBar
hookuseContextualSaveBar
is a hook that accepts no arguments and returns an object with the following methods and objects:
show: ({fullWidth?: boolean; leaveConfirmationDisable?: boolean}) => void;
hide: () => void;
saveAction: { setOptions: (options: SaveActionOptions) => void };
discardAction: { setOptions: (options: DiscardActionOptions) => void };
Anchor to Example CodeExample Code
When using the App Bridge React library, you need to wrap all of your App Bridge React code inside of a single App Bridge Provider
.
The useContextualSaveBar
hook does not accept any props. The following are the APIs for the methods and objects that the hook returns:
show
Name | Type | Description | Required |
---|---|---|---|
fullWidth | boolean | Whether the contextual save bar should fill the entire screen width | No |
leaveConfirmationDisable | boolean | Whether to show a confirmation modal after the user navigates away from the page | No |
hide
No arguments.
Refer to SaveActionOptions
.
Refer to DiscardActionOptions
.
Anchor to [object Object], componentContextualSaveBar
component
ContextualSaveBar
componentContextualSaveBar
is a component that accepts props.
Anchor to Example CodeExample Code
When using the App Bridge React library, you need to wrap all of your App Bridge React code inside of a single App Bridge Provider
.
Anchor to PropsProps
The ContextualSaveBar
component accepts the following props:
Name | Type | Description | Required |
---|---|---|---|
saveAction | SaveActionOptions | Options to customize save behaviour | No |
discardAction | DiscardActionOptions | Options to customize discard behaviour | No |
fullWidth | boolean | Whether the contextual save bar should fill the entire screen width | No |
leaveConfirmationDisable | boolean | Whether to show a confirmation modal after the user navigates away from the page | No |
visible | boolean | Whether the contextual save bar appears on the screen | No |
Both the ContextualSaveBar
component and the useContextualSaveBar
hook use the following types:
Anchor to [object Object]SaveActionOptions
SaveActionOptions
Name | Type | Description | Required |
---|---|---|---|
disabled | boolean | Whether the contextual save bar button is in a disabled state | No |
loading | boolean | Whether the contextual save bar button is in a loading state | No |
onAction | () => void | A callback fired when the user presses the save button | No |
Anchor to [object Object]DiscardActionOptions
DiscardActionOptions
Name | Type | Description | Required |
---|---|---|---|
disabled | boolean | Whether the contextual discard bar button is in a disabled state | No |
loading | boolean | Whether the contextual discard bar button is in a loading state | No |
onAction | () => void | A callback fired when the user presses the discard button | No |
discardConfirmationModal | boolean | No |