style.getProperties(options?)

Retrieves the CSS properties of the specified Style Object. See the style properties list for an index of CSS properties that can be set on a Style.

Syntax

1style.getProperties(options?: BreakpointAndPseudo): Promise<PropertyMap>

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<PropertyMap>

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

Example

1// Get selected element
2const element = await webflow.getSelectedElement()
3
4if (element?.styles) {
5
6 // Get Element Styles
7 const styles = await element.getStyles()
8
9 // Initialize an empty object to store all properties
10 const allProperties: { [key: string]: any } = {};
11
12 for (let style of styles) {
13 // Use string type for styleName
14 const styleName: string = await style.getName();
15 const breakpoint : BreakpointAndPseudo = {breakpoint: 'xxl'}
16 const properties = await style.getProperties(breakpoint);
17 allProperties[styleName] = properties;
18 }
19
20 console.log(allProperties);
21
22}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAn
Built with