Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

AlertBanner

Use AlertBanner to notify a shopper and prompt them to take action. It renders a dismissible banner with a message, an optional icon, and an optional action button.

The SDK AlertBanner showing a notification message with an action button.
import { AlertBanner } from '@dropins/tools/components.js';
PropTypeReq?Description
variant'brand' | 'neutral' | 'success' | 'warning'YesThe banner variant.
messageVNodeYesThe banner message.
onDismiss() => voidYesHandler called when the shopper dismisses the banner.
iconVNode<HTMLAttributes<SVGSVGElement>>NoThe banner icon.
action{ label: string; onClick: (event: Event) => void }NoOptional action with a label and an onClick handler.

AlertBanner also accepts standard <div> HTML attributes (for example, className), except icon and action.

Render a banner with a message, an icon, an action, and a dismiss handler. Build the message and icon VNodes with h.

import { AlertBanner, Icon, provider } from '@dropins/tools/components.js';
import { h } from '@dropins/tools/preact.js';
await provider.render(AlertBanner, {
variant: 'success',
icon: h(Icon, { source: 'InfoFilled' }),
message: h('span', {}, 'Your changes were saved.'),
action: {
label: 'Undo',
onClick: () => yourUndoChanges(),
},
onDismiss: () => yourHideBanner(),
})(document.querySelector('.alert-banner'));
  • InLineAlert — for inline messages tied to a specific field or section.
  • Icon — pass an Icon as the icon prop.