APIsChangelog
Log In

Create color variable

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

collection.createColorVariable(name: string,value: string | ColorVariable): Promise<ColorVariable>

Parameters

  • name : string - Name of the variable
  • value: string - Value of the variable. Value can be a string in one of three formats:
    • Color Name
    • Color rgb hex value
    • Color rgba hex value

Returns

Promise<Variable>

A Promise that resolves to a Variable object.

.### Example

// Get Collection
const collection = await webflow.getDefaultVariableCollection()

// Create Color Variable with a HEX Codre
const myColorVariable = await collection?.createColorVariable("primary", "#ffcc11")
console.log(myColorVariable)