variable.get(options?)

Retrieves the value of the variable.

Syntax

1variable.get(options?: {mode: VariableMode}): Promise< Value: string | Variable >;

Parameters

  • options: {mode: VariableMode} - An optional parameter to get the mode-specific value of the variable.

Returns

A Promise that resolves to the value of the variable, which depends on the variable type. If a variable’s was assigned another variable as it’s value (i.e a variable alias), the value will be the assigned variable. Additionally, if the mode parameter is provided, the value will be returned for the specified mode.

Variable TypeReturn ValueDescription
ColorVariablePromise<string | ColorVariable>Returns a color value as a string (for example, "red", "#ffcc11", "#fffcc11")
SizeVariablePromise<SizeValue | SizeVariable>Returns an object with format { value: number, unit: string } where unit can be "px", "rem", "em", "vw", "vh", "svh", "svw", or "ch"
NumberVariablePromise<number | NumberVariable>Returns a number value between 0 and 100
PercentageVariablePromise<number | PercentageVariable>Returns a number value between 0 and 100
FontFamilyVariablePromise<string | FontFamilyVariable>Returns the font family name as a string (for example, "Verdana")

Example

1// Get Collection
2const collection = await webflow.getDefaultVariableCollection();
3
4// Get All Variables
5const variables = await collection.getAllVariables();
6
7// Get Value of first Variable
8const variable = variables[0];
9const value = await variable.get()

Designer Ability

Checks for Authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canReadVariablesAnyAnyAnyAny
Built with