JSFiddle - React, Tailwind, and code Playground

HTML

<div id='myDiv'></div>

CSS

#myDiv {
    --myCustomProperty:'myCustomValue';
}

JavaScript

function getStyle(el, styleProp) {
    var x = document.getElementById(el);
    if (x.currentStyle) var y = x.currentStyle[styleProp];
    else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
    return y;
}

var value = getStyle('myDiv', '--myCustomProperty');

alert(value);