Use functions in variables
Variables now support using a set of CSS functions in their values, allowing you to create more flexible and dynamic design tokens.
Webflow supports the following CSS functions in variables:
Custom values
To use functions in variables, you need to create or set them as custom values. All variable creation methods accept a CustomValue
object as the value parameter, and the variable.set()
method can also update variable values with custom values. For the custom values object, the type
property is always "custom"
and the value
property is a string containing the CSS function.
CustomValue type
Create a custom value
Set a custom value
Reference variables in functions
When using functions, you can reference other variables using the var()
syntax. This allows you to create dynamic relationships between your design tokens. To dynamically get this syntax, use the new getBinding()
method on a variable.
Getting the value of a custom variable
To get the value of a custom variable, add the customValues
property as an optional parameter to the variable.get()
method.
Using variable.get()
without setting customValues: true
will throw an error if the variable has a custom value. It’s recommend to always setting customValues: true
when getting the value of a variable.