• Removes the CSS variable name from the optionally specified target.

    If no target is specified, uses documentElement (i.e. :root).

    Type Parameters

    • TN extends TagName = "*"

      Tag name of the Element representation of target.

    Parameters

    • name: `--${string}`

      Name of the CSS variable to remove.

    • Optionaltarget: null | Target<TN> = document.documentElement

      Optional Element, EventTarget, or CSS selector.

    Returns ElementOf<TN>

    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>