Element representation of target.
Name of the CSS variable to remove.
Optionaltarget: null | Target = document.documentElementOptional Element, EventTarget, or CSS selector.
Element representation of the specified target.
InvalidCssVarError if the CSS variable could not be removed from target.
elements!InvalidElementError if the specified target wasn't found.
HTML (Before)
<style>:root { --color-fg: green; --is-small: false }</style>
<button id="example" style="--color-bg: blue; font-size: 18px;">Example</button>
Remove from Element
const element = findElement("#example")!;
removeCssVar("color-bg", element);
Remove from :root
const element = findElement("#example")!;
removeCssVar("color-fg");
HTML (After)
<style>:root { --is-small: false }</style>
<button id="example" style="font-size: 18px;">Example</button>
Removes the CSS variable
namefrom the optionally specifiedtarget.If no
targetis specified, thedocumentElement(i.e.:root) is used.