Skip to content

Interactive controls: sliders, toggles and more

Turn Zlv values into sliders, steppers, toggles, dropdown choices, star ratings and color pickers, so dependent lines recalculate live as you adjust them.

Interactive controls turn a number into something you can drag or click. Assign a control to a variable, use the variable in later lines, and watch the whole sheet respond as you adjust it. It is a quick way to explore "what if" questions.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

The controls

ControlSyntaxValue
Sliderslider(min, max, value, step)A number in a range
Stepperstepper(min, max, value, step)A number changed by + and - buttons
Toggletoggle(true, "Label")true or false (1 or 0 in math)
Choicechoice(["A", "B", "C"], "B")The selected option
Ratingrating(max, value)Stars from 0 to max
Colorcolor("#6366f1")A color swatch

Slider

slider(min, max, value, step) shows a draggable slider. The value and step are optional: without a value the slider starts at the minimum, and without a step Zlv picks one based on the range. slide is another name for it.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Stepper

stepper(min, max, value, step) shows minus and plus buttons. In the desktop app the mouse wheel also changes it. counter is another name for it.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Toggle

toggle(true) is an on/off switch. In calculations, on counts as 1 and off as 0, so multiplying by a toggle switches an amount in or out. Add a label as the second argument. checkbox and switch are other names for it.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Choice

choice([options], selected) shows a dropdown. Options can be text or numbers. dropdown, select and picker are other names for it.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

In the desktop engine you can also list numeric options directly and use the selection in math:

Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Rating

rating(max, value) shows clickable stars, up to 10. stars is another name for it.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Color

color("#hex") shows a swatch. In the desktop app, clicking it opens a color picker.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

How controls edit your sheet

When you move a slider, click a toggle or pick an option, Zlv rewrites the numbers inside the control's own line, for example from slider(0, 100, 25, 5) to slider(0, 100, 60, 5). Your sheet stays plain text, so the new value is saved with the document.

Scrub any number (desktop)

You do not need a control to adjust a value. In the desktop editor, hold Alt and drag left or right on any number to change it live. Hold Shift while dragging for steps ten times larger, or Ctrl for steps ten times smaller.

All guides