Create number variable

collection.createNumberVariable(name, value)

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

Syntax

1collection.createNumberVariable(name: string, value: number | NumberVariable | CustomValue): Promise<NumberVariable>

Parameters

  • name : string - Name of the variable
  • value: number | NumberVariable | CustomValue - Value of the variable.

Returns

Promise<NumberVariable>

A Promise that resolves to a NumberVariable object.

Example

1// Get Collection
2const collection = await webflow.getDefaultVariableCollection()
3
4// Create Number Variable of 50
5const myNumberVariable = await collection?.createNumberVariable("small", 50)
6console.log(myNumberVariable)
7
8// Create a Number Variable with a Custom Value
9const myCustomNumberVariable = await collection?.createNumberVariable("h1-font-size", {
10 type: "custom",
11 value: "clamp(1, 2, 2)",
12})
13console.log(myCustomNumberVariable)

Try this example

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyVariablesAnyMainCanvasDesign