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
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
        • Create number variable
        • Create color variable
        • Create font family variable
        • Create size variable
        • Create percentage variable
        • Get all variables
        • Get variable by name
        • Get variable by ID
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • collection.createColorVariable(name, value)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
Variables & CollectionsVariablesCreating & Retrieving Variables

Create color variable

Was this page helpful?
Previous

Create font family variable

Next
Built with

collection.createColorVariable(name, value)

Create a color variable with a name and value for the variable.

Once created, you can set color variables for: Text colors, Background colors, Border and text stroke colors, and Gradient color stops

Syntax

1collection.createColorVariable(
2 name: string,
3 value: string | {{VARIABLE_REFERENCE}} | {{CUSTOM_VALUE}},
4 options?: {
5 mode?: {{VARIABLE_MODE}}
6 }
7): Promise<ColorVariable>

Parameters

  • name : string - Name of the variable
  • value: string | ColorVariable | CustomValue - Value of the variable. Value can be a string in one of four formats:
    • Color Name
    • Color RGB hex value
    • Color RGBA hex value
    • Custom value
  • options: object - Optional parameters for the variable.
    • mode: VariableMode - The variable mode object. Get the variable mode by using the collection.getVariableModeByName() method.

Returns

Promise<ColorVariable>

A Promise that resolves to a ColorVariable object.

Example

1// Get Collection
2const collection = await webflow.getDefaultVariableCollection()
3
4// Create Color Variable with a HEX Codre
5const myColorVariable = await collection?.createColorVariable("primary", "#ffcc11")
6console.log(myColorVariable)

Try this example

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyVariablesAnyMainCanvasDesign