For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
      • Get variable mode
      • Get variable modes
      • Set variable mode
      • Set variable modes
      • Remove variable mode
      • Remove variable modes
      • Remove all variable modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • style.getVariableModes(options?)
  • Syntax
  • Parameters
  • Returns
StylesManaging Variable Modes

Get variable modes

Was this page helpful?
Previous

Set variable mode on a style

Next
Built with

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

1style.getVariableModes(
2 options?: {
3 breakpointId?: {{BREAKPOINT_ID}},
4 pseudoStateKey?: {{PSEUDO_STATE_KEY}}
5 }
6): Promise<{{VARIABLE_MODE_STYLE_PROPERTY_MAP}}>;

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.

      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" |
      3 "visited" | "focus" | "focus-visible" | "focus-within" |
      4 "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
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