Skip to content

Expression & formula syntax

Several places in minisheet accept dynamic content: label content, button labels, table filters, string variable values, and any widget's background color. Two kinds of interpolation are supported, and Formula-type background variables use the expression form directly (without the ${} wrapper).

{varId} — variable reference

Inserts the current (computed) value of a background variable.

HP: {hp} / {hp_max}

${expression} — evaluated expression

Evaluates an expression and inserts the result. Expressions run on mathjs, not JavaScript — the syntax is close to JS/math notation but not identical, and mathjs's own function library (min, max, floor, round, filter, map, string functions, etc.) is available.

DEX mod: ${floor((DEX - 10) / 2)}

Variable ids used inside an expression must be valid mathjs symbols: they start with a letter or underscore, followed by letters, digits, or underscores.

Formula-type background variables are always expressions — you write the expression itself (e.g. floor((DEX - 10) / 2)) without wrapping it in ${}, since the whole value is already treated as a formula.

Arrow-function shorthand

mathjs has its own lambda syntax, but minisheet also accepts the more familiar JS arrow form and rewrites it automatically before evaluation. This mainly matters inside filter/map over table rows:

filter(spells, row => row.prepared)
map(spells, row => row.name)

Both row => row.x and (row) => row.x / (row, i) => ... forms are supported.

Background color expressions

Any widget's background color field accepts the same {varId} / ${expression} interpolation as label content, in addition to a plain CSS color:

${hp <= 0 ? '#f4cccc' : '#d9ead3'}

This is re-evaluated on every render, so a widget's color can react live to sheet state. If the result isn't a valid CSS color, the browser just ignores it (transparent), the same as an unresolved variable in a label.

Circular references

If a formula variable depends on itself, directly or through a chain of other formulas, minisheet detects the cycle and reports it instead of evaluating — it will not hang or crash the page.

Where formulas can't reach

Expressions can only reference background variables, never another widget directly. If two widgets need to reflect the same computed value, point them both at the same background variable rather than trying to reference one widget from another.

minisheet is offline-first — your sheets live on your device, with optional cloud backup.