Get variable modes

style.getVariableModes(options?)

Retrieve all variable modes applied to a style across all variable collections. Returns a map of collection IDs to their applied mode IDs.


Syntax

style.getVariableModes(
options?: {
breakpointId?: BreakpointId,
pseudoStateKey?: PseudoStateKey
}
): Promise<VariableModeStylePropertyMap>;

Parameters

  • options?: BreakpointAndPseudo - An object that lets you filter properties by breakpoint and/or pseudo-state. (Optional)

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

      type BreakpointId = "xxl" | "xl" | "large" | "main" | "medium" | "small" | "tiny"
    • 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"

Returns

A Promise that resolves to a VariableModeStylePropertyMap object containing variable modes applied to the style, keyed by variable collection ID.

VariableModeStylePropertyMap
interface VariableModeStylePropertyMap {
[variableCollectionId: string]: string;
}
// Example
{
"collection-09e4110d-f4b6-45f9-3c1b-614c748a01c6": "mode-2a4f8a4e-eb9b-be56-f773-9e88c3669955",
"collection-b799d4ac-670a-8296-0f2c-e153c4b1b46b": "base",
"collection-cd77d4e3-58e8-aac2-e2e4-4f567d399c4b": "mode-f780f7e7-1b41-b353-f931-13de2c4a1234",
"collection-e4fba320-a8ce-aad6-a302-8f95cdac2c6a": "mode-a4a9e6df-f2a6-f5e8-97e9-59f264e37b90"
}

Example

// Get selected element
const selectedElement = await webflow.getSelectedElement()
if (selectedElement?.styles) {
// Get styles
const styles = await selectedElement.getStyles()
if (styles) {
// Get the primary style
const primaryStyle = styles[0]
// Get the variable modes
const variableModes = await primaryStyle?.getVariableModes()
console.log(variableModes)
}
}

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny