|$ curl https://forge-ai.dev/api/markdown?path=docs/components/toast
$cat docs/toast-notifications.md
updated Recently·16 min read·published

Toast Notifications

CSSHTMLTailwindBootstrapUIIntermediate🎯Free Tools
Introduction

Toast notifications are ephemeral, non-blocking messages that appear temporarily to confirm actions, report errors, or surface important updates. This guide covers production-ready toast patterns in plain HTML/CSS, Tailwind CSS, and Bootstrap — including semantic variants, dismissible states, actions, positioning, stacking, progress indicators, and accessibility.

info

Keep toast messages concise. Use a title + one-line description, and ensure critical errors persist until the user dismisses them.
Toast Variants

Four semantic toast types with matching inline SVG icons and accent colors for different notification contexts.

toast-variants
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast success">
3 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
5 <polyline points="22 4 12 14.01 9 11.01"/>
6 </svg>
7 <div class="content">
8 <strong>
9 Success
10 </strong>
11 <p>
12 Your changes have been saved successfully.
13 </p>
14 </div>
15 </div>
16 <div class="toast error">
17 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
18 <circle cx="12" cy="12" r="10"/>
19 <line x1="15" y1="9" x2="9" y2="15"/>
20 <line x1="9" y1="9" x2="15" y2="15"/>
21 </svg>
22 <div class="content">
23 <strong>
24 Error
25 </strong>
26 <p>
27 Failed to connect. Please try again.
28 </p>
29 </div>
30 </div>
31 <div class="toast warning">
32 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
33 <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
34 <line x1="12" y1="9" x2="12" y2="13"/>
35 <line x1="12" y1="17" x2="12.01" y2="17"/>
36 </svg>
37 <div class="content">
38 <strong>
39 Warning
40 </strong>
41 <p>
42 Your session will expire in 5 minutes.
43 </p>
44 </div>
45 </div>
46 <div class="toast info">
47 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
48 <circle cx="12" cy="12" r="10"/>
49 <line x1="12" y1="16" x2="12" y2="12"/>
50 <line x1="12" y1="8" x2="12.01" y2="8"/>
51 </svg>
52 <div class="content">
53 <strong>
54 Info
55 </strong>
56 <p>
57 A new software update is available.
58 </p>
59 </div>
60 </div>
61</div>
preview

info

Use toasts for brief, non-blocking notifications. They should auto-dismiss after 3-5 seconds for success messages, but persist for errors until the user dismisses them.
Dismissible

Toasts with a close button for manual dismissal — essential for error messages users need to read.

toast-dismiss
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast success dismissible">
3 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
5 <polyline points="22 4 12 14.01 9 11.01"/>
6 </svg>
7 <div class="content">
8 <strong>
9 File uploaded
10 </strong>
11 <p>
12 report-2024.pdf has been uploaded.
13 </p>
14 </div>
15 <button class="close" aria-label="Dismiss">
16 &times;
17 </button>
18 </div>
19 <div class="toast error dismissible">
20 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
21 <circle cx="12" cy="12" r="10"/>
22 <line x1="15" y1="9" x2="9" y2="15"/>
23 <line x1="9" y1="9" x2="15" y2="15"/>
24 </svg>
25 <div class="content">
26 <strong>
27 Upload failed
28 </strong>
29 <p>
30 File exceeds 10MB limit.
31 </p>
32 </div>
33 <button class="close" aria-label="Dismiss">
34 &times;
35 </button>
36 </div>
37</div>
preview
With Action Buttons

Toasts with action buttons for undo, retry, or navigation — gives users a clear next step.

toast-action
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast success">
3 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
5 <polyline points="22 4 12 14.01 9 11.01"/>
6 </svg>
7 <div class="content">
8 <strong>
9 Message sent
10 </strong>
11 <p>
12 Your email has been delivered.
13 </p>
14 </div>
15 <button class="toast-btn">
16 Undo
17 </button>
18 </div>
19 <div class="toast error">
20 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
21 <circle cx="12" cy="12" r="10"/>
22 <line x1="15" y1="9" x2="9" y2="15"/>
23 <line x1="9" y1="9" x2="15" y2="15"/>
24 </svg>
25 <div class="content">
26 <strong>
27 Sync failed
28 </strong>
29 <p>
30 Could not sync your data.
31 </p>
32 </div>
33 <button class="toast-btn">
34 Retry
35 </button>
36 </div>
37</div>
preview

best practice

Action buttons in toasts should use outline or ghost styling to avoid competing visually with the main content area. Keep the button text short — "Undo", "Retry", "View" — not full sentences.
Positions

Toast placement in different corners and edges — choose the position that least disrupts the user flow.

toast-positions
Live
untitled.html
HTML
1<div class="grid">
2 <div class="pos top-left">
3 <div class="toast info mini">
4 Top Left
5 </div>
6 </div>
7 <div class="pos top-right">
8 <div class="toast info mini">
9 Top Right
10 </div>
11 </div>
12 <div class="pos bottom-left">
13 <div class="toast info mini">
14 Bottom Left
15 </div>
16 </div>
17 <div class="pos bottom-right">
18 <div class="toast info mini">
19 Bottom Right
20 </div>
21 </div>
22 <div class="pos top-center">
23 <div class="toast info mini">
24 Top Center
25 </div>
26 </div>
27</div>
preview

warning

Position toasts away from primary navigation areas. Bottom-right is the most common default. Avoid top-center for long messages as it can overlap with the browser toolbar on mobile.
Stacking

Multiple toasts stacking vertically with spacing — newer toasts push older ones up.

toast-stack
Live
untitled.html
HTML
1<div class="stack-area">
2 <div class="toast success">
3 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
5 <polyline points="22 4 12 14.01 9 11.01"/>
6 </svg>
7 <div class="content">
8 <strong>
9 Saved
10 </strong>
11 <p>
12 Profile updated.
13 </p>
14 </div>
15 </div>
16 <div class="toast info">
17 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
18 <circle cx="12" cy="12" r="10"/>
19 <line x1="12" y1="16" x2="12" y2="12"/>
20 <line x1="12" y1="8" x2="12.01" y2="8"/>
21 </svg>
22 <div class="content">
23 <strong>
24 New message
25 </strong>
26 <p>
27 You have 3 unread messages.
28 </p>
29 </div>
30 </div>
31 <div class="toast warning">
32 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
33 <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
34 <line x1="12" y1="9" x2="12" y2="13"/>
35 <line x1="12" y1="17" x2="12.01" y2="17"/>
36 </svg>
37 <div class="content">
38 <strong>
39 Storage low
40 </strong>
41 <p>
42 Only 2GB remaining.
43 </p>
44 </div>
45 </div>
46</div>
preview
With Progress Bar

Toasts with a progress bar showing remaining time before auto-dismiss — gives users a visual countdown.

toast-progress
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast success with-progress">
3 <div class="progress-track">
4 <div class="progress-fill" style="width:80%">
5 </div>
6 </div>
7 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
8 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
9 <polyline points="22 4 12 14.01 9 11.01"/>
10 </svg>
11 <div class="content">
12 <strong>
13 Processing
14 </strong>
15 <p>
16 Your request is being processed...
17 </p>
18 </div>
19 </div>
20 <div class="toast error with-progress">
21 <div class="progress-track">
22 <div class="progress-fill err" style="width:45%">
23 </div>
24 </div>
25 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
26 <circle cx="12" cy="12" r="10"/>
27 <line x1="15" y1="9" x2="9" y2="15"/>
28 <line x1="9" y1="9" x2="15" y2="15"/>
29 </svg>
30 <div class="content">
31 <strong>
32 Error
33 </strong>
34 <p>
35 This toast persists until dismissed.
36 </p>
37 </div>
38 </div>
39</div>
preview
🔥

pro tip

A shrinking progress bar at the top of the toast visually communicates how long it will stay visible. Animate the width from 100% to 0% over the auto-dismiss duration. For persistent toasts (errors), omit the progress bar entirely.
Rich Toast

Toasts with avatars, images, and complex layouts for richer notification content.

toast-rich
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast rich">
3 <div class="t-avatar" style="background:#3B82F6">
4 JD
5 </div>
6 <div class="content">
7 <strong>
8 Jane commented on your post
9 </strong>
10 <p>
11 &quot;Great article! The section on caching was really helpful.&quot;
12 </p>
13 </div>
14 </div>
15 <div class="toast rich">
16 <div class="t-avatar" style="background:#A855F7">
17 AB
18 </div>
19 <div class="content">
20 <strong>
21 Alex shared a file
22 </strong>
23 <p>
24 design-system-v2.fig
25 </p>
26 </div>
27 <button class="toast-btn">
28 View
29 </button>
30 </div>
31</div>
preview
Minimal Style

Clean, minimal toasts with just an icon, text, and close button — no heavy backgrounds or borders.

toast-minimal
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast mini success">
3 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
4 <polyline points="20 6 9 17 4 12"/>
5 </svg>
6 <span>
7 Changes saved
8 </span>
9 <button class="close" aria-label="Dismiss">
10 &times;
11 </button>
12 </div>
13 <div class="toast mini error">
14 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
15 <line x1="18" y1="6" x2="6" y2="18"/>
16 <line x1="6" y1="6" x2="18" y2="18"/>
17 </svg>
18 <span>
19 Connection lost
20 </span>
21 <button class="close" aria-label="Dismiss">
22 &times;
23 </button>
24 </div>
25 <div class="toast mini info">
26 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
27 <circle cx="12" cy="12" r="10"/>
28 <line x1="12" y1="16" x2="12" y2="12"/>
29 <line x1="12" y1="8" x2="12.01" y2="8"/>
30 </svg>
31 <span>
32 Tip: Press Cmd+K to search
33 </span>
34 <button class="close" aria-label="Dismiss">
35 &times;
36 </button>
37 </div>
38</div>
preview
📝

note

Minimal toasts work well in developer tools and power-user interfaces where visual noise should be low. For consumer-facing apps, the richer variants with titles and descriptions are usually more appropriate.
Loading & Async

Toasts that communicate pending operations, success confirmation, and failure states — keep users informed during async workflows.

toast-loading
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="toast info loading">
3 <span class="spinner">
4 </span>
5 <div class="content">
6 <strong>
7 Uploading...
8 </strong>
9 <p>
10 Please wait while we process your file.
11 </p>
12 </div>
13 </div>
14 <div class="toast success">
15 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
16 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
17 <polyline points="22 4 12 14.01 9 11.01"/>
18 </svg>
19 <div class="content">
20 <strong>
21 Upload complete
22 </strong>
23 <p>
24 video-final.mp4 is ready.
25 </p>
26 </div>
27 </div>
28 <div class="toast error">
29 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
30 <circle cx="12" cy="12" r="10"/>
31 <line x1="15" y1="9" x2="9" y2="15"/>
32 <line x1="9" y1="9" x2="15" y2="15"/>
33 </svg>
34 <div class="content">
35 <strong>
36 Upload failed
37 </strong>
38 <p>
39 Network error. Tap to retry.
40 </p>
41 </div>
42 </div>
43</div>
preview
Accessibility

Toasts must be announced to assistive technologies and remain keyboard reachable. Without the right ARIA attributes, transient notifications are easy for screen-reader users to miss.

  • Wrap each toast in a container with role="status" for non-critical updates or role="alert" for errors.
  • Add aria-live="polite" (success/info) or aria-live="assertive" (error/warning) so screen readers announce them.
  • Provide visible focus styles and a keyboard-operable close button. Do not rely solely on auto-dismiss.
  • Give the close button an explicit aria-label="Dismiss notification" when the visible text is only an icon.
  • Keep toast text concise. A title + one sentence is usually enough; move longer content into a dedicated page or dialog.
  • Respect reduced motion: disable entrance/exit animations when prefers-reduced-motion: reduce is active.
Animations & Motion

A toast should feel alive without stealing attention. The canonical micro-interaction pairs a slide-in from the viewport edge with a shrinking progress bar that communicates remaining dwell time. Keep easing snappy—around 300–450 ms—and let the element exit with the same directional logic so the flow feels predictable.

toast-animations
Live
untitled.html
HTML
1<div class="wrap">
2 <button id="trigger" class="trigger" type="button">
3 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4 <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>
5 <path d="M13.73 21a2 2 0 0 1-3.46 0"/>
6 </svg>
7 Show notification
8 </button>
9 <div id="stack" class="stack">
10 </div>
11 <template id="toast-template">
12 <div class="toast" role="status" aria-live="polite">
13 <svg class="icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
14 <polyline points="20 6 9 17 4 12"/>
15 </svg>
16 <div class="content">
17 <strong>
18 Success
19 </strong>
20 <span>
21 Your changes were saved.
22 </span>
23 </div>
24 <button class="close" aria-label="Dismiss">
25 &times;
26 </button>
27 <div class="progress" aria-hidden="true">
28 </div>
29 </div>
30 </template>
31</div>
preview
📝

note

Respect prefers-reduced-motion: reduce by disabling slide and scale transforms and setting animation: none. Users with vestibular disorders may experience nausea from off-screen motion, so make the reduced-motion fallback instant and equivalent in meaning.

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.