Skip to content

StyleSheet

Registry of InlineStyle rules. #Diagram

100%Ctrl + wheel to zoom

Constructor

ts
new StyleSheet()

Properties

This class exposes no public properties.

Methods

.set(name: string, style: InlineStyle)

ArgumentTypeDescription
namestringRule name or selector.
styleInlineStyleInline style instance.

Adds or updates a rule in the stylesheet. Returns this.

.get(name: string)

Returns the InlineStyle for the given name, or undefined.

ArgumentTypeDescription
namestringRule name or selector.

.remove(name: string)

Removes a rule by name. Returns this.

ArgumentTypeDescription
namestringRule name or selector.

.generate()

Generates CSS text for the entire stylesheet.

.toString()

Exports the stylesheet as a string.

Example

ts
const sheet = new StyleSheet();
sheet.set("body", new InlineStyle({ margin: "0", padding: "0" }, "boundary"))
   .set(".container", new InlineStyle({ maxWidth: "1200px", margin: "0 auto" }, "boundary"));
console.log(sheet.generate());