Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 5 hover hover-focus hover-focus-active not working

recently I upgraded my angular app from bootstrap 4.5 to 5.1.1 by editing package.json file.

"dependencies": {
"bootstrap": "5.1.1"...

I faced below issue after upgrading.

ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined mixin.
   ╷
7  │ ┌   @include hover {
8  │ │     color: $color;
9  │ │     background-color: $focus-background;
10 │ │     border-color: $focus-border;
11 │ └   }

Any idea?

like image 343
Nalin Kularathna Avatar asked Feb 10 '26 17:02

Nalin Kularathna


1 Answers

Issue was hover hover-focus hover-focus-active mixins deprecated in bootstrap 4 and remove in bootstrap 5. So if you are using those need to initialize the start of the file you are using them.

https://raw.githubusercontent.com/twbs/bootstrap/v4-dev/scss/mixins/_hover.scss

@mixin hover-focus-active() {
&:hover,
&:focus,
&:active {
@content;
}
}

@mixin bmd-hover-focus-active {
// add the .active to the whole mix of hover-focus-active
&.active {
  @content;
}
@include hover-focus-active() {
  @content;
}
}

like that define the all mixins

like image 132
Nalin Kularathna Avatar answered Feb 15 '26 14:02

Nalin Kularathna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!