โœฆ StealThis .dev

Toast Notification Stack

A lightweight toast notification system with success, error, warning, and info variants. Toasts stack, auto-dismiss, and support manual close.

Open in Lab
vanilla-js css animation
Targets: JS HTML React Native

Expo Snack

Code

Toast Notification Stack

A zero-dependency toast notification system with four semantic variants: success, error, warning, and info. Toasts slide in from the bottom-right, stack vertically, and auto-dismiss after 4 seconds.

How it works

  1. showToast(message, type) creates a <div> with the right variant class and appends it to a fixed container
  2. A CSS slide-in keyframe animates entry; a slide-out class triggers exit before removal
  3. Auto-dismiss uses setTimeout โ€” clicking the ร— button cancels the timer and dismisses immediately
  4. Toasts stack naturally via flexbox column-reverse

Variants

  • success โ€” green accent, checkmark icon
  • error โ€” red accent, X icon
  • warning โ€” amber accent, triangle icon
  • info โ€” blue accent, info icon

When to use it

  • Form submission feedback
  • Async operation results (save, delete, upload)
  • System alerts and status updates