Switch
Prompt operator with toggle switch for true/false values.
You can create a switch toggle with switch:
ui:
components:
- key: unit_powered
type: switch
label: "Unit Powered On"
description: "Confirm the unit is powered on before testing"
required: trueProperties
Display
You can configure how the toggle appears to the operator.
| Property | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Unique identifier for accessing the value |
type | string | Yes | Must be "switch" |
label | string | No | Display label for the toggle |
description | string | No | Helper text displayed below the toggle |
Value
You can set default values and bind to measurements or unit properties.
| Property | Type | Required | Description |
|---|---|---|---|
default_value | boolean | No | Default value to pre-fill the switch. If not set, switch starts in "Unset" state. |
bind | string | No | Bind to unit property or measurement. See Collect Input for details. |
Validation
You can validate input before the value is submitted.
| Property | Type | Required | Description |
|---|---|---|---|
required | boolean | No | If true, operator must provide input (shows "Required" badge) |
TofuPilot validates operator input before submission, preventing continuation until all constraints are met.
Examples
Unset State
Switches without a default value start in an "Unset" state:
phases:
- name: Optional Setting
ui:
components:
- key: optional_feature
type: switch
label: "Optional Feature"
# No default_value set - starts as "Unset" #
description: "Enable if needed, or leave unset"Feature Toggle
We'll use a switch to enable or disable a feature:
phases:
- name: Configure Test
ui:
components:
- key: enable_calibration
type: switch
label: "Enable Calibration Mode"
description: "Run test in calibration mode"
required: falseConditional Flow
We'll use a switch to determine the next step:
phases:
- name: Review Results
ui:
components:
- key: retest_required
type: switch
label: "Retest Required"
description: "Check if the unit needs to be retested"
required: trueHow is this guide?