How can I use JS to set CSS variables (:root) from a JSON file?
The format of my data is as follows:
css_json:
{
--design-white: “#f1f2f9”
--main-flamingo: “#8e24aa”
}
My variables will be used as an example like this:
color: var(–main-flamingo). Which option might be more flexible in my situation?
New contributor
tmk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.