Skip to the page content

Alerts

Messages in the page, from plain alerts to countdowns and error lists.

Bootstrap docs

15 alert types

Contextual colors

Bootstrap's eight alert classes as they come, with no extra markup. Each picks up the palette, and the text color is mixed toward the body text so it stays readable on its tint.

Bootstrap
Show code
<div class="alert alert-primary" role="alert">Customers can now pay invoices in euros.</div>
<div class="alert alert-secondary" role="alert">…</div>
<div class="alert alert-success" role="alert">…</div>
<div class="alert alert-danger" role="alert">…</div>
<div class="alert alert-warning" role="alert">…</div>
<div class="alert alert-info" role="alert">…</div>
<div class="alert alert-light" role="alert">…</div>
<div class="alert alert-dark" role="alert">…</div>

Dismissible alert

Bootstrap's .alert-dismissible with the alert script: the close button fades the alert out and removes it. The page header button brings them back.

Bootstrap
Show code
<div class="alert alert-warning alert-dismissible fade show" role="alert">
  Your card on file expires next month.
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>

Alert with icon

Bootstrap's flex utilities put an icon beside the message. The icon is hidden from screen readers, so the words carry the meaning.

Bootstrap
Show code
<div class="alert alert-info d-flex align-items-center gap-2" role="alert">
  <i class="bi bi-info-circle-fill flex-shrink-0" aria-hidden="true"></i>
  <div>Orders placed after 2:00 pm ship the next working day.</div>
</div>

Heading and link

Bootstrap's .alert-heading, a divider and .alert-link, which takes the alert's own color and weight.

Bootstrap
Show code
<div class="alert alert-success" role="alert">
  <h3 class="alert-heading">Max plan approved</h3>
  <p>Highpoint Outfitters moves to Max on November 1.</p>
  <hr>
  <p class="mb-0">Send them the <a href="#" class="alert-link">welcome pack</a>.</p>
</div>

Alert with list

A heading and a plain list inside a Bootstrap alert, for a short set of related points.

Bootstrap
Show code
<div class="alert alert-warning" role="alert">
  <h3 class="alert-heading">Before the Avocet Robotics rollout on Monday</h3>
  <ul class="mb-0">
    <li>Set up 12 team member accounts</li>
    <li>Send 12 app download links</li>
  </ul>
</div>

Solid alert

A filled block for the one message on a page that must not be missed. The fill is the alert color deepened, so the light text on it stays readable.

Style

Preview mode. Customers can't see these changes yet.

Show code
<div class="alert alert-danger basalt-alert basalt-alert-solid" role="alert">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-wifi-off"></i></span>
  <p class="basalt-alert-text">The app is offline. Visit updates are queued.</p>
</div>

Outlined alert

A border and colored icon on the card's own surface. Good for dense screens where a filled block would shout.

Style

Invite sent to dana@lakesideapparel.com.

Price edits are locked while the sale is running.

Show code
<div class="alert alert-success basalt-alert basalt-alert-outline" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-envelope-check"></i></span>
  <p class="basalt-alert-text">Invite sent to dana@lakesideapparel.com.</p>
</div>

Accent border alert

A plain surface with a thick edge in the alert's color. Quieter than a full tint, so it suits pages that already have a lot of color.

Style

Tip

Blazers shown with sunglasses sell 30% better than blazers on their own.

Show code
<div class="alert alert-primary basalt-alert basalt-alert-accent" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-lightbulb"></i></span>
  <div class="basalt-alert-body">
    <p class="basalt-alert-title">Tip</p>
    <p class="basalt-alert-text">Blazers shown with sunglasses sell 30% better than blazers on their own.</p>
  </div>
</div>

Compact alert

A one-line alert for tight spots: inside a card, under a field, above a table. Same colors and icon slot as the full alert at a smaller size.

Layout
Sculpted Shoulder Blazer $1,290.00

Only 3 left in stock

Synced with your accounting app 2 minutes ago

Prices include sales tax

This discount code expired on September 1

Show code
<div class="alert alert-warning basalt-alert basalt-alert-compact" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-hourglass-split"></i></span>
  <p class="basalt-alert-text">Only 3 left in stock</p>
</div>

Page banner

A full-width strip for the top of a page, holding one announcement at a time. Arrow buttons page through them, the count says where you are, and closing it takes the whole strip away.

Layout

Draped Column Gown is in the store. $2,150, with a free pocket square until the end of October. See what's new

1 / 3

Checkout is paused on Sunday from 2:00 to 3:00 am while payments are upgraded.

Show code
<div class="basalt-banner" role="region" aria-roledescription="announcements"
     aria-label="Store announcements" data-basalt-banner>
  <span class="basalt-banner-icon" aria-hidden="true"><i class="bi bi-megaphone"></i></span>
  <div class="basalt-banner-slides" aria-live="polite">
    <p class="basalt-banner-slide"><strong>Draped Column Gown is in the store.</strong> <a href="#">See what's new</a></p>
    <p class="basalt-banner-slide" hidden><strong>Free shipping this week.</strong></p>
  </div>
  <div class="basalt-banner-pager">
    <button type="button" class="basalt-banner-nav" data-basalt-banner-prev aria-label="Previous announcement">
      <i class="bi bi-chevron-left" aria-hidden="true"></i></button>
    <span class="basalt-banner-count" data-basalt-banner-count>1 / 2</span>
    <button type="button" class="basalt-banner-nav" data-basalt-banner-next aria-label="Next announcement">
      <i class="bi bi-chevron-right" aria-hidden="true"></i></button>
  </div>
  <button type="button" class="basalt-banner-close" data-basalt-banner-close aria-label="Close announcements">
    <i class="bi bi-x-lg" aria-hidden="true"></i></button>
</div>

<!-- Tones: basalt-banner-warning, --danger, --success -->

Alert group

Several notices folded into one block, worst first. The header counts them by color, Show all opens the rest, and each one can be cleared on its own or all together.

Layout

4 notices

  • Card payment failed on order #1058.

  • Leather Trench Coat stock is down to 3 units.

  • Two estimates are waiting for approval.

  • Live training for Highpoint Outfitters moved to Friday.

Show code
<section class="basalt-alert-group" aria-labelledby="notices-title" data-basalt-alert-group>
  <header class="basalt-alert-group-head">
    <h3 class="basalt-alert-group-title" id="notices-title">
      <span data-basalt-alert-group-count>2</span> notices</h3>
    <span class="basalt-alert-group-tally" data-basalt-alert-group-tally></span>
    <div class="basalt-alert-group-tools">
      <button type="button" data-basalt-alert-group-toggle aria-expanded="false">Show all</button>
      <button type="button" data-basalt-alert-group-clear>Clear all</button>
    </div>
  </header>
  <ul class="basalt-alert-group-list">
    <!-- Worst first. data-tone feeds the tally. -->
    <li class="alert alert-danger basalt-alert basalt-alert-compact" data-tone="danger">
      <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-credit-card"></i></span>
      <p class="basalt-alert-text">Card payment failed on order #1058.</p>
      <button type="button" class="basalt-alert-close" data-basalt-alert-close
              aria-label="Clear: card payment failed"><i class="bi bi-x-lg" aria-hidden="true"></i></button>
    </li>
  </ul>
  <div class="basalt-alert-group-empty" data-basalt-alert-group-empty hidden>All clear.</div>
</section>

Expandable alert

A short headline with the detail folded away. The toggle is Bootstrap's own collapse, so the extra content opens smoothly and the button reports whether it is open.

Interactive

Deliveries to the north are running a day late

Snow has closed two hubs. Four open orders are affected.

  • #1042Sandra FranklinThursday
  • #1047Cheryl SorensenThursday
  • #1051Travis DaughertyFriday
  • #1053Christopher VanceFriday
Email these customers
Show code
<div class="alert alert-warning basalt-alert basalt-alert-expand" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-truck"></i></span>
  <div class="basalt-alert-body">
    <p class="basalt-alert-title">Deliveries to the north are running a day late</p>
    <button class="basalt-alert-toggle" type="button" data-bs-toggle="collapse"
            data-bs-target="#late-orders" aria-expanded="false" aria-controls="late-orders">
      Show the orders <i class="bi bi-chevron-down" aria-hidden="true"></i>
    </button>
    <div class="collapse" id="late-orders">
      <ul class="basalt-alert-rows">
        <li><span class="basalt-alert-mono">#1042</span><span>Sandra Franklin</span><span>Thursday</span></li>
      </ul>
    </div>
  </div>
</div>

Error summary alert

The alert a form shows when saving fails. It takes focus, lists every problem as a link to its field, and shrinks as each one is fixed. Try saving the empty form.

Interactive
Show code
<!-- Shown when saving fails. Focus moves here so the problems are read out. -->
<div class="alert alert-danger basalt-alert basalt-alert-summary"
     tabindex="-1" role="alert" aria-labelledby="summary-title">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-exclamation-octagon"></i></span>
  <div class="basalt-alert-body">
    <p class="basalt-alert-title" id="summary-title">Fix 2 things before saving</p>
    <ul class="basalt-alert-list">
      <li><a href="#product-name">Enter a product name</a></li>
      <li><a href="#product-price">Enter a price, like 149.00</a></li>
    </ul>
  </div>
</div>

Progress alert

A long job reported in the page instead of a spinner. The bar and the row count move together, screen readers hear each quarter, and the alert changes color and wording when the job ends.

Interactive

Ready to import the autumn range

autumn-range.csv, 480 products

0 of 480 rows0%

Show code
<div class="alert alert-primary basalt-alert basalt-alert-as-progress" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-cloud-arrow-up"></i></span>
  <div class="basalt-alert-body">
    <p class="basalt-alert-title">Importing products</p>
    <p class="basalt-alert-text">autumn-range.csv, 480 products</p>
    <div class="basalt-alert-progress" role="progressbar" aria-label="Import progress"
         aria-valuemin="0" aria-valuemax="100" aria-valuenow="65">
      <span class="share-65"></span>
    </div>
    <p class="basalt-alert-meta"><span>312 of 480 rows</span><span>65%</span></p>
  </div>
  <div class="basalt-alert-actions">
    <button type="button" class="btn btn-sm basalt-alert-btn basalt-alert-btn-ghost">Cancel</button>
  </div>
</div>

Action alert with countdown

An alert that carries the next step with it. The low stock notice places a reorder in place, then turns into a confirmation that closes itself. The countdown stops while the pointer or keyboard focus is on it, and Keep open stops it for good.

Interactive

Shield Sunglasses stock is low

6 pairs are left in the warehouse, about four days of orders at the current pace.

Show code
<div class="alert alert-success basalt-alert basalt-alert-action" role="status">
  <span class="basalt-alert-icon" aria-hidden="true"><i class="bi bi-check2-circle"></i></span>
  <div class="basalt-alert-body">
    <p class="basalt-alert-title">Reorder placed</p>
    <p class="basalt-alert-text">60 pairs of Shield Sunglasses arrive on Thursday.</p>
    <!-- Counts down, pauses on hover and focus, closes at zero -->
    <div class="basalt-alert-timer" data-basalt-alert-timer="8">
      <span class="basalt-alert-timer-track" aria-hidden="true"><span class="basalt-alert-timer-bar"></span></span>
      <span class="basalt-alert-timer-text" data-basalt-alert-left>Closes in 8 s</span>
      <button type="button" class="basalt-alert-keep" data-basalt-alert-keep>Keep open</button>
    </div>
  </div>
  <div class="basalt-alert-actions">
    <button type="button" class="btn btn-sm basalt-alert-btn">Undo</button>
    <button type="button" class="btn btn-sm basalt-alert-btn basalt-alert-btn-ghost">View order</button>
  </div>
  <button type="button" class="basalt-alert-close" data-basalt-alert-close aria-label="Dismiss">
    <i class="bi bi-x-lg" aria-hidden="true"></i>
  </button>
</div>

<script>
  // Starts the countdown; the alert closes itself at zero.
  basaltAlert.timer(document.querySelector('.basalt-alert-action'));
</script>