Panels

Last updated on November 9, 2026

PreviewThis feature is in preview, so its scope and behavior may change. Request access.

An airspeed indicator panel: the needle follows a live measurement, with its value and PASS outcome below

The Operator UI components cover most test screens: inputs, text, images, progress. Sometimes you want to go further: a gauge that reads like the instrument on the bench, a synoptic of the fixture with each connector colored by its result, or a station screen in your line's own layout and colors. A panel lets you draw that screen yourself.

You can replace a phase's component list with your own screen using panel, the path of an HTML file relative to the project root:

ui:
  panel: panels/airspeed.html

A panel is plain HTML and CSS, with inline SVG for gauges and diagrams. TofuPilot fills it with live values from your phase, so you write no JavaScript. Your components, measurements and limits stay in procedure.yaml, so validation and recording work exactly as without a panel.

See finished panels running live in the panels gallery, each with its code. This page builds one panel step by step, for a battery charge station: first a value, then a gauge, then buttons and the operator's verdict. Each section adds one idea to the previous one.

Show a Value

You can show any value on any element with data-bind. Start with a phase that records a measurement, and a panel that shows it.

main:
  - key: charge
    name: Charge
    python: phases.charge:charge
    measurements:
      - key: pack_voltage
        name: Pack voltage
        unit: V
        validators:
          - operator: ">="
            expected_value: 30
          - operator: "<="
            expected_value: 60
    ui:
      panel: panels/charge.html
import time


def charge(measurements, psu):
    for _ in range(50):
        measurements.pack_voltage = psu.read_voltage()
        time.sleep(0.1)
<p>
  Pack voltage:
  <b data-bind="measurements.pack_voltage" data-format="0.00"></b> V
</p>

The value updates each time the phase records pack_voltage. data-format="0.00" shows two decimals. Until the first value arrives the element is empty, never an error.

The path after data-bind uses the names your Python phase uses for its parameters: measurements.KEY, ui.KEY, unit.serial_number, run.status... See Paths for the full list.

Turn It into a Gauge

You can turn a value into a needle, a bar or a color with CSS. Besides its text, data-bind writes the value on its element as a CSS variable, --value, and the measurement's verdict as data-outcome.

panels/charge.html
<svg viewBox="-150 -150 300 300">
  <circle r="110" fill="#111"/>
  <g data-bind="measurements.pack_voltage"> 
    <line class="needle" y2="-95"/>
    <text y="60" text-anchor="middle" fill="#fff" data-bind="measurements.pack_voltage" data-format="0.00"/>
  </g>
</svg>
<style>
  svg { display: block; width: min(480px, 100%); margin: 0 auto; }
  .needle {
    stroke: #fff;
    stroke-width: 4;
    transform: rotate(calc((clamp(0, var(--value, 0), 60) / 60 * 270 - 135) * 1deg)); 
    transition: transform .3s;
  }
  [data-outcome=FAIL] .needle { stroke: #e33; } 
</style>

CSS variables inherit, so binding the <g> lets every child read var(--value). The needle turns red as soon as a value fails the measurement's limits, because the engine judges a measurement when it is recorded.

Always give var(--value, 0) a fallback: the variable is removed while the value does not exist. Keep pass/fail decisions in the measurement's limits, not in CSS, so the color shows the same verdict the run records.

See Styling for everything data-bind writes.

Show Live Values Without Recording

A measurement records every value you assign. To animate a reading without recording each step, write it to a ui key that no component declares. The panel shows it, and it is never recorded.

def charge(ui, measurements, psu):
    for _ in range(50):
        measurements.pack_voltage = psu.read_voltage()
        ui.amps = psu.read_current()  # Shown by the panel, never recorded
        time.sleep(0.1)
<p>Current: <b data-bind="ui.amps" data-format="0.0"></b> A</p>

Add a Button

You can add a button your Python reads with <button name="NAME">. The phase counts its presses with ui.pressed("NAME"), which never blocks, so you call it from your measuring loop.

<button name="tare">Tare</button>
def charge(ui, measurements, psu):
    for _ in range(50):
        if ui.pressed("tare"):  # Presses since the last call
            psu.tare()
        measurements.pack_voltage = psu.read_voltage()
        time.sleep(0.1)

ui.pressed raises ValueError for a name the panel has no button for, and suggests the closest one.

Let the Operator Edit a Value

You can let the operator edit an input component from the panel with an HTML field of the same name. Declare the component as usual: it keeps its validation, its bind and its recorded answer.

    ui:
      panel: panels/charge.html
      components:
        - key: setpoint_a
          type: number_input
          label: "Charge Current"
          min: 0
          max: 20
<input type="range" name="setpoint_a" min="0" max="20">

The field works both ways: it shows the component's value, including one your Python sets with ui.setpoint_a = 5, and writes the operator's changes back. <input>, <select> and <textarea> all work this way.

To place the standard rendering of a component instead, with its label and errors, use <slot name="setpoint_a"></slot>.

Answer the Screen

You can let the operator finish the screen with a submit button. A submit with a name and a value first writes the value into that input component, which turns two buttons into a recorded PASS / FAIL verdict.

        - key: verdict
          type: select
          label: "Verdict"
          options: 
            - label: "Pass"
              value: pass
            - label: "Fail"
              value: fail
<button type="submit" name="verdict" value="pass">PASS</button>
<button type="submit" name="verdict" value="fail">FAIL</button>
    answer = ui.wait()  # Returns when the operator presses PASS or FAIL
    psu.set_current(answer["setpoint_a"])

Without a submit button, the standard Continue stays under the panel. A <button> without type="submit" never submits, whatever the HTML default, and pressing Enter in a field never triggers a named submit, so a verdict is always a deliberate press.

ui.wait() blocks until the screen is answered, then returns the components' values. See Wait for the Operator.

Frame the Whole Run

You can frame the whole run with a panel at the procedure's root. It stays on screen from plug setup to the verdict, and one <slot></slot> shows the current screen: a phase's panel, its component list, the running screen or the verdict.

name: Battery FVT
ui: 
  panel: panels/run.html

main:
  - key: charge
    # ...
<header class="run">
  <b data-bind="unit.serial_number"></b>
  <span data-bind="phase.name"></span>
  <span class="status" data-bind="run.status"></span>
  <button name="stop">Stop</button>
</header>
<slot></slot>
<style>
  .run { display: flex; gap: 16px; align-items: center; padding: 8px 16px; }
  .status[data-value=PASS] { color: #2c2; }
  .status[data-value=FAIL] { color: #e33; }
</style>

A run panel reads unit.*, run.*, PHASE_KEY.measurements.* and PLUG_KEY.status, and phase and measurements follow the phase running now. It has no ui values and no fields, and its CSS never reaches inside its <slot>. It accepts two buttons:

ElementDescription
<button name="stop">Stops the run gracefully, like the control bar's Stop.
<button name="kill">Kills the run. It arms half a second after the panel's Stop, so a double tap never kills: a panel with a Kill button also needs a Stop button.

Both are disabled once the run has ended and while the station is unreachable.

Full Example

The charge phase from the sections above, in one place.

main:
  - key: charge
    name: Charge
    python: phases.charge:charge
    measurements:
      - key: pack_voltage
        name: Pack voltage
        unit: V
        validators:
          - operator: ">="
            expected_value: 30
          - operator: "<="
            expected_value: 60
    ui:
      panel: panels/charge.html
      components:
        - key: setpoint_a
          type: number_input
          label: "Charge Current"
          min: 0
          max: 20
        - key: verdict
          type: select
          label: "Verdict"
          options:
            - label: "Pass"
              value: pass
            - label: "Fail"
              value: fail
import time


def charge(ui, measurements, psu):
    for _ in range(50):
        if ui.pressed("tare"):
            psu.tare()
        measurements.pack_voltage = psu.read_voltage()
        ui.amps = psu.read_current()
        time.sleep(0.1)
    answer = ui.wait()
    psu.set_current(answer["setpoint_a"])
<div class="cockpit">
  <svg viewBox="-150 -150 300 300">
    <circle r="110" fill="#111"/>
    <g data-bind="measurements.pack_voltage">
      <line class="needle" y2="-95"/>
      <text y="60" text-anchor="middle" fill="#fff" data-bind="measurements.pack_voltage" data-format="0.00"/>
    </g>
  </svg>
  <div class="controls">
    <p>Current: <b data-bind="ui.amps" data-format="0.0"></b> A</p>
    <input type="range" name="setpoint_a" min="0" max="20">
    <button name="tare">Tare</button>
    <button type="submit" name="verdict" value="pass">PASS</button>
    <button type="submit" name="verdict" value="fail">FAIL</button>
  </div>
</div>
<style>
  .cockpit { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
  .cockpit svg { display: block; width: min(480px, 100%); margin: 0 auto; }
  .controls { display: grid; gap: 12px; align-content: start; }
  .needle {
    stroke: #fff;
    stroke-width: 4;
    transform: rotate(calc((clamp(0, var(--value, 0), 60) / 60 * 270 - 135) * 1deg));
    transition: transform .3s;
  }
  [data-outcome=FAIL] .needle { stroke: #e33; }
</style>

Design with an LLM

Panels are plain HTML, so an LLM can draw one for you. Copy this prompt into your assistant and replace the description with your phase:

prompt.txt
Read https://www.tofupilot.com/docs/frameworks/tofupilot/operator-ui/panels.mdx,
then design a TofuPilot panel: one HTML file, plain HTML, CSS and inline SVG,
no JavaScript.

The phase: <what the operator sees and does. Example: a motor spin test showing
RPM and current as two gauges, with a Stop motor button and PASS / FAIL.>

Bind values with data-bind, and give me the measurements and components the
panel expects.

The station checks the panel when the run starts and names any mistake with its line and the closest name, so you can paste the error back to the model.

Give the model a photo or a sketch of the instrument or fixture if you have one. A panel that looks like the bench is faster for operators to read than any generic layout.

Reference

Attributes

HTMLDescription
data-bind="PATH"Shows the value at PATH, see Paths and Styling.
data-format="0.00"With data-bind, shows a number with that many decimals (0, 0.0, 0.00...).
<input name="KEY">, <select name="KEY">, <textarea name="KEY">Edits the input component KEY, both ways.
<slot name="KEY"></slot>Places the standard rendering of component KEY, with its label and errors.
<button name="NAME">A press. The phase reads it with ui.pressed("NAME").
<button type="submit">Answers the screen, like Continue: the phase moves on, or ui.wait() returns.
<button type="submit" name="KEY" value="V">Writes V into the input component KEY, then answers the screen.

Paths

PathValue
ui.KEYA component's value, or a value the phase writes with ui.KEY = v without declaring a component.
measurements.KEYThe latest value of a measurement of this phase.
measurements.KEY.outcome / .low / .high / .unitsThe measurement's verdict, its limits' range and its unit.
PHASE_KEY.measurements.KEYA measurement of another phase.
PLUG_KEY.statusA plug's status.
unit.serial_numberThe unit's serial number. Also part_number, revision_number, batch_number.
run.statusRUNNING, then the verdict: PASS, FAIL, ERROR, ABORTED...
run.operated_byThe operator attributed to the run.
run.procedure.name / .versionThe procedure's name and version.
run.slot.key / .nameThe slot, on a multi-slot fixture.
phase.key / phase.nameThe current phase.

Styling

data-bind writes these on its element:

WrittenUse in CSS
data-valueThe value as text, true or false for a flag: [data-value=true]. Removed while the value does not exist.
--valueThe value as a number (true is 1, false is 0), for calc(). Removed otherwise, so give it a fallback: var(--value, 0).
textThe value, on an element without child elements.
valueOn a <meter> or a <progress>.
data-outcome, --low, --highOn a measurement: PASS, FAIL or UNSET, and the range its limits draw.

Showing and hiding works the same way:

<div class="alarm" data-bind="ui.overheat">Overheat</div>
<style>
  .alarm[data-value=false] { display: none; }
</style>

Size

A panel takes the whole width of the screen. Its title and the standard submit button stay in the form's column. Set the panel's size in your CSS: display: block, width: min(560px, 100%) and margin: 0 auto keep it centered at that width.

An <svg> without a height attribute is limited to what fits on the screen with the title and the button, and centered when it is alone in the panel. Set max-height in your CSS to change that. Use max-height: none for a CSS height taller than the screen, or when HTML placed over the drawing has to stay aligned with it.

Python

PythonDescription
ui.KEY = vSets component KEY. On a key no component declares, sets a value only the panel shows: it is never recorded and never part of an answer. It is kept when ui.wait() shows the screen again.
ui.pressed("NAME")Returns the number of presses of <button name="NAME"> since the last call, 0 when none. Never blocks.
ui.wait()Blocks until the screen is answered, then returns the components' values.

Limits

A panel is shown to every viewer of the run, in the kiosk and in the dashboard, so it can run nothing and load nothing from outside the procedure:

  • No <script>, on* attribute, <iframe>, <object>, <form>, <link>, <foreignObject> or custom element.
  • Links (<a href>) and <use href> point inside the panel only, as #id.
  • Images use a relative raster path (images/fixture.png) or data:image/png;.... No .svg file, srcset or external URL.
  • CSS lives in a <style> block or a style attribute, and applies inside the panel only. The panel renders in its own shadow root, so the page's CSS does not reach it either: only inherited properties (font, color) pass through.
  • No id or name that is a property of the page or of a form (title, submit, action...): the browser drops it.
  • At most 40 kB per file and 10,000 elements, with a warning from 2,000.

CSS restrictions

No @import, no url() other than url(#id) or raster data, no image-set(), no rule for the whole page (@font-face, @layer...) and no CSS escapes (\). Give your @keyframes a distinctive name.

The station checks every panel before the run starts. A forbidden element, a field for a component the phase does not declare, or a path that does not exist refuses the run, with the file, the line and the closest name:

procedure.yaml:18:7: main[0].ui.panel: `panels/charge.html` line 12: <input name="setpoint">: no component `setpoint` in this phase; a field writes the input component of that key; did you mean `setpoint_a`?

An undeclared measurement only warns, since the phase may record it under that name. So does a ui.KEY the phase's Python file never assigns, unless the phase writes values with setattr(ui, ...) or passes ui to a helper, which the check cannot follow.

Terminal and Agents

The terminal UI shows the components, then the panel's values as text and its buttons on F1, F2 and so on. With tofupilot run --json, each ui_request lists the panel's buttons, and an agent presses one with {"type": "ui_event", "request_id": "...", "name": "tare"}. Neither receives the panel's HTML.

How is this guide?

On this page