123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- ---
- title: Alerts
- description: Alert messages are used to inform users of the status of their action and help them solve any problems that might have occurred. Good design of alert modals is very important for the overall user experience of a website or app.
- bootstrapLink: components/alerts/
- ---
- ## Default markup
- Depending on the information you need to convey, you can use one of the following types of alert messages - **success**, **info**, **warning** or **danger**. Using the right type of alert modal will help draw users' attention to the message and prompt them to take action.
- ```html example vertical
- <div class="alert alert-success" role="alert">
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- <div class="alert alert-info" role="alert">
- <h4 class="alert-title">Did you know?</h4>
- <div class="text-secondary">Here is something that you might like to know.</div>
- </div>
- <div class="alert alert-warning" role="alert">
- <h4 class="alert-title">Uh oh, something went wrong</h4>
- <div class="text-secondary">Sorry! There was a problem with your request.</div>
- </div>
- <div class="alert alert-danger" role="alert">
- <h4 class="alert-title">I'm so sorry…</h4>
- <div class="text-secondary">Your account has been deleted and can't be restored.</div>
- </div>
- ```
- ```html
- <div class="alert alert-success" role="alert">
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- ```
- ## Alert links
- Add a link to your alert message to redirect users to the details they need to complete or additional information they should read.
- ```html example vertical code
- <div class="alert alert-danger m-0">
- This is a danger alert — <a href="#" class="alert-link">check it out</a>!
- </div>
- ```
- ## Dismissible alerts
- Add the `x` close button to make an alert modal dismissible. Thanks to that, your alert modal will disappear only once the user closes it.
- ```html example
- <div class="alert alert-success alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <path d="M5 12l5 5l10 -10" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-info alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <circle cx="12" cy="12" r="9" />
- <line x1="12" y1="8" x2="12.01" y2="8" />
- <polyline points="11 12 12 12 12 16 13 16" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Did you know?</h4>
- <div class="text-secondary">Here is something that you might like to know.</div>
- </div>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-warning alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <path d="M12 9v2m0 4v.01" />
- <path d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Uh oh, something went wrong</h4>
- <div class="text-secondary">Sorry! There was a problem with your request.</div>
- </div>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-danger alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <circle cx="12" cy="12" r="9" />
- <line x1="12" y1="8" x2="12" y2="12" />
- <line x1="12" y1="16" x2="12.01" y2="16" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">I'm so sorry…</h4>
- <div class="text-secondary">Your account has been deleted and can't be restored.</div>
- </div>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- ```
- ```html
- <div class="alert alert-success alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/check -->
- <svg>...</svg>
- </div>
- <div>
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- ```
- ## Alerts with icons
- Add an icon to your alert modal to make it more user-friendly and help users easily identify the message.
- ```html example
- <div class="alert alert-success" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <path d="M5 12l5 5l10 -10" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- </div>
- </div>
- <div class="alert alert-info" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <circle cx="12" cy="12" r="9" />
- <line x1="12" y1="8" x2="12.01" y2="8" />
- <polyline points="11 12 12 12 12 16 13 16" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Did you know?</h4>
- <div class="text-secondary">Here is something that you might like to know.</div>
- </div>
- </div>
- </div>
- <div class="alert alert-warning" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <path d="M12 9v2m0 4v.01" />
- <path d="M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Uh oh, something went wrong</h4>
- <div class="text-secondary">Sorry! There was a problem with your request.</div>
- </div>
- </div>
- </div>
- <div class="alert alert-danger" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <circle cx="12" cy="12" r="9" />
- <line x1="12" y1="8" x2="12" y2="12" />
- <line x1="12" y1="16" x2="12.01" y2="16" />
- </svg>
- </div>
- <div>
- <h4 class="alert-title">I'm so sorry…</h4>
- <div class="text-secondary">Your account has been deleted and can't be restored.</div>
- </div>
- </div>
- </div>
- ```
- ```html
- <div class="alert alert-success" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/check -->
- <svg>...</svg>
- </div>
- <div>
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- </div>
- </div>
- <div class="alert alert-info" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/info-circle -->
- <svg>...</svg>
- </div>
- <div>
- <h4 class="alert-title">Did you know?</h4>
- <div class="text-secondary">Here is something that you might like to know.</div>
- </div>
- </div>
- </div>
- <div class="alert alert-warning" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/alert-triangle -->
- <svg>...</svg>
- </div>
- <div>
- <h4 class="alert-title">Uh oh, something went wrong</h4>
- <div class="text-secondary">Sorry! There was a problem with your request.</div>
- </div>
- </div>
- </div>
- <div class="alert alert-danger" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/alert-circle -->
- <svg>...</svg>
- </div>
- <div>
- <h4 class="alert-title">I'm so sorry…</h4>
- <div class="text-secondary">Your account has been deleted and can't be restored.</div>
- </div>
- </div>
- </div>
- ```
- ## Alert with avatar
- Add an avatar to your alert modal to make it more personalized.
- ```html code example
- <div class="alert alert-success" role="alert">
- <div class="d-flex">
- <div>
- <span class="avatar float-start me-3"></span>
- </div>
- <div>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
- </div>
- </div>
- </div>
- <div class="alert alert-info" role="alert">
- <div class="d-flex">
- <div>
- <span class="avatar float-start me-3">JL</span>
- </div>
- <div>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
- </div>
- </div>
- </div>
- <div class="alert alert-warning" role="alert">
- <div class="d-flex">
- <div>
- <span class="avatar float-start me-3"></span>
- </div>
- <div>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
- </div>
- </div>
- </div>
- <div class="alert alert-danger" role="alert">
- <div class="d-flex">
- <div>
- <span class="avatar float-start me-3"></span>
- </div>
- <div>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
- </div>
- </div>
- </div>
- ```
- ## Alert with buttons
- Add primary and secondary buttons to your alert modals if you want users to take a particular action based on the information included in the modal message.
- ```html code example
- <div class="alert alert-success alert-dismissible" role="alert">
- <h3 class="mb-1">Some Title</h3>
- <p>Lorem ipsum Minim ad pariatur eiusmod ea ut nulla aliqua est quis id dolore minim voluptate.</p>
- <div class="btn-list">
- <a href="#" class="btn btn-success">Okay</a>
- <a href="#" class="btn">Cancel</a>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-info alert-dismissible" role="alert">
- <h3 class="mb-1">Some Title</h3>
- <p>Lorem ipsum Minim ad pariatur eiusmod ea ut nulla aliqua est quis id dolore minim voluptate.</p>
- <div class="btn-list">
- <a href="#" class="btn btn-info">Okay</a>
- <a href="#" class="btn">Cancel</a>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-warning alert-dismissible" role="alert">
- <h3 class="mb-1">Some Title</h3>
- <p>Lorem ipsum Minim ad pariatur eiusmod ea ut nulla aliqua est quis id dolore minim voluptate.</p>
- <div class="btn-list">
- <a href="#" class="btn btn-warning">Okay</a>
- <a href="#" class="btn">Cancel</a>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-danger alert-dismissible" role="alert">
- <h3 class="mb-1">Some Title</h3>
- <p>Lorem ipsum Minim ad pariatur eiusmod ea ut nulla aliqua est quis id dolore minim voluptate.</p>
- <div class="btn-list">
- <a href="#" class="btn btn-danger">Okay</a>
- <a href="#" class="btn">Cancel</a>
- </div>
- <a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- ```
- ## Important alerts
- If you want your alert to be really eye-catching, you can add a class `alert-important`.
- ```html example vertical height="20rem"
- <div class="alert alert-important alert-success alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
- <path d="M5 12l5 5l10 -10"></path>
- </svg>
- </div>
- <div>
- <h4 class="alert-title">Wow! Everything worked!</h4>
- <div class="text-secondary">Your account has been saved!</div>
- </div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-important alert-danger alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <svg xmlns="http://www.w3.org/2000/svg" class="icon alert-icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
- <circle cx="12" cy="12" r="9" />
- <line x1="12" y1="8" x2="12" y2="12" />
- <line x1="12" y1="16" x2="12.01" y2="16" />
- </svg>
- </div>
- <div>Your account has been deleted and can't be restored.</div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- ```
- ```html
- <div class="alert alert-important alert-success alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/check -->
- <svg>...</svg>
- </div>
- <div>
- Your account has been saved!
- </div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-important alert-info alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/info-circle -->
- <svg>...</svg>
- </div>
- <div>
- Here is something that you might like to know.
- </div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-important alert-warning alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/alert-triangle -->
- <svg>...</svg>
- </div>
- <div>
- Sorry! There was a problem with your request.
- </div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- <div class="alert alert-important alert-danger alert-dismissible" role="alert">
- <div class="d-flex">
- <div>
- <!-- SVG icon from http://tabler-icons.io/i/alert-circle -->
- <svg>...</svg>
- </div>
- <div>
- Your account has been deleted and can't be restored.
- </div>
- </div>
- <a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
- </div>
- ```
|