Skip to content

Inline Alert

Use InLineAlert to display a message or warning to the shopper, with a heading, an optional description, action buttons, and an optional dismiss button. The type prop sets the alert’s semantics and border color.

The SDK InLineAlert showing a success notification with a heading, icon, and dismiss button.
import { InLineAlert } from '/@dropins/tools/components.js';
PropTypeReq?Description
headingstringYesThe alert heading message.
variant'primary' | 'secondary'NoChange the appearance of the alert. The secondary variant disables the border and adds a background. Defaults to primary.
descriptionstringNoThe alert description text.
type'error' | 'warning' | 'success'NoThe alert type, which determines the border color and accessibility role. Defaults to warning.
iconVNode<HTMLAttributes<SVGSVGElement>>NoAn Icon component to display next to the heading.
additionalActionsArray<{ label: string; onClick: (event: Event) => void; 'aria-label'?: string }>NoOne or more action buttons. Each action needs a label and onClick, and may include an aria-label to give the button a unique accessible name (falls back to label when omitted).
onDismiss(event: Event) => voidNoWhen set, renders a dismiss button and calls this function when the shopper clicks it.
itemListVNodeNoA list of items to display inside the alert.
actionButtonPosition'top' | 'bottom'NoPosition of the action buttons. top renders only the first action next to the heading; bottom renders all actions below the alert. When omitted, a single action renders at the top and two or more render at the bottom.

InLineAlert also accepts standard HTML attributes (for example, onClick, className), except icon.

The cart shows InLineAlert as a transient success notification after a shopper updates a cart item’s quantity or options through the mini PDP, with an Icon next to the heading and a dismiss button that clears it.

import { InLineAlert, Icon, provider } from '/@dropins/tools/components.js';
import { h } from '/@dropins/tools/preact.js';
const notification = await provider.render(InLineAlert, {
heading: 'Item updated in cart',
type: 'success',
variant: 'primary',
icon: h(Icon, { source: 'CheckWithCircle' }),
// Announce the notification to screen readers as soon as it appears.
'aria-live': 'assertive',
role: 'alert',
onDismiss: () => notification.remove(),
})(yourCartNotificationElement);
// Auto-dismiss after 5 seconds, the way the cart does.
setTimeout(() => notification.remove(), 5000);
  • Icon — pass an Icon as the icon prop.
  • Button — the component used to render each action.