Skip to content

Rewrite alert component page with CSS-only patterns and new variants#42105

Open
anvme wants to merge 4 commits intotwbs:v6-devfrom
anvme:v6-alert-native
Open

Rewrite alert component page with CSS-only patterns and new variants#42105
anvme wants to merge 4 commits intotwbs:v6-devfrom
anvme:v6-alert-native

Conversation

@anvme
Copy link

@anvme anvme commented Mar 1, 2026

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

CSS-only dismiss replaces alert.js — faster, no JS dependency
Adds new variants

@anvme anvme requested review from a team as code owners March 1, 2026 05:33
Copy link
Member

@julien-deramond julien-deramond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @anvme
I haven’t reviewed the main content of the PR, but here are a few comments on secondary elements in the docs that I noticed while quickly scanning the changes.

You can also import JavaScript plugins individually as needed to keep bundle sizes down:

```js
import Alert from 'bootstrap/js/dist/alert'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR is accepted, we may want to keep an example of this kind of import. Instead of removing this one, we could provide an additional example following the import [...] from 'bootstrap/js/dist/[...] import.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to mention that the same modification should be applied to the Vite and Webpack guides as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants