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.createNumberVariable(name, value)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
Variables & CollectionsVariablesCreating & Retrieving Variables

Create number variable

Was this page helpful?
Previous

Create color variable

Next
Built with

collection.createNumberVariable(name, value)

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

Syntax

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

Parameters

  • name : string - Name of the variable
  • value: number | NumberVariable | CustomValue - Value of the variable.
  • 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<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