Skip to content

Function: getCssVariable() ​

ts
function getCssVariable(key, ele?): string;

Gets the value of a CSS variable on the specified element or the root element.

Parameters ​

ParameterTypeDescription
keystringThe name of the CSS variable to get.
ele?HTMLElementThe element to get the CSS variable from. If not specified, defaults to the root element.

Returns ​

string

The value of the CSS variable.

Example ​

ts
setCssVariable('--test-color', 'red')
console.log(getCssVariable('--test-color'))

Since ​

1.0.0

Released under the MIT License.