$theme_color: rgb(0,170,80);
$colors: (
primary: $theme_color, //488aff
danger: #f53d3d,
light: #f4f4f4,
dark: #222, //#222,
lightgrn: #EAEDED,
footer_bg: rgba(0,0,0,0.2),
blur_bg: rgba(0,0,0,0.4),
transpnt: transparent
);
How to change $theme_color value from Components.ts file ?
is this possible?
Thanks in advance
Thanks for your reply.
I need change value like
In components.ts file
Platform.ready(()=>{
$color.primary = < new value >
});
is this possible ?
I can understand your answer. But I need update variable value at run time in variable.scss file.
I think it’s not possible…
correct ?
When you build an Ionic App the Ionic CLI invokes the Sass executable to compile .sass
and .scss
files to .css
files.
I got the answer, here my working code
variable.scss
$theme_color: rgb(0,170,80); //default
.myTheme1 {
$theme_color: red !global;
}
.myTheme2 {
$theme_color: blue !global;
}
.myTheme3 {
$theme_color: yellow !global;
}
$colors: (
primary: $theme_color,
secondary: 00aa51,
danger: #f53d3d,
light: #f4f4f4,
dark: #222, //#222,
lightgrn: #EAEDED,
footer_bg: rgba(0,0,0,0.2),
blur_bg: rgba(0,0,0,0.4),
transpnt: transparent
);
app.html
<ion-nav [root]=“rootPage” #content [class]=“myTheme”>
Component.ts
myTheme: string = “myTheme2”;
Thank you for you replies.
L3vick
October 1, 2018, 3:23pm
8
I don’t know why, but without setting mytheme = ‘whatever’ is taking the last theme and all ‘primary’ are yellow. If I delete theme3 then are blue. and when I set the theme nothing changes.
Hi L3vick, I am getting this same problem.
It is already automatically defaulting to the last theme and its colours and is not dynamically changing.
Did you manage to find a solution to this?