Get style properties

style.getProperties(options?)

Retrieves the CSS properties of the specified Style Object. Additionally, you can get properties on a style for a specific breakpoint or pseudo-state.

See the style properties list for an index of CSS properties to set on a style.

Syntax

style.getProperties(
options?: {
breakpoint?: {{BREAKPOINT_ID}},
pseudo?: {{PSEUDO_STATE_KEY}},
variantId?: {{VARIANT_ID}}
}
): Promise<{{PROPERTY_MAP}}>

Parameters

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

    • breakpoint: BreakpointId - Identifies the responsive breakpoint to get styles for.

      type BreakpointId = "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny"
    • pseudo: PseudoStateKey - Specifies a CSS pseudo-class to get styles for.

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

Returns

Promise<PropertyMap>

A Promise that resolves to a PropertyMap object. A dictionary of style properties and their values.

Example

// Get selected element
const element = await webflow.getSelectedElement()
if (element?.styles) {
// Get Element Styles
const styles = await element.getStyles()
// Initialize an empty object to store all properties
const allProperties: { [key: string]: any } = {};
for (let style of styles) {
// Use string type for styleName
const styleName: string = await style.getName();
const options: StyleOptions = { breakpoint: 'xxl' }
const properties = await style.getProperties(options);
allProperties[styleName] = properties;
}
console.log(allProperties);
}

Designer ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny