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.setVariableModes(props, options?)
  • Syntax
  • Parameters
  • Returns
StylesManaging Variable Modes

Set variable modes on a style

Was this page helpful?
Previous

Remove variable mode on a style

Next
Built with

style.setVariableModes(props, options?)

Apply multiple variable modes to a style. Each variable mode belongs to a variable collection. To apply multiple variable modes, you must provide a map of variable collection IDs to their corresponding variable mode IDs.


Syntax

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

Parameters

  • props: VariableModeStylePropertyMap - A map of variable collection IDs to their corresponding variable mode IDs.

    VariableModeStylePropertyMap
    1// Example
    2const props: VariableModeStylePropertyMap = {
    3"collection-09e4110d-f4b6-45f9-3c1b-614c748a01c6": "mode-2a4f8a4e-eb9b-be56-f773-9e88c3669955",
    4"collection-b799d4ac-670a-8296-0f2c-e153c4b1b46b": "base",
    5"collection-cd77d4e3-58e8-aac2-e2e4-4f567d399c4b": "mode-f780f7e7-1b41-b353-f931-13de2c4a1234",
    6"collection-e4fba320-a8ce-aad6-a302-8f95cdac2c6a": "mode-a4a9e6df-f2a6-f5e8-97e9-59f264e37b90"
    7}
  • 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

Promise<null>

A Promise that resolves to null.

Example

1// This example gets variable modes from the style of the currently selected element, then sets them a chosen style
2
3// Get Selected Element
4const selectedElement = await webflow.getSelectedElement()
5
6if (selectedElement?.styles) {
7 // Get Styles
8 const styles = await selectedElement.getStyles()
9 const primaryStyle = styles?.[0] // Get the primary style
10 const variableModes = await primaryStyle?.getVariableModes()
11
12 // Set Variable Modes on Selected Style
13 if (variableModes) {
14 await selectedStyle?.setVariableModes(variableModes)
15 }
16}

Try this example

Designer ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyStyleBlocksAnyAnyCanvasDesign