Components · Notifications

E-Com Toast

An E-Com Toast confirms a shopping action without leaving the page: a product added to the cart, or saved to the wishlist. It has no status color; it speaks in the store’s own black and white.

How to show an E-Com Toast from script and the CSS behind it. The files are eco-design-system/notifications.css and notifications.js.

Basic Usage

Link the shared files once per page. Never copy the rules into a page.

StepWhat to do
1. Link<link rel="stylesheet" href="/eco-design-system/notifications.css"> and <script src="/eco-design-system/notifications.js"></script>. Link button.css first.
2. Show a toastCall ECO_N.showEcomToast({ variant, name, text }).
3. Variantcart (image and two buttons) or info (black, optional link).
4. Actionsprimary and secondary for the cart, link for the informational toast, each { label, onClick }.

E-Com Toast

The markup has no motion. The slide is set in Motion on Examples & Guidelines.


API

Settings of showEcomToast

SettingUse
variantcart (default) or info.
name, textThe product name (bold) and the text after it.
imgAdd to cart: the product image URL.
primary, secondaryAdd to cart: buttons, each { label, onClick }.
linkInformational: { label, onClick }.
autoHideMilliseconds; default 4000, 0 = stays until dismissed.

Things to know

  • It uses the same host, motion and custom properties as the Toast: --toast-in-ease, --toast-in-duration, --toast-out-ease, --toast-out-duration.
  • Only one toast is on screen: a new toast replaces the current one, also a System Toast.
  • Buttons inside the toast are always 32px high, also when button.css is on the page.

CSS / Tailwind

The component is one CSS file and one script, shared by every notification. Link them, never copy them. The code below is read from the files the page links, so it is always what you see.