abey
January 8, 2025, 9:50am
1
Hello,
I was trying to use a custom code I found from repository and I discovered that I can’t import variables that has values for light & darkmode.
for example,
:root{
–base-color: white;
–base-variant: #e8e9ed ;
–text-color: #111528 ;
–secondary-text: #232738 ;
–primary-color: #3a435d ;
–accent-color: #0071ff ;
}
.darkmode{
–base-color: #070b1d ;
–base-variant: #101425 ;
–text-color: #ffffff ;
–secondary-text: #a4a5b8 ;
–primary-color: #3a435d ;
–accent-color: #0071ff ;
}
how do I import these variables while storing the values of the darkmode class?
I feel it’s either a missing feature/bug when I pasted in the variable import screen to import the codes
Matej
January 8, 2025, 11:35am
2
Hi,
you can only have one variable with the same name.
So, what you probably need to do is import just :root
variables, and for dark mode, include that class that you have, that will override the variables if the user switches to dark mode.
If you also want “dark mode” variables inside the variable manager, then you will need to name it differently.
I hope it’s understandable.
Matej
abey
January 8, 2025, 4:59pm
3
You mean I should include .darkmode{
–base-color: #070b1d ;
–base-variant: #101425 ;
–text-color: #ffffff ;
–secondary-text: #a4a5b8 ;
–primary-color: #3a435d ;
–accent-color: #0071ff ;
}
in the Bricks Settings > Custom Code?
Maexxx
January 8, 2025, 5:20pm
4
You can put them in the CSS of the class, as well. Then they override the others when .darkmode is added.
abey
January 8, 2025, 6:36pm
5
Importing classes can only be in json. I exported classes from bricks to see the json format, but i can’t see the values for the class.
Matej
January 8, 2025, 7:22pm
6
abey:
ou mean I should include .darkmode{
–base-color: #070b1d ;
–base-variant: #101425 ;
–text-color: #ffffff ;
–secondary-text: #a4a5b8 ;
–primary-color: #3a435d ;
–accent-color: #0071ff ;
}
in the Bricks Settings > Custom Code?
That’s right. Include this in Settings → Custom code, or under a “.darkmode” class in builder, like @Maexxx suggested.
Then, once you apply this class, all elements below it, will have those new variables.