Issue:
After customizing the theme colors of my Angular Material application, multiple material components lost their background colors such as (MatTooltip, MatSelect, MatDialog etc...)
I followed the Official Guide to customize the theme of my app, and I'm pretty sure I followed everything to the letter, but then this weird bug happened and no suggestion on the internet helped with it.
Screenshots:
- Screenshot of
MatTooltiplosing the backgroundColor. - Screenshot of
MatSelectlosing the backgroundColor.
The theme file _theming.scss:
This is the file used for theming the app, I created two themes, light and dark, switchable by class.
@import 'node_modules/@angular/material/theming';
@include mat-core();
$light-primary : mat-palette($mat-blue, 800);
$light-accent : mat-palette($mat-amber, 500);
$light-warn : mat-palette($mat-red, 500);
$light-theme : mat-light-theme((
color: (
primary: $light-primary,
accent: $light-accent,
warn: $light-warn,
)
));
$dark-primary : mat-palette($mat-blue, 800);
$dark-accent : mat-palette($mat-amber, 800);
$dark-warn : mat-palette($mat-red, 800);
$dark-theme : mat-dark-theme((
color: (
primary: $dark-primary,
accent: $dark-accent,
warn: $dark-warn,
)
));
.light-theme {
@include angular-material-theme($light-theme);
}
.dark-theme {
@include angular-material-theme($dark-theme);
}
This file is imported in the global styles.scss. No other theme is imported.
Version info:
- Angular Version: 11
- Angular Material Version: 11