Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 );
 
PREVIOUS NEXT
Tagged: #typescript #css #variables #html
ADD COMMENT
Topic
Name
6+6 =