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

Alerts & Notifications

CSSHTMLTailwindBootstrapUIIntermediate🎯Free Tools
Introduction

Alerts communicate status, feedback, and errors to users. This guide covers production-ready alert patterns in plain HTML/CSS, Tailwind CSS, and Bootstrap — including variants, dismissible alerts, banners, toasts, inline messages, outlined styles, and rich alerts with actions.

info

Use role="alert" for critical messages and aria-live="polite" for non-critical updates. Never rely on color alone to convey meaning.
Alert Variants

Success, error, warning, and info alerts with matching inline SVG icons.

variants
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="alert success" role="alert">
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 <span>
8 Settings saved successfully.
9 </span>
10 </div>
11 <div class="alert error" role="alert">
12 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
13 <circle cx="12" cy="12" r="10"/>
14 <line x1="15" y1="9" x2="9" y2="15"/>
15 <line x1="9" y1="9" x2="15" y2="15"/>
16 </svg>
17 <span>
18 Failed to save. Please try again.
19 </span>
20 </div>
21 <div class="alert warning" role="alert">
22 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
23 <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"/>
24 <line x1="12" y1="9" x2="12" y2="13"/>
25 <line x1="12" y1="17" x2="12.01" y2="17"/>
26 </svg>
27 <span>
28 Your session will expire in 5 minutes.
29 </span>
30 </div>
31 <div class="alert info" role="alert">
32 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
33 <circle cx="12" cy="12" r="10"/>
34 <line x1="12" y1="16" x2="12" y2="12"/>
35 <line x1="12" y1="8" x2="12.01" y2="8"/>
36 </svg>
37 <span>
38 A new update is available.
39 </span>
40 </div>
41</div>
preview
Dismissible Alerts

Alerts with close buttons and optional undo action. Include JavaScript to animate removal.

dismissible
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="alert success" role="alert">
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 <span class="flex-1">
8 Message sent successfully.
9 </span>
10 <button class="undo">
11 Undo
12 </button>
13 <button class="close" aria-label="Close">
14 &times;
15 </button>
16 </div>
17 <div class="alert warning" role="alert">
18 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
19 <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"/>
20 <line x1="12" y1="9" x2="12" y2="13"/>
21 <line x1="12" y1="17" x2="12.01" y2="17"/>
22 </svg>
23 <span class="flex-1">
24 Low disk space.
25 </span>
26 <button class="close" aria-label="Close">
27 &times;
28 </button>
29 </div>
30</div>
preview
Toast Notifications

Corner-positioned toast notifications with slide-in animation and optional close control.

toast
Live
untitled.html
HTML
1<div class="container">
2 <div class="toast success" role="status">
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>
8 <strong>
9 Saved!
10 </strong>
11 <p>
12 Your changes have been saved.
13 </p>
14 </div>
15 </div>
16 <div class="toast error" role="alert">
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>
23 <strong>
24 Error
25 </strong>
26 <p>
27 Could not connect to server.
28 </p>
29 </div>
30 <span class="t-close" aria-label="Close">
31 &times;
32 </span>
33 </div>
34</div>
preview
Inline Alerts

Compact inline alerts for form fields and small UI areas.

inline
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="inline error" role="alert">
3 <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
4 <circle cx="12" cy="12" r="10"/>
5 <line x1="12" y1="8" x2="12" y2="12"/>
6 <line x1="12" y1="16" x2="12.01" y2="16"/>
7 </svg>
8 Please enter a valid email address.
9 </div>
10 <div class="inline success" role="status">
11 <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
12 <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
13 <polyline points="22 4 12 14.01 9 11.01"/>
14 </svg>
15 Username is available.
16 </div>
17 <div class="inline warning" role="alert">
18 <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
19 <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"/>
20 <line x1="12" y1="9" x2="12" y2="13"/>
21 <line x1="12" y1="17" x2="12.01" y2="17"/>
22 </svg>
23 Password must be at least 8 characters.
24 </div>
25</div>
preview
Outlined Alerts

Transparent-background alerts with strong borders for subtle emphasis.

outlined
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="alert success" role="alert">
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 <span>
8 Deployment completed.
9 </span>
10 </div>
11 <div class="alert error" role="alert">
12 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
13 <circle cx="12" cy="12" r="10"/>
14 <line x1="15" y1="9" x2="9" y2="15"/>
15 <line x1="9" y1="9" x2="15" y2="15"/>
16 </svg>
17 <span>
18 Build failed — check the logs.
19 </span>
20 </div>
21 <div class="alert warning" role="alert">
22 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
23 <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"/>
24 <line x1="12" y1="9" x2="12" y2="13"/>
25 <line x1="12" y1="17" x2="12.01" y2="17"/>
26 </svg>
27 <span>
28 API rate limit at 80%.
29 </span>
30 </div>
31 <div class="alert info" role="alert">
32 <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
33 <circle cx="12" cy="12" r="10"/>
34 <line x1="12" y1="16" x2="12" y2="12"/>
35 <line x1="12" y1="8" x2="12.01" y2="8"/>
36 </svg>
37 <span>
38 Tip: use keyboard shortcuts.
39 </span>
40 </div>
41</div>
preview
Rich Alerts with Actions

Detailed alerts with title, description, icon, and action buttons.

rich
Live
untitled.html
HTML
1<div class="wrap">
2 <div class="rich success" role="alert">
3 <svg width="20" height="20" 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="body">
8 <strong>
9 Payment successful
10 </strong>
11 <p>
12 Your invoice #4921 has been paid. A receipt has been emailed to you.
13 </p>
14 </div>
15 <div class="actions">
16 <button class="primary">
17 View Receipt
18 </button>
19 <button class="secondary">
20 Dismiss
21 </button>
22 </div>
23 </div>
24 <div class="rich warning" role="alert">
25 <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
26 <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"/>
27 <line x1="12" y1="9" x2="12" y2="13"/>
28 <line x1="12" y1="17" x2="12.01" y2="17"/>
29 </svg>
30 <div class="body">
31 <strong>
32 Storage warning
33 </strong>
34 <p>
35 You have used 92% of your storage quota. Upgrade to avoid upload failures.
36 </p>
37 </div>
38 <div class="actions">
39 <button class="primary">
40 Upgrade
41 </button>
42 <button class="secondary">
43 Later
44 </button>
45 </div>
46 </div>
47</div>
preview
Accessibility

Alerts must be perceivable and understandable for all users. Pair color with icons and text, and manage focus for dynamic notifications.

  • Use role="alert" for errors and critical feedback so screen readers announce them immediately.
  • Use aria-live="polite" for success or info toasts that do not require urgent action.
  • Include a visible icon alongside color so meaning is not conveyed by color alone.
  • Provide accessible labels for dismiss buttons with aria-label="Close".
  • Move focus to the alert when it appears dynamically, then return focus after dismissal.
  • Do not auto-dismiss critical alerts without a pause control or clear persistent option.

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.