Set Styles

element.setStyles(styles)

Set styles on an element.

Syntax

element.setStyles(styles: Array<Style>): Promise<null>>

Parameters

Returns

Promise<null>

A Promise that resolves to null.

Example

// Get Selected Element
const selectedElement = await Webflow.getSelectedElement()
if (selectedElement?.styles) {
// Create a new style
const newStyle = await Webflow.createStyle("MyCustomStyle");
// Set properties for the style
newStyle.setProperties({
'background-color': "blue",
'font-size': "32px",
'font-weight': "bold",
});
// Set style on selected element
selectedElement.setStyles([newStyle])
}