style.setProperty(prop, value, options?)

Manage the CSS of a Style by setting a specific style property at the given breakpoint and pseudo-state.

Syntax

1 style.setProperty(prop: StyleProperty, value: String, options?: BreakpointAndPseudo): Promise<void>

Parameters

  • prop: StyleProperty - The name of the style property to set. See the style properties list for an index of CSS properties and their accepted value types.
  • value: string | Variable - The new value to set for the property, which can also be a variable. See the Property Map for a reference of value types for a property.
  • options : BreakpointAndPseudo {breakpoint: BreakpointId, pseudo: PseudoStateKey?}- An optional parameter to filter properties based on a breakpoint and/or pseudo-class, also known as a pseudo-state.

    • BreakpointId: "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny" - An optional identifier of the breakpoint size, also known as media query, in the Designer.
    • PseudoStateKey: "noPseudo" | "nth-child(odd)" | "nth-child(even)" | "first-child" | "last-child" | "hover" | "active" | "pressed" | "visited" | "focus" | "focus-visible" | "focus-within" | "placeholder" | "empty" | "before" | "after" - An optional identifier for the pseudo-classes of an element that can be targeted and styled using CSS.

Returns

Promise<null>

A Promise that resolves to null

Example

1// Retrieve the style by name
2const retrievedStyle = await webflow.getStyleByName(styleName);
3
4// Set Style Properties
5const options: BreakpointAndPseudo = { breakpoint: "xl", pseudo: "hover" }
6await retrievedStyle?.setProperty('background-color', 'blue', options)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyStyleBlocksAnyAnyCanvasDesign