Rewrite alert component page with CSS-only patterns and new variants#42105
Rewrite alert component page with CSS-only patterns and new variants#42105anvme wants to merge 4 commits intotwbs:v6-devfrom
Conversation
|
This is a good idea, but shouldn't we use the Popover API for this instead ? it would be more future-proof IMO and a simpler DOM... https://developer.mozilla.org/en-US/docs/Web/API/Popover_API |
No, alerts are rarely something that command that much attention. Plus, if I recall, the popover API places content in the top layer, just like native dialog, which is difficult to deal with. |
|
Do you think we could land it @patrickhlauke ? I'm not expert but it feels hacky to me to use a checkbox here instead of a button. I understand the idea but these are my 2cents about the close button. Few remarks about accessibility:
Aside, there are many good ideas in this PR, great work ! |
Yes you are right popover promotes the element to the top layer so it's not a good use case.
Actually if we put the role on the input as it should be, the vocalisation references a button so that's good For the Live toggle I think it's just an oversight, it looks like the checkbox is missing in the code. Still there is the issue of the missing Enter key handling... |
this is extremely hacky to me. I'd be strongly against this approach. not sure why folks think that CSS-only is inherently better/more desirable than a bit of targeted JS. (also, currently there's no focus indication on those "show alert" "buttons" https://deploy-preview-42105--twbs-bootstrap.netlify.app/docs/6.0/components/alert/#live-toggle and they can't be triggered with |
|
hey, it was just a new experience for me, so, feel free to decline it if need |
Description
Rewrite the alert component to use CSS-only patterns, removing all JavaScript dependency
Motivation & Context
Bootstrap v6 is moving toward reducing JavaScript where native HTML/CSS solutions exist
Type of changes
Remove alert.js plugin, its unit tests, and all Alert JS references from entry points (index.esm.js, index.umd.js), guide pages (Vite, Webpack, Parcel), and getting-started docs
Remove live alert JS snippet from snippets.js
CSS-only dismiss via hidden inside a — :has(.alert-dismiss:checked) hides the alert. Supports instant and animated (.fade.show) dismiss
Proxy focus ring from hidden checkbox to visible close button via :has(input:focus-visible)
New reusable accent-border mixin (scss/mixins/_accent-border.scss)
New variants: accent borders (.alert-accent-start/top/bottom), callout, compact, expandable details, split layout, progress bars (countdown/countup/indeterminate/stepped), live toggle
Update cheatsheet examples (LTR + RTL) to CSS-only dismiss pattern
Expand documentation and visual test page with demos for all new variants
Checklist
npm run lint)Live previews
Related issues
CSS-only dismiss replaces alert.js — faster, no JS dependency
Adds new variants