APIsChangelog
Log In
APIs

Get style properties

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

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

Parameters

  • 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<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 breakpoint : BreakpointAndPseudo = {breakpoint: 'xxl'}
    const properties = await style.getProperties(breakpoint);
    allProperties[styleName] = properties;
  }

  console.log(allProperties);

}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAn