Alerts

Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.


Examples

Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts jQuery plugin.Use the .alert-link utility class to quickly provide matching colored links within any alert.


  <div class="alert alert-primary" role="alert">
    A simple primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-secondary" role="alert">
    A simple secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-success" role="alert">
    A simple success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-danger" role="alert">
    A simple danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-warning" role="alert">
    A simple warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-info" role="alert">
    A simple info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-light" role="alert">
    A simple light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>
  <div class="alert alert-dark" role="alert">
    A simple dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
  </div>

Dismissing

Using the alert JavaScript plugin, it's possible to dismiss any alert inline. Here's how:

  • Be sure you've loaded the alert plugin, or the compiled Bootstrap JavaScript.
  • If you're building our JavaScript from source, it requires util.js. The compiled version includes this.
  • Add a dismiss button and the .alert-dismissible class, which adds extra padding to the right of the alert and positions the .close button.
  • On the dismiss button, add the data-dismiss="alert" attribute, which triggers the JavaScript functionality. Be sure to use the <button> element with it for proper behavior across all devices.
  • To animate alerts when dismissing them, be sure to add the .fade and .show classes.
<div class="alert alert-warning alert-dismissible fade show" role="alert">
  <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

Color Variations

With the help of our utility classes and some small trick you can make 50+ alert variation

 <div class="alert bg-primary text-white alert-dismissible fade show" role="alert">
  <div class="media align-items-center">
    <i class="fas fa-thumbs-up font-size-18"></i>
    <div class="media-body pl-2">
      <strong> Well done!</strong> You successfully read this important alert message.
    </div>
  </div>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

<div class="alert bg-success text-white alert-dismissible fade show" role="alert">
  <div class="media align-items-center">
    <i class="fas fa-check font-size-18"></i>
    <div class="media-body pl-2">
      <strong> Well done!</strong> You successfully read this important alert message.
    </div>
  </div>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

<div class="alert bg-info text-white alert-dismissible fade show" role="alert">
  <div class="media align-items-center">
    <i class="fas fa-bell font-size-18"></i>
    <div class="media-body pl-2">
      <strong> Heads up!</strong> This alert needs your attention, but it's not super important.
    </div>
  </div>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

<div class="alert bg-warning text-white alert-dismissible fade show" role="alert">
  <div class="media align-items-center">
    <i class="fas fa-exclamation-circle font-size-20"></i>
    <div class="media-body pl-2">
      <strong> Warning!</strong> Better check yourself, you're not looking too good.
    </div>
  </div>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

<div class="alert bg-danger text-white alert-dismissible fade show" role="alert">
  <div class="media align-items-center">
    <i class="fas fa-exclamation-triangle font-size-20"></i>
    <div class="media-body pl-2">
      <strong> Oh snap!</strong> Changae a few things up and try submitting again.
    </div>
  </div>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

Outline Style Alerts

 <div class="alert border border-primary text-primary alert-dismissible fade show" role="alert">
    <strong> Hello World!</strong> This is default alert message box style.
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>

  <div class="alert border border-success text-success alert-dismissible fade show" role="alert">
    <strong> Well done!</strong> You successfully read this important alert message.
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>

  <div class="alert border border-info text-info alert-dismissible fade show" role="alert">
    <strong> Heads up!</strong> This alert needs your attention, but it's not super important.
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>

Alerts Contextual

<div class="alert alert-success alert-dismissible fade show" role="alert">
          <div class="media align-items-center">
            <img src="../assets/img/avatars/43.jpg" alt="" class="iconbox iconbox-sm d-flex mr-3">
            <div class="media-body">
              <div class="d-flex justify-content-between mr-4">
                <strong>Albert Heller</strong>
                <small>2 min ago</small>
              </div>
              <p class="mb-0">
                Your friend request has been accepted.
              </p>
            </div>
          </div>
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        
        <div class="alert alert-info alert-dismissible fade show" role="alert">
          <div class="media align-items-center">
            <div class="iconbox iconbox-sm bg-success text-white mr-3">
              <i class="fas fa-heart"></i>
            </div>
            <div class="media-body">
              <div class="d-flex justify-content-between mr-4">
                <strong>Albert Heller</strong>
                <small>Yesterday</small>
              </div>
              <p class="mb-0">
                Added you as a favorite member
              </p>
            </div>
          </div>
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>

Alert with additional content

<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="font-size-20 d-block mb-3">
Well done!
</strong>
<p>
Aww yeah, you successfully read this important alert message. This example text is going to run
a bit longer so that you can see how spacing within an alert works with this kind of content.
</p>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>

Alert additional content with button

<div class="alert alert-success alert-dismissible fade show" role="alert">
    <strong class="font-size-20 d-block mb-3">
      Well done!
    </strong>
    <p>
      Aww yeah, you successfully read this important alert message. This example text is going to
      run
      a bit longer so that you can see how spacing within an alert works with this kind of content.
    </p>
    <button class="btn btn-danger btn-sm" data-dismiss="alert" aria-label="Close">Dismiss</button>
    <a href="#" class="btn btn-success btn-sm">Fix Now</a>
  </div>

  <div class="alert alert-info alert-dismissible fade show" role="alert">
    <strong class="font-size-20 d-block mb-3">
      Heads up!
    </strong>
    <p>
      Aww yeah, you successfully read this important alert message. This example text is going to
      run
      a bit longer so that you can see how spacing within an alert works with this kind of content.
    </p>
    <button class="btn btn-danger btn-sm" data-dismiss="alert" aria-label="Close">Dismiss</button>
    <a href="#" class="btn btn-success btn-sm">Fix Now</a>
  </div>

  <div class="alert alert-danger alert-dismissible fade show" role="alert">
    <strong class="font-size-20 d-block mb-3">
      Warning!
    </strong>
    <p>
      Aww yeah, you successfully read this important alert message. This example text is going to
      run
      a bit longer so that you can see how spacing within an alert works with this kind of content.
    </p>
    <button class="btn btn-danger btn-sm" data-dismiss="alert" aria-label="Close">Dismiss</button>
    <a href="#" class="btn btn-success btn-sm">Fix Now</a>
  </div>