Skip to main content

add()

creates a new class with a list of styles

add(cssList: object, customId?: string, silent?: boolean): string;

Parameters:

  • cssList: object - mandatory, an object with a list of styles
  • customId: string - optional, a custom name of the class
  • silent: boolean - optional, if true - a new class will be created but not added to an HTML page

Returns:

A string with the name of the created class.

Example

// create a new CSS class
const cssClassName = dhx.cssManager.add({
display: "flex";
flexDirection: "column"
});

const block = document.createElement("div");
block.classList.add(cssClassName);

// or

dhx.cssManager.add({
display: "flex";
flexDirection: "column"
}, "myCustomClass");

const block = document.createElement("div");
block.classList.add("myCustomClass");

The new created styles will be added to the <head> section of the HTML document.

If the silent parameter is set to true, you need to use the update() method after add to apply the made changes to the HTML page.