Banner
Highlights important information or required actions prominently within the interface. Use to communicate statuses, provide feedback, or draw attention to critical updates.
Anchor to propertiesProperties
- Anchor to dismissibledismissibleboolean
Determines whether the close button of the banner is present.
When the close button is pressed, the
dismiss
event will fire, thenhidden
will be true, any animation will complete, and theafterhide
event will fire.- Anchor to headingheadingstring
The title of the banner.
- boolean
Determines whether the banner is hidden.
If this property is being set on each framework render (as in 'controlled' usage), and the banner is
dismissible
, ensure you update app state for this property when thedismiss
event fires.If the banner is not
dismissible
, it can still be hidden by setting this property.- Anchor to tonetone"info" | "success" | "warning" | "critical" | "auto"
Sets the tone of the Banner, based on the intention of the information being conveyed.
The banner is a live region and the type of status will be dictated by the Tone selected.
critical
creates an assertive live region that is announced by screen readers immediately.neutral
,info
,success
,warning
andcaution
creates an informative live region that is announced by screen readers after the current message.
Banner
- adoptedCallback
() => void
- attributeChangedCallback
(name: string) => void
- click
Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`. For example, if the `sourceEvent` was a middle click, or has particular keys held down, components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
({ sourceEvent }?: ClickOptions) => void
- connectedCallback
() => void
- disconnectedCallback
() => void
- dismissible
Determines whether the close button of the banner is present. When the close button is pressed, the `dismiss` event will fire, then `hidden` will be true, any animation will complete, and the `afterhide` event will fire.
boolean
- heading
The title of the banner.
string
- hidden
Determines whether the banner is hidden. If this property is being set on each framework render (as in 'controlled' usage), and the banner is `dismissible`, ensure you update app state for this property when the `dismiss` event fires. If the banner is not `dismissible`, it can still be hidden by setting this property.
boolean
- queueRender
Queue a run of the render function. You shouldn't need to call this manually - it should be handled by changes to @property values.
() => void
- setAttribute
(name: string, value: string) => void
- tone
Sets the tone of the Banner, based on the intention of the information being conveyed. The banner is a live region and the type of status will be dictated by the Tone selected. - `critical` creates an [assertive live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role) that is announced by screen readers immediately. - `neutral`, `info`, `success`, `warning` and `caution` creates an [informative live region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/status_role) that is announced by screen readers after the current message.
"info" | "success" | "warning" | "critical" | "auto"
declare class Banner extends PreactCustomElement implements BannerProps {
accessor heading: BannerProps['heading'];
accessor tone: BannerProps['tone'];
accessor hidden: BannerProps['hidden'];
accessor dismissible: BannerProps['dismissible'];
constructor();
}
ClickOptions
- sourceEvent
The event you want to influence the synthetic click.
ActivationEventEsque
export interface ClickOptions {
/**
* The event you want to influence the synthetic click.
*/
sourceEvent?: ActivationEventEsque;
}
ActivationEventEsque
- button
number
- ctrlKey
boolean
- metaKey
boolean
- shiftKey
boolean
export interface ActivationEventEsque {
shiftKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
button: number;
}
Anchor to eventsEvents
Learn more about registering events.
- Anchor to afterhideafterhideCallbackEventListener<typeof tagName> | null
- Anchor to dismissdismissCallbackEventListener<typeof tagName> | null
BannerEvents
- afterhide
CallbackEventListener<typeof tagName> | null
- dismiss
CallbackEventListener<typeof tagName> | null
export interface BannerEvents {
dismiss: CallbackEventListener<typeof tagName> | null = null;
afterhide: CallbackEventListener<typeof tagName> | null = null;
}
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Anchor to slotsSlots
- Anchor to secondary-actionssecondary-actionsHTMLElement
The secondary actions to display at the bottom of the banner.
A maximum of two
s-button
components are allowed, and only buttons with thevariant
of "secondary" are permitted.
BannerSlots
- secondary-actions
The secondary actions to display at the bottom of the banner. A maximum of two `s-button` components are allowed, and only buttons with the `variant` of "secondary" are permitted.
HTMLElement
export interface BannerSlots {
/**
* The secondary actions to display at the bottom of the banner.
*
* A maximum of two `s-button` components are allowed, and only buttons with the `variant` of "secondary" are permitted.
*/
'secondary-actions'?: HTMLElement;
}
Code
examples
Code
<s-banner heading="Order archived" tone="info" dismissible> This order was archived on March 7, 2017 at 3:12pm EDT. </s-banner>
<!DOCTYPE html><html><head><style>html, body {height:100%} body {box-sizing: border-box; margin: 0; padding:0.5rem; display: grid; place-items: center; gap: 0.5rem;}</style><script src="https://cdn.shopify.com/shopifycloud/app-bridge-ui-experimental.js"></script></head><body><s-banner heading="Order archived" tone="info" dismissible> This order was archived on March 7, 2017 at 3:12pm EDT. </s-banner> </body></html>
Preview
Anchor to outside-of-a-sectionOutside of a section
Banners placed outside of a section will display in their own card and should be located at the top of the page. They're useful for conveying messages that apply to the entire page or areas not visible within the viewport, such as validation errors further down the page.
Anchor to in-a-sectionIn a section
Banners placed inside a section will have styles applied contextually. They're useful for conveying messages relevant to a specific section or piece of content.
Anchor to best-practicesBest practices
- Seeing these banners can be stressful, so use them sparingly to avoid overwhelming users.
- Focus on a single piece of information or required action to avoid overwhelming users.
- Make the message concise and scannable. Users shouldn’t need to spend a lot of time figuring out what they need to know and do.
- Info, Warning and Critical banners should contain a call to action and clear next steps. Users should know what to do after seeing the banner.
- Avoid banners that can't be dismissed unless the user is required to take action.