components: Getting SASS error when creating new theme
I tried creating a new theme
@import '@angular/material/core/theming/all-theme';
// Include non-theme styles for core.
@include md-core();
// Define a theme.
$primary: md-palette($md-light-blue);
$accent: md-palette($md-teal, A200, A100, A400);
$theme: md-light-theme($primary, $accent);
// Include all theme styles for the components.
@include angular-material-theme($theme);
It is throwing the following error
home.style.css:8Uncaught Error: Module build failed:
undefined
^
Argument `$color` of `opacity($color)` must be a color
Backtrace:
node_modules/@angular/material/core/theming/_theming.scss:55, in function `opacity`
node_modules/@angular/material/core/theming/_theming.scss:55, in function `if`
node_modules/@angular/material/core/theming/_theming.scss:55, in function `md-color`
node_modules/@angular/material/core/theming/_theming.scss:51, in function `md-color`
node_modules/@angular/material/core/ripple/_ripple.scss:68, in mixin `md-ripple-theme`
node_modules/@angular/material/core/_core.scss:26, in mixin `md-core-theme`
node_modules/@angular/material/core/theming/_all-theme.scss:26, in mixin `angular-material-theme`
It is working fine after commenting @include md-core-theme($theme) in _all-theme.scss. But i am not sure it breaks something else.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 26 (4 by maintainers)
I had a similar issue, which occurred because when I apply the color, I forgot to use
mat-color
.I have the same issue
I was getting this type of error as well.
@s-f-a-g you would need to use the md-color method like so: @import ‘~@angular/material/core/theming/theming’; $bg-primary: md-color($primary, 700, 0.3); md-toolbar { background-color: $bg-primary; } It was giving the error, because we gave it a palette of colors, not just one color.
Hello,
I reproduced the bug, and in my case, managed to solve it. My problem was simply that a variable in my background theme was missing.
You introduced recently a new variable in the background theme, raised-button. I had my own background theme, but I hadn’t updated it with this new variable, so the compiler was not working anymore. Using the backtrace, I checked the source of the error, and found out pretty easily that angular material was trying to find a variable in my theme that was missing.
Kind regards
Here is the backtrace
@willshowell turns it was the way i defined $accent as
$accent: mat-palette($mat-deep-orange, A400, A50, A900);
it worked in an earlier version, but doesn’t seem to work anymore. i left it like this . . .
$accent: mat-palette($mat-deep-orange, A400);
seems to be ok now
it appears to be related to the mat_progress-bar-theme($theme) function in angular-material-theme($theme). if i comment it out everything works.
If someone has a hard time figuring out this problem you need to add a new variable to: $mat-light-theme-background: (…) raised-button: white
// Background palette for light themes. $mat-light-theme-background: ( status-bar: map_get($mat-grey, 300), app-bar: map_get($mat-grey, 100), background: map_get($mat-grey, 50), hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX card: white, dialog: white, disabled-button: rgba(black, 0.12), raised-button: white, );