Angular Material cant change background color with theme





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I've been tring to make a custom theme for my site but nothing will effect the background color. This is my theme:



@import '~@angular/material/theming';
@include mat-core();

$warn: mat-palette($mat-red);

$dark-primary: mat-palette($mat-grey, 900);
$dark-accent: mat-palette($mat-grey);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $warn);
@include angular-material-theme($dark-theme);

$blue-primary: mat-palette($mat-indigo, 800, 100, 100);
$blue-accent: mat-palette($mat-grey, 300, 100, 500);
$blue-theme: mat-light-theme($blue-primary, $blue-accent, $warn);

.alt-theme {
@include angular-material-theme($blue-theme);
}


I have mat-app-background on my body but what ever the first included theme is set to dark/light that is what the background color is changed too, black or white.



This was a problem at first but I'm fine with that my issue now is that it doesnt care that the alt-theme is light, the background stays black. Or if the first included theme is light and the alt is dark it will stay white.



EDIT:



So my issue was that I was adding the class to my mat-drawer-container which I guess it doesnt like, I wrapped it in a div and then everything started working as expected










share|improve this question

























  • Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

    – maerlin
    Nov 16 '18 at 14:07













  • Yes I am applying the class.

    – amedeiros
    Nov 16 '18 at 14:08











  • The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

    – amedeiros
    Nov 16 '18 at 14:17


















1















I've been tring to make a custom theme for my site but nothing will effect the background color. This is my theme:



@import '~@angular/material/theming';
@include mat-core();

$warn: mat-palette($mat-red);

$dark-primary: mat-palette($mat-grey, 900);
$dark-accent: mat-palette($mat-grey);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $warn);
@include angular-material-theme($dark-theme);

$blue-primary: mat-palette($mat-indigo, 800, 100, 100);
$blue-accent: mat-palette($mat-grey, 300, 100, 500);
$blue-theme: mat-light-theme($blue-primary, $blue-accent, $warn);

.alt-theme {
@include angular-material-theme($blue-theme);
}


I have mat-app-background on my body but what ever the first included theme is set to dark/light that is what the background color is changed too, black or white.



This was a problem at first but I'm fine with that my issue now is that it doesnt care that the alt-theme is light, the background stays black. Or if the first included theme is light and the alt is dark it will stay white.



EDIT:



So my issue was that I was adding the class to my mat-drawer-container which I guess it doesnt like, I wrapped it in a div and then everything started working as expected










share|improve this question

























  • Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

    – maerlin
    Nov 16 '18 at 14:07













  • Yes I am applying the class.

    – amedeiros
    Nov 16 '18 at 14:08











  • The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

    – amedeiros
    Nov 16 '18 at 14:17














1












1








1








I've been tring to make a custom theme for my site but nothing will effect the background color. This is my theme:



@import '~@angular/material/theming';
@include mat-core();

$warn: mat-palette($mat-red);

$dark-primary: mat-palette($mat-grey, 900);
$dark-accent: mat-palette($mat-grey);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $warn);
@include angular-material-theme($dark-theme);

$blue-primary: mat-palette($mat-indigo, 800, 100, 100);
$blue-accent: mat-palette($mat-grey, 300, 100, 500);
$blue-theme: mat-light-theme($blue-primary, $blue-accent, $warn);

.alt-theme {
@include angular-material-theme($blue-theme);
}


I have mat-app-background on my body but what ever the first included theme is set to dark/light that is what the background color is changed too, black or white.



This was a problem at first but I'm fine with that my issue now is that it doesnt care that the alt-theme is light, the background stays black. Or if the first included theme is light and the alt is dark it will stay white.



EDIT:



So my issue was that I was adding the class to my mat-drawer-container which I guess it doesnt like, I wrapped it in a div and then everything started working as expected










share|improve this question
















I've been tring to make a custom theme for my site but nothing will effect the background color. This is my theme:



@import '~@angular/material/theming';
@include mat-core();

$warn: mat-palette($mat-red);

$dark-primary: mat-palette($mat-grey, 900);
$dark-accent: mat-palette($mat-grey);
$dark-theme: mat-dark-theme($dark-primary, $dark-accent, $warn);
@include angular-material-theme($dark-theme);

$blue-primary: mat-palette($mat-indigo, 800, 100, 100);
$blue-accent: mat-palette($mat-grey, 300, 100, 500);
$blue-theme: mat-light-theme($blue-primary, $blue-accent, $warn);

.alt-theme {
@include angular-material-theme($blue-theme);
}


I have mat-app-background on my body but what ever the first included theme is set to dark/light that is what the background color is changed too, black or white.



This was a problem at first but I'm fine with that my issue now is that it doesnt care that the alt-theme is light, the background stays black. Or if the first included theme is light and the alt is dark it will stay white.



EDIT:



So my issue was that I was adding the class to my mat-drawer-container which I guess it doesnt like, I wrapped it in a div and then everything started working as expected







angular angular-material material-design material-theme angular-material-theming






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 15:03







amedeiros

















asked Nov 16 '18 at 14:02









amedeirosamedeiros

677




677













  • Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

    – maerlin
    Nov 16 '18 at 14:07













  • Yes I am applying the class.

    – amedeiros
    Nov 16 '18 at 14:08











  • The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

    – amedeiros
    Nov 16 '18 at 14:17



















  • Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

    – maerlin
    Nov 16 '18 at 14:07













  • Yes I am applying the class.

    – amedeiros
    Nov 16 '18 at 14:08











  • The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

    – amedeiros
    Nov 16 '18 at 14:17

















Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

– maerlin
Nov 16 '18 at 14:07







Are you appling the .alt-theme css class to any component or to your html body? You are just including the dark-theme. If you want to activate the .alt-theme you have to use an overlay i think

– maerlin
Nov 16 '18 at 14:07















Yes I am applying the class.

– amedeiros
Nov 16 '18 at 14:08





Yes I am applying the class.

– amedeiros
Nov 16 '18 at 14:08













The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

– amedeiros
Nov 16 '18 at 14:17





The issue is isnt that the theme isnt being applied the issue is that when it does get applied the background color doesnt change with it

– amedeiros
Nov 16 '18 at 14:17












1 Answer
1






active

oldest

votes


















0














I usually add variables like these:



$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);





share|improve this answer
























  • How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

    – amedeiros
    Nov 16 '18 at 14:16












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339350%2fangular-material-cant-change-background-color-with-theme%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I usually add variables like these:



$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);





share|improve this answer
























  • How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

    – amedeiros
    Nov 16 '18 at 14:16
















0














I usually add variables like these:



$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);





share|improve this answer
























  • How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

    – amedeiros
    Nov 16 '18 at 14:16














0












0








0







I usually add variables like these:



$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);





share|improve this answer













I usually add variables like these:



$mat-light-theme-background: (
status-bar: map_get($mat-grey, 300),
app-bar: map_get($mat-grey, 100),
background: map_get($mat-grey, A100),
hover: rgba(black, 0.04), // TODO(kara): check style with Material Design UX
card: white,
dialog: white,
disabled-button: $black-12-opacity,
raised-button: white,
focused-button: $black-6-opacity,
selected-button: map_get($mat-grey, 300),
selected-disabled-button: map_get($mat-grey, 400),
disabled-button-toggle: map_get($mat-grey, 200),
unselected-chip: map_get($mat-grey, 300),
disabled-list-option: map_get($mat-grey, 200),
);

$mat-light-theme-foreground: (
base: black,
divider: $dark-dividers,
dividers: $dark-dividers,
disabled: $dark-disabled-text,
disabled-button: rgba(black, 0.26),
disabled-text: $dark-disabled-text,
hint-text: $dark-disabled-text,
secondary-text: $dark-secondary-text,
icon: rgba(black, 0.54),
icons: rgba(black, 0.54),
text: rgba(black, 0.87),
slider-min: rgba(black, 0.87),
slider-off: rgba(black, 0.26),
slider-off-active: rgba(black, 0.38),
);

// Create the theme object (a Sass map containing all of the palettes).
$material-theme: mat-light-theme($primary, $accent, $warn);






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 14:04









CarstenCarsten

2,089919




2,089919













  • How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

    – amedeiros
    Nov 16 '18 at 14:16



















  • How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

    – amedeiros
    Nov 16 '18 at 14:16

















How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

– amedeiros
Nov 16 '18 at 14:16





How do you apply the foreground and background? I did try just adding the code to my scss file but nothing changed

– amedeiros
Nov 16 '18 at 14:16




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53339350%2fangular-material-cant-change-background-color-with-theme%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python