For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
  • Styles
      • Get all styles
      • Get style by name or path
      • Create style
      • Remove style
      • Is combo class
      • Get parent style
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • webflow.createStyle(name, options?)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer ability
StylesCreating & Retrieving Styles

Create style

Was this page helpful?
Previous

Remove style

Next
Built with

webflow.createStyle(name, options?)

Create a new style with a provided name. Provide a parent style to create a combo class.

Syntax

1webflow.createStyle(
2 name: string,
3 options?: {
4 parent?: Style
5 }
6): Promise<Style>

Parameters

  • name: String - The name of the style.
  • options: Object - An object containing the following properties:
    • parent: Style - A style object that will be the parent of the combo class 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}

Try this example

Designer ability

Designer abilityLocaleBranchWorkflowSitemode
canCreateStyleBlocksPrimaryAnyCanvasDesign