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

1getVariableModes(options?: BreakpointAndPseudo): Promise<VariableModeStylePropertyMap>;

Parameters

Returns

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

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

Example

1// Get selected element
2const selectedElement = await webflow.getSelectedElement()
3
4if (selectedElement?.styles) {
5 // Get styles
6 const styles = await selectedElement.getStyles()
7 if (styles) {
8 // Get the primary style
9 const primaryStyle = styles[0]
10
11 // Get the variable modes
12 const variableModes = await primaryStyle?.getVariableModes()
13 console.log(variableModes)
14 }
15}

Try this example

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny