refactor(Toast)!: move the transition to CSS with @starting-style - #707
Merged
Conversation
Toast was the last component driving its animation from JavaScript: it toggled `.fade`, forced a reflow, then juggled `.show`, `.showing` and a deprecated `.hide` class to fake an exit animation. Menu and the picker popup already express this in CSS, so Toast now does the same — `@starting-style` supplies the state to animate from, and a discrete `display` transition keeps the toast laid out until the fade-out finishes. JavaScript only toggles `.show`. BREAKING CHANGE: the `animation` option and `data-coreui-animation` are gone; add `.toast-instant` to skip the animation. The `.showing` class and the deprecated `.hide` class are gone with them, and toasts no longer take the generic `.fade` class. `isShown()` now returns `false` as soon as `hide()` is called, rather than when the fade-out ends. Ported from twbs/bootstrap#42783.
Coverage Report for CI Build 31188239378Coverage decreased (-0.005%) to 92.97%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Toast was the last component in the library driving its animation from JavaScript: it toggled
.fade, forced a reflow, then juggled.show,.showingand a deprecated.hideclass to fake an exit animation. Menu and the picker popup already express this in CSS, so Toast now does the same —@starting-stylesupplies the state to animate from, and a discretedisplaytransition keeps the toast laid out until the fade-out finishes. JavaScript only toggles.show.Compiled output:
display: blockon.showis what the toast rendered as before (the base rule only said:not(.show) { display: none }), so nothing moves on the page.Breaking
animationoption anddata-coreui-animationare gone. Add.toast-instantto skip the animation..showingand the deprecated.hideclass are gone, and toasts no longer take the generic.fadeclass. The stale "we still toggle.hidefor backwards compatibility" callout goes with them.isShown()returnsfalseas soon ashide()is called, rather than when the fade-out ends.Recorded in the v6 migration guide; docs get an Instant section and lose the
animationrow.Worth a look before merging
.toast-instantis the first-instantclass in this tree. Upstream introduced it alongside.dialog-instant/.drawer-instant, which we do not have — our Modal and Offcanvas still take animation from the.fadeclass in markup, and Tooltip still has ananimationoption. If you would rather keepanimationas the public knob for now, say so and I will drive the class from the option instead of dropping it.Not covered by tests
The unit suite exercises the JS (32 specs, incl. two new ones asserting
shown/hiddenfire synchronously for an instant toast), but it does not load the compiled CSS, so@starting-styleand the discretedisplaytransition are unverified by automation. Toast is not in the visual suite yet — a candidate when that suite grows.Unrelated observation
Every toast example in the docs (v5 and v6, and upstream too) is markup without
.show, which.toast { display: none }hides — the published page at coreui.io/bootstrap/docs/components/toasts renders empty boxes held open by.docs-example-toasts { min-height: 240px }. Not touched here; worth its own fix.Ported from twbs/bootstrap#42783.