lit-css-vars
Version:
For easily creating and sharing typed CSS vars for the lit.dev ecosystem.
41 lines (40 loc) • 1.59 kB
TypeScript
import { SingleCssVarDefinition } from './define-css-vars.js';
/**
* Set the given CSS var to the given value on the given element. Allows numeric values but converts
* them to strings (since the style.setProperty API only allows strings).
*
* @category Main
*/
export declare function setCssVarValue({ onElement, toValue, forCssVar, }: {
onElement: HTMLElement;
toValue: string | number;
forCssVar: SingleCssVarDefinition;
}): void;
/**
* Set the given property's value to the given CSS var on the given element, using
* "element.style.setProperty".
*
* @category Main
*/
export declare function applyCssVar({ onElement, forProperty, toCssVar, }: {
onElement: HTMLElement;
forProperty: string;
toCssVar: SingleCssVarDefinition;
}): void;
/**
* Read the given CSS var's value on the given element. If "includeCascade" is set to true, the
* given elements styles are computed to retrieve cascaded CSS var values. If "includeCascade" is
* false, the CSS var is read directly off the element, which will only read values from the element
* on which the CSS var was directly set.
*
* WARNING: "includeCascade: true" is less performant because it runs "globalThis.getComputedStyle".
* However, in practice I've yet to actually see this be an issue (unless you're running this in an
* immediate infinite loop but of course don't do that).
*
* @category Main
*/
export declare function readCssVarValue({ onElement, forCssVar, includeCascade, }: {
onElement: HTMLElement;
forCssVar: SingleCssVarDefinition;
includeCascade?: boolean;
}): string;