Skip to main content

foundation-utils.insertdocumentcssrule

Home > @genesislcap/foundation-utils > insertDocumentCSSRule

insertDocumentCSSRule() function

Inserts a CSS rule into the document by creating a new style element or using an existing one with the specified ID. Returns a function that can be called to remove the rule from the document.

Signature:

insertDocumentCSSRule: (cssRule: string, styleElementId: string) => (() => void)

Parameters

Parameter

Type

Description

cssRule

string

The CSS rule to insert.

styleElementId

string

The ID of the style element to use or create.

Returns:

(() => void)

A function that removes the rule from the document.