Alerts
Default Alert
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. 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 background color use class
.bg-*
, .text-white
<div class="alert alert-primary" role="alert">
<strong>Primary - </strong> A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
<strong>Secondary - </strong> A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
<strong>Success - </strong> A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
<strong>Error - </strong> A simple danger alert—check it out!
</div>
<div class="alert alert-warning text-bg-warning border-0" role="alert">
<strong>Warning - </strong> A simple warning alert—check it out!
</div>
<div class="alert alert-info text-bg-info border-0" role="alert">
<strong>Info - </strong> A simple info alert—check it out!
</div>
<div class="alert alert-light text-bg-light border-0" role="alert">
<strong>Light - </strong> A simple light alert—check it out!
</div>
<div class="alert alert-dark border-0 mb-0" role="alert">
<strong>Dark - </strong> A simple dark alert—check it out!
</div>
Dismissing Alerts
Add a dismiss button and the .alert-dismissible
class, which adds
extra padding to the right of the alert
and positions the .btn-close
button.
<div class="alert alert-primary alert-dismissible text-bg-primary border-0 fade show" role="alert">
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Primary - </strong> A simple primary alert—check it out!
</div>
<div class="alert alert-secondary alert-dismissible text-bg-secondary border-0 fade show" role="alert">
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Secondary - </strong> A simple secondary alert—check it out!
</div>
<div class="alert alert-success alert-dismissible text-bg-success border-0 fade show" role="alert">
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Success - </strong> A simple success alert—check it out!
</div>
<div class="alert alert-danger alert-dismissible text-bg-danger border-0 fade show" role="alert">
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Error - </strong> A simple danger alert—check it out!
</div>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Warning - </strong> A simple warning alert—check it out!
</div>
<div class="alert alert-info alert-dismissible fade show" role="alert">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Info - </strong> A simple info alert—check it out!
</div>
<div class="alert alert-light alert-dismissible fade show" role="alert">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Light - </strong> A simple light alert—check it out!
</div>
<div class="alert alert-dark alert-dismissible fade show mb-0" role="alert">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<strong>Dark - </strong> A simple dark alert—check it out!
</div>
Custom Alerts
Display alert with transparent background and with contextual text color. Use
classes
.bg-white
, and .text-*
. E.g. bg-white
text-primary
.
<div class="alert alert-primary bg-transparent text-primary" role="alert">
This is a <strong>primary</strong> alert—check it out!
</div>
<div class="alert alert-secondary bg-transparent text-secondary" role="alert">
This is a <strong>secondary</strong> alert—check it out!
</div>
<div class="alert alert-success bg-transparent text-success" role="alert">
This is a <strong>success</strong> alert—check it out!
</div>
<div class="alert alert-info bg-transparent text-info" role="alert">
This is a <strong>info</strong> alert—check it out!
</div>
<div class="alert alert-warning bg-transparent text-warning" role="alert">
This is a <strong>warning</strong> alert—check it out!
</div>
<div class="alert alert-danger bg-transparent text-danger" role="alert">
This is a <strong>danger</strong> alert—check it out!
</div>
<div class="alert alert-light bg-transparent text-light" role="alert">
This is a <strong>light</strong> alert—check it out!
</div>
<div class="alert alert-dark bg-transparent text-dark" role="alert">
This is a <strong>dark</strong> alert—check it out!
</div>
Link Color
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>
Icons with Alerts
You can also include additional elements like icons, heading, etc along side the actual message.
<div class="alert alert-success" role="alert">
<i class="ri-check-line me-1 align-middle font-16"></i> This is a <strong>success</strong> alert - check it out!
</div>
<div class="alert alert-danger" role="alert">
<i class="ri-close-circle-line me-1 align-middle font-16"></i> This is a <strong>danger</strong> alert - check it out!
</div>
<div class="alert alert-warning" role="alert">
<i class="ri-alert-line me-1 align-middle font-16"></i> This is a <strong>warning</strong> alert - check it out!
</div>
<div class="alert alert-info" role="alert">
<i class="ri-information-line me-1 align-middle font-16"></i> This is a <strong>info</strong> alert - check it out!
</div>
Additional content
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
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.
<div class="alert alert-success" role="alert">
<h4 class="alert-heading">Well done!</h4>
<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>
<hr>
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</div>
Live Alert
Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.
<div id="liveAlertPlaceholder"></div>
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>