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.

Custom Theme issue

See original GitHub issue

Bug, feature request, or proposal:

Bug? Feature request?

What is the expected behavior?

Following this: https://github.com/angular/material2/blob/master/docs/theming.md#defining-a-custom-theme I should be able to introduce a custom the in my project.

Btw current themes (coming with the lib) are working fine. I’m only getting this error with custom themes.

What is the current behavior?

On the compile (angular-cli - webpack) I’m getting:

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/assets/styles/material-theme.sass
Module build failed:
  $color: map-get($palette, $hue);
         ^
      Argument `$map` of `map-get($map, $key)` must be a map

Backtrace:
    node_modules/@angular/material/core/theming/_theming.scss:54, in function `map-get`
    node_modules/@angular/material/core/theming/_theming.scss:54, 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`
    stdin:23
      in /Projects/Jexia/WebApp/node_modules/@angular/material/core/theming/_theming.scss (line 54, column 11)
 @ ./src/assets/styles/material-theme.sass 4:14-185
 @ multi styles

What are the steps to reproduce?

My current setup:

My custom theme:

@import '~@angular/material/core/theming/all-theme'
@import 'variables'
@include md-core()

$primary: '#fab700'
$accent:  '#fab700'
$warn:    md-palette($md-red)

$theme: md-light-theme($primary, $accent, $warn)

@include angular-material-theme($theme)

My angular-cli.json (related part only):

"styles": [
      "./assets/styles/material-theme.sass"
]

Which versions of Angular, Material, OS, browsers are affected?

Angular: 2.0.0 angular-cli: 1.0.0-beta.16

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
jelbourncommented, Oct 10, 2016

Your $primary, $accent, etc. are not what the theme function is expecting. If you look at our pre-built themes as examples, you’ll see that it’s expecting one of the Material Design color palettes (such as $md-red), not just a single color. If you create a map with the same structure it will work.

5reactions
odahcamcommented, Feb 28, 2018

For anyone that is worryed about how to create these palettes, you can use tools like mcg, example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Product page issue with custom theme - WordPress.org
Hi, all. We have a custom theme and can't find a way to have the product page follow the same style as the...
Read more >
10 Common WordPress Theme Issues & How To Fix Them
We address some of the most common WordPress theme issues and provide easy ... A lot of theme developers use custom page templates...
Read more >
Custom Theme Not Working in Service
The custom theme that I have loaded into the report is reverting back to default values in the service. In the desktop my...
Read more >
Audacity Custom Theme not working(Version 3.1.0) #2043
Only Custom themes aren't working , the other ones such as 'Classic' , 'Light' , 'Dark' , 'High Contrast' has NO issue. image....
Read more >
Shopify theme & customization issues: The differences
All Shopify themes come with a base set of options that can be configured under the “Customize theme” menu accessible from the Themes...
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