A set of Bootstrap 6 alerts with icons for dashboards, settings pages and app shells. It covers info, success, warning and danger messages, a rich welcome alert with actions, a "new feature" alert and a compact dark offline banner. Each alert has a solid icon tile in its theme color, a colored edge and a dismiss button.
How it works
Every alert is a plain Bootstrap 6 .alert with a theme-* class: theme-info, theme-success, theme-warning, theme-danger, theme-primary, theme-accent and theme-inverse. The theme class sets --bs-theme-bg, --bs-theme-fg and related variables, and .awi-alert reuses them. The left edge uses border-inline-start-color: var(--bs-theme-bg) and the .awi-icon tile uses the same color as its background with --bs-theme-contrast for the Bootstrap Icon. So one class change recolors the whole alert.
The warning alert holds a small .progress meter, the rich alert adds an .alert-heading and two buttons, and .awi-alert-compact turns the inverse alert into a solid dark banner.
Dismissing needs no code: each .btn-close has data-bs-dismiss="alert", and the bundle fades the alert out and removes it. The script listens for close.bs.alert on .awi-root to remember the alert and choose where focus should go. Bootstrap fires closed.bs.alert after the alert has left the page, so that listener is added to the alert itself. Focus then moves to the next dismiss button or to the restore button instead of falling back to the page body. .awi-restore (demo only) puts hidden alerts back in their original order using data-awi-index.
Customization
- Change
theme-warning(or anytheme-*class) on an.alertto recolor its background, text, edge and icon tile at once. --awi-icon-sizeon.awi-root: makes the icon tiles larger or smaller;.awi-icon-lgis the bigger variant used in the rich alert.--awi-stripeon.awi-root: sets the width of the colored left edge. Use0for a plain border.--awi-radiuson.awi-root: rounds the alert corners.- Swap the
bi-*class inside.awi-iconfor any Bootstrap Icon. widthon.awi-meter-barandaria-valuenowon.awi-meter: show a different storage level.- Replace the
setTimeoutin the.awi-retryclick handler with a real connectivity check such asfetch('/ping').
Use cases
- Admin dashboards: show info, success, warning and danger messages with colored icon tiles and dismiss buttons
- Settings pages: warn about storage limits using an alert that includes a small usage meter
- App welcome screens: greet new users with a rich alert holding a heading and two action buttons
- Offline or connection notices: display a compact dark banner with a retry button when the network drops
Accessibility
Warnings and errors use role="alert" so screen readers announce them immediately; informational messages use the politer role="status". Icons are decorative (aria-hidden="true"), so the bold lead-in text carries the meaning, not the color alone. Every dismiss button has a specific aria-label such as "Dismiss upload error". Bootstrap draws .btn-close with a CSS mask, which hides outlines, so keyboard focus shows it at full opacity. The storage meter is a labelled progressbar.
Bootstrap 6 notes
alert alert-danger from Bootstrap 5 is now alert theme-danger, alert-dismissible and the .fade .show classes are gone, and the close button simply sits inside the flex alert. Text goes in a <p>, and theme-accent and theme-inverse are new color roles. Built on 6.0.0-alpha.1, so names may still change. Icons come from Bootstrap Icons.