Snippets Alert

Bootstrap 5 Alerts: Info, Success, Warning, Error

Dismissible alerts for info, success, warning and error states in a soft tinted style and an accent-bar style, with buttons that fire new alerts.

Bootstrap 5 No jQuery Dec 2019 2.1K views

<section class="wdw-stage wdw-alerts">
  <div class="container" style="max-width:1000px">
    <div class="text-center mb-4">
      <span class="wdw-eyebrow">Feedback</span>
      <h2 class="wdw-heading h3 mb-1">Alerts & messages</h2>
      <p class="wdw-muted mb-0">Soft and solid dismissible alerts, plus toast notifications you can fire.</p>
    </div>
    <div class="row g-4">
      <div class="col-lg-6">
        <div class="wdw-card p-4 d-grid gap-3 h-100 align-content-start">
          <h3 class="h6 fw-bold mb-0 wdw-muted">Soft</h3>
          <div class="alert alert-info soft alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="ico flex-shrink-0"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8h.01"/></svg></span>
            <div><strong class="d-block">Heads up</strong><span>A new version is available. Refresh to get the latest features.</span></div>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-success soft alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="ico flex-shrink-0"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m8.5 12.5 2.5 2.5 4.5-5"/></svg></span>
            <div><strong class="d-block">Saved</strong><span>Your changes were published to the live site.</span></div>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-warning soft alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="ico flex-shrink-0"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3 2.5 20h19L12 3Z"/><path d="M12 10v4M12 17h.01"/></svg></span>
            <div><strong class="d-block">Check your plan</strong><span>You have used 90% of your monthly storage.</span></div>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-danger soft alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="ico flex-shrink-0"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m9 9 6 6M15 9l-6 6"/></svg></span>
            <div><strong class="d-block">Payment failed</strong><span>Your card was declined. Update billing details to retry.</span></div>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
        </div>
      </div>
      <div class="col-lg-6">
        <div class="wdw-card p-4 d-grid gap-3 h-100 align-content-start">
          <h3 class="h6 fw-bold mb-0 wdw-muted">Solid with action</h3>
          <div class="alert alert-info solid alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="flex-shrink-0"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8h.01"/></svg></span>
            <div><strong class="d-block">New comment</strong><span>Maya replied to your design review.</span> <a href="#" class="alert-link ms-1 text-white fw-semibold">Open thread</a></div>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-success solid alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="flex-shrink-0"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m8.5 12.5 2.5 2.5 4.5-5"/></svg></span>
            <div><strong class="d-block">Invite sent</strong><span>Three teammates were invited to the workspace.</span> <a href="#" class="alert-link ms-1 text-white fw-semibold">Undo</a></div>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-warning solid alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="flex-shrink-0"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3 2.5 20h19L12 3Z"/><path d="M12 10v4M12 17h.01"/></svg></span>
            <div><strong class="d-block">Trial ends soon</strong><span>Your free trial finishes in 2 days.</span> <a href="#" class="alert-link ms-1 text-white fw-semibold">Upgrade</a></div>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          <div class="alert alert-danger solid alert-dismissible fade show d-flex align-items-start gap-3 mb-0" role="alert">
            <span class="flex-shrink-0"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m9 9 6 6M15 9l-6 6"/></svg></span>
            <div><strong class="d-block">Upload failed</strong><span>hero-banner.png is larger than the 10 MB limit.</span> <a href="#" class="alert-link ms-1 text-white fw-semibold">Retry</a></div>
            <button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
        </div>
      </div>
    </div>
    <div class="d-flex flex-wrap justify-content-center gap-2 mt-4" id="alert-triggers">
      <button type="button" class="btn btn-outline-primary rounded-pill" data-fire="info">Fire info</button>
      <button type="button" class="btn btn-outline-primary rounded-pill" data-fire="success">Fire success</button>
      <button type="button" class="btn btn-outline-primary rounded-pill" data-fire="warning">Fire warning</button>
      <button type="button" class="btn btn-outline-primary rounded-pill" data-fire="danger">Fire danger</button>
    </div>
    <div class="toast-container position-fixed bottom-0 end-0 p-3" id="toast-stack"></div>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.