Alerts

Contextual feedback messages

Bootstrap Alerts documentation share-external-link-1

Example

Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts JavaScript plugin.

<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>
<div class="alert alert-warning" role="alert">
    A simple warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
    A simple info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
    A simple light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
    A simple dark alert—check it out!
</div>

Soft styleExclusive

Use the .text-bg-*-soft class to create softer background color.

<div class="alert text-bg-primary-soft" role="alert">
    A soft primary alert—check it out!
</div>
<div class="alert text-bg-secondary-soft" role="alert">
    A soft secondary alert—check it out!
</div>
<div class="alert text-bg-success-soft" role="alert">
    A soft success alert—check it out!
</div>
<div class="alert text-bg-danger-soft" role="alert">
    A soft danger alert—check it out!
</div>
<div class="alert text-bg-warning-soft" role="alert">
    A soft warning alert—check it out!
</div>
<div class="alert text-bg-info-soft" role="alert">
    A soft info alert—check it out!
</div>
<div class="alert text-bg-light-soft" role="alert">
    A soft light alert—check it out!
</div>
<div class="alert text-bg-dark-soft" role="alert">
    A soft dark 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="javascript: void(0);" class="alert-link">an example link</a>. Give it a click if you like.
</div>
<div class="alert text-bg-primary-soft" role="alert">
    A soft primary alert with <a href="javascript: void(0);" class="alert-link">an example link</a>. Give it a click if you like.
</div>

Icons

Similarly, you can use flexbox utilities and any icons to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.

<div class="alert alert-success d-flex align-items-center" role="alert">
    <div>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="18" width="18" class="me-3"><path d="M23.39,10.53,13.46.6a2.07,2.07,0,0,0-2.92,0L.61,10.54a2.06,2.06,0,0,0,0,2.92h0l9.93,9.92A2,2,0,0,0,12,24a2.07,2.07,0,0,0,1.47-.61l9.92-9.92A2.08,2.08,0,0,0,23.39,10.53ZM11,6.42a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Zm1.05,11.51h0a1.54,1.54,0,0,1-1.52-1.47A1.47,1.47,0,0,1,12,14.93h0A1.53,1.53,0,0,1,13.5,16.4,1.48,1.48,0,0,1,12.05,17.93Z" style="fill: currentColor"/></svg>                                              
    </div>
    <div>
        An example alert with an icon
    </div>
</div>