webflow.createStyle(name)

Create a new Style with a provided name.

Syntax

1webflow.createStyle(name: string): Promise<Style>

Parameters

  • name: String - The name of the style.

Returns

Promise<Style>

A Promise that resolves to a Style object.

Example

1// Create new style
2const newStyle = await webflow.createStyle(styleName);
3
4// Set properties for the style
5newStyle.setProperties({
6 "background-color": "blue",
7 "font-size": "16px",
8 "font-weight": "bold",
9});
10
11// Get Selected Element
12const selectedElement = await webflow.getSelectedElement()
13
14if (selectedElement?.styles) {
15
16 // Apply style to selected element
17 await selectedElement.setStyles([newStyle])
18
19} else {
20 console.log("No element selected")
21}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canCreateStyleBlocksPrimaryAnyCanvasDesign