StyleSheet
Registry of InlineStyle rules. #Diagram
Constructor
ts
new StyleSheet()Properties
This class exposes no public properties.
Methods
.set(name: string, style: InlineStyle)
| Argument | Type | Description |
|---|---|---|
name | string | Rule name or selector. |
style | InlineStyle | Inline style instance. |
Adds or updates a rule in the stylesheet. Returns this.
.get(name: string)
Returns the InlineStyle for the given name, or undefined.
| Argument | Type | Description |
|---|---|---|
name | string | Rule name or selector. |
.remove(name: string)
Removes a rule by name. Returns this.
| Argument | Type | Description |
|---|---|---|
name | string | Rule 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());