Skip to content

Function: addCss()

ts
function addCss(
   selector, 
   cssRules, 
   title?): void;

Add CSS rules to a stylesheet with a given title. If a stylesheet with that title does not exist, it will be created.

Parameters

ParameterTypeDefault valueDescription
selectorstringundefinedThe CSS selector to which to apply the rules.
cssRulesStylePropsundefinedAn object containing CSS rules to apply.
titlestring'sheet'The title of the stylesheet.

Returns

void

Example

ts
addCss('.my-class', { color: 'red', backgroundColor: 'blue' }, 'my-stylesheet')
console.log(document.querySelectorAll('style').length > 0)

Since

1.0.0

Released under the MIT License.