WTF is an expression ? ๐Ÿ†•

For no-code and low-code users who want to build smarter forms without writing code.

Definition

An expression is a tiny formula that tells Superform:

โ€œWatch this input, and when it changesโ€ฆ do something.โ€

or

โ€œIf this happens โžœ do that.โ€

Itโ€™s just logic. Like what youโ€™d use in a calculator or spreadsheet:

2 + 2         // โ†’ 4
$f.age > 18   // โ†’ true
$f.price * $f.quantity  // โ†’ 2 * 18 = 36

You use expressions inside attributes like sf-react and Superform updates the DOM (HTML elements) automagically.

Example expressions

๐Ÿ‘‹ Live name preview

<p>Welcome back <span sf-react="text($f.name)">Name</span></p>

โ†’ $f.name comes from an <input name="name">.

โ†’ Updates the span with what the user typed in the name input.

Refer to Update Text reactivity for more information and Webflow examples!

๐Ÿงฎ Show total price

โ†’ $f.price and $f.quantity come from <input name="price"> and <input name="quantity">.

โ†’ Calculates and displays price ร— quantity as the user types/selects quantities.

Refer to Update Text reactivity for more information and Webflow examples!

๐Ÿ”ž Show warning if underage

โ†’ $f.age comes from an <input name="age" type="number">.

โ†’ Shows the message only if the entered age is under 18.

Refer to Visibility reactivity for more information and Webflow examples!

๐ŸŸฉ Highlight selected plan

โ†’ $f.plan comes from a group of radio buttons or a <select name="plan">.

โ†’ Toggles the active class when the selected plan is "pro".

Refer to Class Toggle feature for more information and Webflow examples!

โœ… Show message based on score with ternary operator (advanced)

โ†’ $v.score is a custom score variable calculated using sf-score-calc.

โ†’ Shows "Great job!" if the score is above 5, otherwise "Keep going!".

Refer to Update Text and Score Setup & Calculation feature for more information and Webflow examples!

๐Ÿชœ Highlight the active step visually (advanced)

โ†’ $s is the current step index (starts at 0).

โ†’ Adds the active-step class only when you're on Step 3 (index 2).

Useful for styling progress indicators, steppers, or conditional content blocks.

Refer to Class Toggle feature and Progress Percentage ($p) variable for more information and Webflow examples!


What can I use inside Expressions

Inside expressions, you can combine:

  • โœ… Superform variables like $f, $s, $p, and $v

  • โœ… Superform functions like text(), value(), visibility(), class(), and attr()

  • โœ… Basic JavaScript logic like math, comparisons, strings, and ternary operators

๐Ÿง  Variables overview (see Variables)

Variable
Meaning

$f

Form data (like $f.name, $f.email, etc)

$s

Current step index (useful in multistep forms)

$p

Progress value (%)

$v

Score variables ($v.totalScore, etc)

๐Ÿ› ๏ธ Reactivity features

Function
What it does

text(value)

Updates the elementโ€™s text

value(value)

Sets the value of an input or element

visibility(condition)

Show/hide the element

class(condition, 'classname')

Adds a class if true

attr(value, 'attribute')

Sets a custom attribute


Last updated

Was this helpful?