In bootstrap 4 you can define and/or override default colors using the following array: (as documented here)
$theme-colors: (
"primary": #001122, /*override*/
"color-1": red, /*new color*/
"color-2": black, /*new color*/
"color-3": white /*new color*/
);
I want to make custom theme colors for different users. Users can choose different color palettes which I have defined based on the class of the body.
I made a new file to make my own styles, defining my theme colors in CSS variables in the body tag:
body {
&.color-pallette-red {
--theme-color-1: red;
--theme-color-2: black;
--theme-color-3: white;
color: var(--theme-color-1); /*red*/
}
&.color-pallette-yellow {
--theme-color-1: yellow;
--theme-color-2: black;
--theme-color-3: white;
color: var(--theme-color-1); /*yellow*/
}
}
But in this way, the bootstrap colors are of course not overwritten...
I tried to paste my CSS variables in the bootstrap array mentioned earlier, to make sure that bootstrap used my colors:
$theme-colors: (
"color-1": var(--theme-color-1),
"color-2": var(--theme-color-2),
"color-3": var(--theme-color-3)
);
But this returns Error: $color2: var(--theme-color-1) is not a color. @return mix($color-base, $color, $level * $theme-color-interval);
after running the compiling script. So bootstrap/compiler didn't recognize my CSS variables as a color...
Summarized what I want is: Change bootstrap colors based on body class. Does anyone know a way to achieve this?