Bootstrap 5 Alerts Icons – GeeksforGeeks
Bootstrap 5 Alerts Icons are used to add icons to the alert bar to format the bar and make it more informative. To include the icon using <svg> tag we have to define its path inside the <path> tag in svg tag. We also need to specify its height and width to adjust its size according to the notification size.
Alert Icons Classes: No special classes are used in Alerts Icons. You can customize the List using Bootstrap icon classes and style them with flexbox utilities. (We must include the bootstrap 5 icons CSS file)
Alert icon Attributes(for svg tag only):
- width: To specify width inside of the icon.
- height: To specify height of icon.
- fill: To specify color of the icon usually set to currentColor.
- d: Used inside path tag to specify the path.
Syntax:
<div class="alert alert-...> // To display icon using i tag <i class="bi bi-..."></i> </div> // To display icon using svg tag <svg width="..." height="..." fill="..." class="bi bi-"> <path d="..."> </svg>
Example 1: The following code demonstrates the Alert Icons using the svg tag.
HTML
|
Output:
Example 2: The following code demonstrates multiple icons using the Bootstrap 5 Alert properties with the help of <i> tag.
HTML
|
Output:
Reference: https://getbootstrap.com/docs/5.0/components/alerts/#icons
Bootstrap 5 Alerts Icons are used to add icons to the alert bar to format the bar and make it more informative. To include the icon using <svg> tag we have to define its path inside the <path> tag in svg tag. We also need to specify its height and width to adjust its size according to the notification size.
Alert Icons Classes: No special classes are used in Alerts Icons. You can customize the List using Bootstrap icon classes and style them with flexbox utilities. (We must include the bootstrap 5 icons CSS file)
Alert icon Attributes(for svg tag only):
- width: To specify width inside of the icon.
- height: To specify height of icon.
- fill: To specify color of the icon usually set to currentColor.
- d: Used inside path tag to specify the path.
Syntax:
<div class="alert alert-...> // To display icon using i tag <i class="bi bi-..."></i> </div> // To display icon using svg tag <svg width="..." height="..." fill="..." class="bi bi-"> <path d="..."> </svg>
Example 1: The following code demonstrates the Alert Icons using the svg tag.
HTML
|
Output:
Example 2: The following code demonstrates multiple icons using the Bootstrap 5 Alert properties with the help of <i> tag.
HTML
|
Output:
Reference: https://getbootstrap.com/docs/5.0/components/alerts/#icons