question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting SASS error when creating new theme

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:26 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
mattiLeBlanccommented, Oct 29, 2017

I had a similar issue, which occurred because when I apply the color, I forgot to use mat-color.

@import '../../../../node_modules/@angular/material/_theming';
@include mat-core();

$podshark-light-primary: mat-palette($mat-grey, A100,A100,A100); //white
$podshark-light-accent:  mat-palette($mat-pink, A200, A100, A400);
$podshark-light-warn:    mat-palette($mat-red);

$custom-theme: mat-light-theme( $podshark-light-primary, $podshark-light-accent, $podshark-light-warn);

@mixin mat-form-field($theme ) {

  $primary: map-get( $theme, primary);
  $warn: map-get($theme, warn);

  mat-form-field {
    .mat-form-field-underline {
      background-color: $primary; // -> THIS IS WRONG!
      background-color: mat-color($primary); // -> THIS IS RIGHT :)
    }
    .mat-form-field-placeholder {
      color: mat-color($primary);
    }
  }
}

@mixin custom-theme( $theme ) {
  @include mat-form-field( $theme );
}

4reactions
guysenpaicommented, May 15, 2017

I have the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 13: Angular Material 13 custom theme throwing error
It seems that material needs at least hue: 100, hue 500 and hue 700 (probably for functions like lighter etc).
Read more >
New version 1.2.5 not compiling properly - WordPress.org
The problem seems to be that the plugin doesn't create its necessary “cache” directory. If you create that directory it seems to work...
Read more >
Deprecating Sass for Shopify Themes
Get details on why Shopify is deprecating Sass in themes and how you can adjust your workflow and custom themes to adapt to...
Read more >
Issues when building theme - Forums - Liferay
Hi,. I am facing issues with my environment, I guess. I am trying to create a new theme, but I am receiving errors...
Read more >
Customize Styling | Mendix Documentation
Create a new file theme/web/company-header.scss. In the new file create a class with a selector name ( .company-header ) and include a CSS ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found