6.7 · UI Pattern

Toast Notification.

Brief feedback that slides in from the bottom-right, dismisses automatically with a progress bar, and stacks when multiple appear. Sonner / react-hot-toast pattern.

What it is

Non-blocking feedback messages — "Saved", "Copied to clipboard", "Failed to upload" — that briefly appear in a corner of the screen, auto-dismiss after a few seconds, and can be dismissed manually. Multiple toasts stack vertically; the newest appears on top, oldest disappears first. Used everywhere — every modern web app ships a toast system, usually from a library like Sonner or react-hot-toast.

How it works

One container fixed in a corner (bottom-right standard). When a toast is triggered, JS appends a new element to the container with the message + type + auto-dismiss timer. The element animates in (translateX from 120% + opacity 0 → 0/1) using a springy easing, then animates out before the timer ends. A thin progress bar at the bottom of each toast counts down visually. Click the × or wait — both call the same cleanup. Use flex-direction: column-reverse so new toasts appear at the bottom.

Fixed corner containerposition:fixed bottom:24px right:24px with flex-direction:column-reverse
Slide-in springtranslateX 120% → 0 with cubic-bezier(0.34, 1.56, 0.64, 1)
Auto-dismiss + baranimation that shrinks scaleX(1) → scaleX(0) for the visual timer
Types: success/info/warn/errorEach with its own icon, color, and corresponding bar tint

Live demo

Trigger any toast — they auto-dismiss in ~4 seconds, stack, and can be closed by clicking the ×.

Live · trigger toasts

Click any button to spawn a toast in the bottom-right of the demo. Multiple toasts stack — newest on top of the visual pile (oldest at the top of the column). Watch the colored progress bar count down before auto-dismiss.

Copy this prompt

Prompt · 6.7 Toast Notification
Build a toast notification system. Container: position:fixed bottom:24px right:24px, max-width:360px, display:flex flex-direction:column-reverse gap:10px (so new toasts push older ones up). A toast(type, title, message) JS function creates a new div with: dark background (#14141B), rounded 12px, 14-16px padding, deep shadow. Layout: round icon circle on the left (success ✓ green, info ⓘ blue, warn ⚠ yellow, error ✕ red — each with a tinted-alpha background), body in the middle (title 14px bold + message 13px muted), close button on the right (× icon). Below the body, a 2px progress bar pinned to the bottom-left of the toast. Toast animations: in — transform translateX(120%) opacity:0 → translateX(0) opacity:1 with cubic-bezier(0.34, 1.56, 0.64, 1) over 0.32s. Out — same in reverse, fires automatically after 4.2 seconds via @keyframes. The bar uses a separate @keyframes that scales scaleX(1) → scaleX(0) over 4.2s linear so it visually counts down. Close button removes the toast immediately. Provide 4 trigger buttons in the demo: Success / Info / Warning / Error each calling toast() with appropriate type, title, and message.

Example sites to study