Create number variable

collection.createNumberVariable(name, value)

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

Syntax

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

Parameters

Returns

Promise<NumberVariable>

A Promise that resolves to a NumberVariable object.

Example

// Get Collection
const collection = await webflow.getDefaultVariableCollection()
// Create Number Variable of 50
const myNumberVariable = await collection?.createNumberVariable("small", 50)
console.log(myNumberVariable)
// Create a Number Variable with a Custom Value
const myCustomNumberVariable = await collection?.createNumberVariable("h1-font-size", {
type: "custom",
value: "clamp(1, 2, 2)",
})
console.log(myCustomNumberVariable)

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canModifyVariablesAnyMainCanvasDesign