Answers for "typescript css variables html"

1

typescript css variables html

const styling: { name: string, value: string }[] = [
	{ name: "--primary", value: "#123456" }
];

let styleElement: HTMLElement = document.createElement( 'style' );
let cssVariable: string = '';

for ( let i = 0; i < styling.length; i++ ) {
  cssVariable += styling[i].name + ':' + styling[i].value + ';';
}

styleElement.innerText = ':root { ' + cssVariable + ' }';
document.getElementsByTagName( 'head' )[0].appendChild( styleElement );
Posted by: Guest on October-21-2021
3

typescript css variables

document.documentElement.style.setProperty("--main-background-color", "green");
Posted by: Guest on September-11-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language