The alert itself (initially invisible). Can be opened using a trigger. Only one should be present on a page A trigger button is required to be able to see the floating alert.
Note the aria-attributes to make this component WCAG-compliant.
<!-- Button type: solid -->
<button aria-controls="floating-alert" data-floating-alert-msg="Alert triggered message" type="button" class="vi-floating-alert-trigger vi-btn-solid vi-btn">Alert!</button>
A few triggers each showing a different message.
<!-- Button type: solid -->
<button aria-controls="floating-alert" data-floating-alert-msg="Alert triggered message" type="button" class="vi-floating-alert-trigger vi-btn-solid vi-btn">Alert!</button>
<!-- Button type: solid -->
<button aria-controls="floating-alert" data-floating-alert-msg="A second alert message" type="button" class="vi-floating-alert-trigger vi-btn-solid vi-btn">Alert!</button>
<!-- Button type: solid -->
<button aria-controls="floating-alert" data-floating-alert-msg="A third message in which you can't inject javascript <script>alert("This should not be visible")</script>" type="button" class="vi-floating-alert-trigger vi-btn-solid vi-btn">Alert!</button>
The alert itself is rendered via js (See const floatingAlertHtml in index.js).
Only one will be present on a page
The following stylesheets are required to display this component.
The following javascript is required to display this component.
Usage documentation can be found here.
Changelog
Fix
- 15 Apr 2025 - (floating-alert-v2) Fix stacking order in regard to new header.
Added
- Initial draft