Set style properties

style.setProperties(props, options?)

Set multiple style-properties on a Style object.

Syntax

1style.setProperties(
2 props: {{PROPERTY_MAP}},
3 options?: {
4 breakpoint?: {{BREAKPOINT_ID}},
5 pseudo?: {{PSEUDO_STATE_KEY}},
6 variantId?: {{VARIANT_ID}}
7 }
8): Promise<void>

Parameters

  • props: PropertyMap - An object of style properties and their values. See the Style Properties reference for a list of supported properties.

  • options: StyleOptions - An object that filters properties by breakpoint, pseudo-state, and/or variant. (Optional)

    • breakpoint: BreakpointId - Identifies the responsive breakpoint to set the style properties for.

      1type BreakpointId = "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny"
    • pseudo: PseudoStateKey - Specifies a CSS pseudo-class to set the style properties for.

      1type PseudoStateKey = "noPseudo" | "nth-child(odd)" | "nth-child(even)" |
      2 "first-child" | "last-child" | "hover" | "active" | "pressed" |
      3 "visited" | "focus" | "focus-visible" | "focus-within" |
      4 "placeholder" | "empty" | "before" | "after"
    • variantId: string - The ID of the variant to target. 'base' is not a valid value. (Optional)

Returns

Promise<null>

A Promise that resolves to null

Example

1// Create a new style
2const newStyle = await webflow.createStyle('MyCustomStyle')
3
4const propertyMap : PropertyMap = {
5 'background-color': "blue",
6 'font-size': "16px",
7 'font-weight': "bold",
8 }
9const myBreakpoint: StyleOptions = { breakpoint: "medium" }
10
11// Set and save properties for the style
12await newStyle.setProperties(propertyMap, myBreakpoint);
13
14// Set properties for a specific variant
15await newStyle.setProperties(propertyMap, { variantId: 'variant-123' });

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyStyleBlocksAnyAnyCanvasDesign