Element representation of target
.
Name of the CSS variable to remove.
Optional
target: 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
name
from the optionally specifiedtarget
.If no
target
is specified, usesdocumentElement
(i.e.:root
).