Create percentage variable

collection.createPercentageVariable(name, value)

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

Syntax

collection.createPercentageVariable(
name: string,
value: number | {{VARIABLE_REFERENCE}} | {{CUSTOM_VALUE}},
options?: {
mode?: {{VARIABLE_MODE}}
}
): Promise<PercentageVariable>

Parameters

  • name : string - Name of the variable
  • value: number | PercentageVariable | CustomValue - Value of the variable.
  • options: object - Optional parameters for the variable.

Returns

Promise<PercentageVariable>

A Promise that resolves to a PercentageVariable object.

Example

// Get Collection
const collection = await webflow.getDefaultVariableCollection()
// Create Percentage Variable of 50 Percent
const myPercentageVariable = await collection?.createPercentageVariable("50%", 50)
console.log(myPercentageVariable)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyVariablesAnyMainCanvasDesign