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

  • options: BreakpointAndPseudo (optional)

    An object that lets you filter properties by breakpoint and/or pseudo-state.

    1{
    2 breakpoint?: BreakpointId
    3 pseudo?: PseudoStateKey
    4}
    • BreakpointId: Identifies the responsive breakpoint to get styles for.

      1type BreakpointId = "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny"
    • PseudoStateKey: Specifies a CSS pseudo-class to get styles 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"

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
Built with