Handbook · Bindings vs expressions vs scripts

Bindings vs expressions vs scripts

Where in the UI. Layout inspector (value source), Structure expressions canvas, Scripts tab, fieldBindings node.

Three tools overlap. Using the heaviest one first makes templates hard to debug. Start at the top of this list and stop when it fits.

  1. Static — the value never changes (a label “Weight”, a brand color).
  2. Binding — show or edit a stored value (title, a category number, image slot 0).
  3. Expression — a formula that should stay true as inputs change (full name, overdue flag, converted units, contrast color). No side effects.
  4. Field bindings node — after expressions run, write results into stored fields (set backgroundColor from a formula).
  5. Script — something happens: dialogs, creating children, writing several fields, talking to relatives, timers, files. Side effects live here.

When not to script

Do not use Blockly to copy title into a text widget on every frame. Bind the widget. Do not use a script to compute “days until due” for display; use an expression (timeBetween + now). Scripts shine on events: onCreated, onEdited, button pressed.

Value sources on layout

Most visual props accept static, binding, or expression. Rotation, colors, and text content are typical. Some flags stay static (QR error correction, rating glyph shape) because the host paints them as enums.