Remove a style property

style.remove(prop, options?)

Remove a single style-property from a Style object.

Syntax

1style.removeProperty(prop: StyleProperty, 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<void>

A Promise that resolves to undefined

Example

1removeSingleStyleProperty: async (property: StyleProperty) => {
2
3 // Get Selected Element
4 const selectedElement = await webflow.getSelectedElement()
5
6 if (selectedElement?.styles) {
7
8 // Get Element Styles
9 const styles = await selectedElement.getStyles()
10 const primaryStyle = styles[0]
11 await primaryStyle.removeProperty(property)
12
13 }
14},

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyStyleBlocksAnyAnyCanvasDesign
Built with