Check out example codes for "javascript get css variable". It will help you in understanding the concepts better.

Code Example 1

let docStyle = getComputedStyle(document.documentElement);

//get variable
let myVarVal docStyle.getPropertyValue('--my-variable-name');

//set variable
docStyle.setProperty('--my-variable-name', '#fff');

Learn ReactJs, React Native from akashmittal.com