Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Bs5 Alerts in Bootstrap

Bs5 Alerts in Bootstrap

In Bootstrap 5 (BS5), alerts are components used to provide feedback messages like success, warning, error, or information messages. They are styled using contextual classes and can be made dismissible.


? Basic Alert

<div class="alert alert-primary" role="alert">  This is a primary alert—check it out!</div>

? Alert Contextual Classes

Use different classes for different types of alerts:

ClassPurpose
alert-primaryInformational alert
alert-secondaryLess emphasis
alert-successSuccess message
alert-dangerError or danger alert
alert-warningWarning alert
alert-infoInformational alert
alert-lightSubtle info
alert-darkDark themed info

? Dismissible Alert

<div class="alert alert-warning alert-dismissible fade show" role="alert">  <strong>Warning!</strong> You should check this out.  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>
  • alert-dismissible: Adds padding and close button position

  • fade show: Adds animation

  • btn-close: Bootstrap's close button

  • data-bs-dismiss="alert": Triggers the dismiss action


?? JavaScript (Optional)

Bootstrap's alert component can be controlled with JavaScript if needed.

// Manually close alertvar myAlert = document.querySelector('.alert');var bsAlert = new bootstrap.Alert(myAlert);bsAlert.close();

? Additional Notes

  • Requires Bootstrap 5 JavaScript for dismiss functionality (via bundle or separate files).

  • Works with custom content, including links, headings, and more.

Would you like examples with links, icons, or alerts inside modals/cards?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql