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.getVariableMode(VariableCollecton, options?)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer ability
StylesManaging Variable Modes

Get variable mode

Was this page helpful?
Previous

Get variable modes

Next
Built with

style.getVariableMode(VariableCollecton, options?)

Retrieve the variable mode applied to a style for a given variable collection. A collection can define multiple modes, but a style can have only one variable mode applied per collection.


Syntax

1style.getVariableMode(
2 collection: {{VARIABLE_COLLECTION}},
3 options?: {
4 breakpointId?: {{BREAKPOINT_ID}},
5 pseudoStateKey?: {{PSEUDO_STATE_KEY}}
6 }
7): Promise<{{VARIABLE_MODE}} | null>

Parameters

  • collection: VariableCollection - The variable collection of the variable mode.
  • options?: BreakpointAndPseudo - The breakpoint and pseudo state for the style.
    • 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" |

Returns

A Promise that resolves to a VariableMode object or null if the variable mode isn’t found.

Example

1// Get Selected Element
2const selectedElement = await webflow.getSelectedElement()
3
4 if (selectedElement?.styles) {
5 // Get Styles
6 const styles = await selectedElement.getStyles()
7 const primaryStyle = styles[0] // Get the primary style
8
9 // Get Variable Mode
10 if (primaryStyle && variableCollection) {
11 const variableMode =
12 await primaryStyle.getVariableMode(variableCollection)
13 const variableModeName = await variableMode?.getName()
14 console.log(variableModeName)
15 }
16}

Try this example

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny