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.
Evaluating…
The controls
| Control | Syntax | Value |
|---|---|---|
| Slider | slider(min, max, value, step) | A number in a range |
| Stepper | stepper(min, max, value, step) | A number changed by + and - buttons |
| Toggle | toggle(true, "Label") | true or false (1 or 0 in math) |
| Choice | choice(["A", "B", "C"], "B") | The selected option |
| Rating | rating(max, value) | Stars from 0 to max |
| Color | color("#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.
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.
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.
Evaluating…
Choice
choice([options], selected) shows a dropdown. Options can be text or numbers. dropdown, select and picker are other names for it.
Evaluating…
In the desktop engine you can also list numeric options directly and use the selection in math:
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.
Evaluating…
Color
color("#hex") shows a swatch. In the desktop app, clicking it opens a color picker.
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.
Related pages
- Random, dice and coins
- 2D plots, which also react to controls.