Alerts
Contextual feedback messages for user actions
Basic Alerts
A simple primary alert—check it out!
A simple secondary alert—check it out!
A simple success alert—check it out!
A simple danger alert—check it out!
A simple warning alert—check it out!
A simple info alert—check it out!
A simple light alert—check it out!
A simple dark alert—check it out!
<div class="alert alert-primary" role="alert">
A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
A simple danger alert—check it out!
</div>
Alerts with Icons
An example alert with an icon
An example success alert with an icon
An example warning alert with an icon
An example danger alert with an icon
<div class="alert alert-primary d-flex align-items-center" role="alert">
<i class="bi bi-info-circle me-2"></i>
<div>An example alert with an icon</div>
</div>
<div class="alert alert-success d-flex align-items-center" role="alert">
<i class="bi bi-check-circle me-2"></i>
<div>An example success alert with an icon</div>
</div>
Dismissible Alerts
Holy guacamole! You should check in on some of those fields below.
Heads up! This alert needs your attention, but it's not super important.
Well done! You successfully read this important alert message.
<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="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
Alerts with Additional Content
Well done!
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.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
Information
This is an info alert with additional content and actions.
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<p>Aww yeah, you successfully read this important alert message.</p>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities.</p>
</div>
Live Alert Examples
const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
const appendAlert = (message, type) => {
const wrapper = document.createElement('div')
wrapper.innerHTML = [
`<div class="alert alert-${type} alert-dismissible" role="alert">`,
` <div>${message}</div>`,
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
'</div>'
].join('')
alertPlaceholder.append(wrapper)
}