Skip to main content

Banner

The banner component highlights important information or required actions prominently within the interface. Use banners to communicate statuses, provide feedback, draw attention to critical updates, or guide buyers toward necessary actions.

Banners support multiple tones to convey urgency levels, optional actions for next steps, and can be positioned contextually within sections or page-wide at the top. For inline status indicators on individual items, use badge.

Support
Targets (29)

Configure the following properties on the banner component.

Anchor to collapsible
collapsible
boolean
Default: false

Whether the banner content can be collapsed and expanded by the user. A collapsible banner conceals child elements initially, allowing the user to expand the banner to reveal them.

Anchor to dismissible
dismissible
boolean
Default: false

Whether the banner displays a close button that allows users to dismiss it.

When the close button is pressed, the dismiss event will fire, then hidden will be set to true, any animation will complete, and the afterhide event will fire.

Anchor to heading
heading
string
Default: ''

The heading text displayed at the top of the banner to summarize the message or alert.

Anchor to hidden
hidden
boolean
Default: false

Controls whether the banner is visible or hidden.

When using a controlled component pattern and the banner is dismissible, update this property to true when the dismiss event fires.

You can hide the banner programmatically by setting this to true even if it's not dismissible.

string

A unique identifier for the element. Use this to reference the element in JavaScript, link labels to form controls, or target specific elements for styling or scripting.

'success' | 'info' | 'auto' | 'warning' | 'critical'
Default: 'auto'

The semantic meaning and color treatment of the component. The banner is a live region and the type of status is dictated by the tone selected.

  • info: Informational content or helpful tips.
  • auto: Automatically determined based on context.
  • success: Positive outcomes or successful states.
  • warning: Important warnings about potential issues.
  • critical: Urgent problems or destructive actions.

The critical tone creates an assertive live region that is announced by screen readers immediately. The info, success, and warning tones create an informative live region that is announced by screen readers after the current message.

The banner component provides event callbacks for handling user interactions. Learn more about handling events.

Anchor to afterhide
afterhide
<typeof tagName>

A callback that fires when the banner has fully hidden, including after any hide animations have completed.

The hidden property is true when this event fires.

Anchor to dismiss
dismiss
<typeof tagName>

A callback that fires when the banner is dismissed by the user clicking the close button.

This doesn't fire when setting hidden manually.

The hidden property is false when this event fires.


Anchor to Display a basic notificationDisplay a basic notification

Display a basic notification to the buyer. This example renders an s-banner with an info tone and a heading to communicate a free shipping promotion.

Display a basic notification

A rendered example of the banner component

html

<s-banner heading="Free shipping on all orders." tone="info"></s-banner>

Anchor to Warn with a dismissible bannerWarn with a dismissible banner

Present a warning buyers can dismiss. This example combines warning tone with dismissible for address verification details.

html

<s-banner
heading="Action needed for delivery"
tone="warning"
dismissible
collapsible
>
<s-paragraph>
We could not verify your apartment number. Update your address or confirm
the building name so we can ship your order.
</s-paragraph>
</s-banner>

Anchor to Confirm a successful actionConfirm a successful action

Confirm to buyers when they successfully complete an action. This example shows an s-banner confirming a discount application with tone="success" and a short savings summary.

html

<s-banner heading="Discount applied" tone="success">
<s-paragraph>
Your code SAVE10 saved you $10.00 on this order.
</s-paragraph>
</s-banner>

  • Use banners sparingly: Too many banners distract buyers from completing checkout. Reserve them for the most important information.
  • Place banners contextually: Display banners at the top of a page or section, below the relevant header. If a banner relates to specific content, place it near that content.
  • Include a next step when possible: Add a button with a clear action so buyers know what to do after reading the message.
  • Make banners dismissible unless critical: Buyers should be able to dismiss informational banners. Keep critical banners persistent until the issue is resolved.
  • Match tone to urgency: The default tone is auto, which adapts to context. Use info for general updates, warning for issues needing attention, success for confirmations, and critical for problems that must be resolved to complete checkout.
  • Use the critical tone sparingly: The critical tone creates an assertive live region that screen readers announce immediately. Overusing it overwhelms buyers using assistive technology.

Was this page helpful?