Text Input

Last updated on June 16, 2026

Operator UI: Text Input
  Label: Serial Number (required)
  Placeholder: SN-001
  Help: Enter the unit's serial number to start testing

You can create a text input with text_input:

ui:
  components:
    - key: serial_number
      type: text_input
      label: "Serial Number"
      placeholder: "SN-001"
      description: "Enter the unit's serial number to start testing"
      required: true

Properties

Display

You can configure how the input field appears to the operator.

PropertyTypeRequiredDescription
keystringYesUnique identifier for accessing the value
typestringYesMust be "text_input"
labelstringNoDisplay label for the input
descriptionstringNoHelper text displayed below the input
placeholderstringNoHint text shown when empty

Value

You can set default values and bind to measurements or unit properties.

PropertyTypeRequiredDescription
default_valuestringNoDefault value to pre-fill the input field
bindstringNoBind to unit property or measurement. See Bind to Measurements for details.

Modifiers

You can automatically add prefix or suffix to the operator's input when the value is submitted.

PropertyTypeRequiredDescription
prefixstringNoText automatically prepended to the submitted value (e.g., "PCB-")
suffixstringNoText automatically appended to the submitted value (e.g., "-REV")
trimbooleanNoRemove leading and trailing whitespace from input (default: true)

Validation

You can validate input format and length before the value is submitted.

PropertyTypeRequiredDescription
requiredbooleanNoIf true, operator must provide input (shows "Required" badge)
min_lengthnumberNoMinimum number of characters required
max_lengthnumberNoMaximum number of characters allowed
patternstringNoRegex pattern for format validation

The web operator UI checks these constraints before submission, but they are not enforced by the execution engine itself, so do not rely on them as pass/fail criteria.

Instead, you can capture the input as a Measurement using Binding and validate it with Validators. TofuPilot will record the actual operator input while enforcing pass/fail criteria.

Examples

Length Validation

We'll enforce character count limits:

main:
  - name: Enter Part Code
    ui:
      components:
        - key: part_code
          type: text_input
          label: "Part Code"
          min_length: 3
          max_length: 10
          required: true

Pattern Validation

We'll use regex pattern to enforce specific formats:

main:
  - name: Collect Serial Number
    ui:
      components:
        - key: serial_number
          type: text_input
          label: "Serial Number"
          placeholder: "SN-12345678"
          pattern: "^SN-[0-9]{8}$"
          required: true

Prefix and Suffix

We'll automatically add prefix or suffix to the submitted value:

main:
  - name: Component Information
    ui:
      components:
        - key: part_number
          type: text_input
          label: "Component Part Number"
          placeholder: "Enter part ID"
          prefix: "PCB-"
          # Operator enters "1234" → Submitted as "PCB-1234"

        - key: firmware_version
          type: text_input
          label: "Firmware Version"
          placeholder: "2.4.1"
          suffix: "-prod"
          # Operator enters "2.4.1" → Submitted as "2.4.1-prod"

        - key: test_reference
          type: text_input
          label: "Test Reference"
          placeholder: "reference-id"
          prefix: "TEST-"
          suffix: "-REV"
          # Operator enters "A1" → Submitted as "TEST-A1-REV"

How is this guide?

On this page