Skip to main content

Widget Core Function

UI Experience: Toggle true/false interface for the user
Data Organization: Provides users with exactly two choices to select from, storing the selected data for use in other widgets.

Key Features

  • Simple binary choice interface (Yes/No, True/False, On/Off)
  • Clean, intuitive user experience for boolean decisions
  • Stores selection as index (0 or 1) for use in calculations
  • Supports custom labels for both toggle states

Video Tutorial

Create a Toggle

Watch Tutorial Learn how to create and configure toggle widgets step by step

Visual Presentation

The toggle widget interface provides a simple binary choice (Yes/No, True/False) displayed as radio buttons.

Configuration

Example Code

Configuration Parameters

string
required
Set to “lookup” to define the widget type
boolean
required
Set to true for toggle widgets to display as radio buttons instead of dropdown
array
required
Simple array with one column definition for the toggle options
matrix
required
Two-row matrix with the toggle options. Typically [“No”] and [“Yes”] or [“False”] and [“True”]
boolean
default:"false"
Should be set to false for toggle widgets as autosize is not applicable

Common Toggle Patterns

Yes/No Toggle

True/False Toggle

On/Off Toggle

Custom Labels

Examples from Current Calculators

Usage in Calculations

Toggle widgets return index values (0 or 1) that can be used in boolean logic:

Conditional Logic Examples

Visibility Control

Best Practices

  1. Clear Labels: Use descriptive labels that make the choice obvious to users
    • Good: “Yes” / “No”
    • Good: “Required” / “Not Required”
    • Avoid: “True” / “False” (less user-friendly)
  2. Default Values:
    • Set defaultValue: "0" for the safer/more conservative option
    • Consider which choice users will select most often
  3. Boolean Logic: Remember that toggles return indices (0, 1), not boolean values
    • Use == 1 for “true” checks
    • Use == 0 for “false” checks
  4. Conditional Visibility: Use toggles to control visibility of related widgets
  5. Documentation: Include clear author notes explaining what each toggle state represents

Integration Patterns

Controlling Widget Visibility

Conditional Calculations

Troubleshooting

Common Issues:
  • Forgetting to set radioListDisplay: true (widget will appear as dropdown instead of toggle)
  • Using boolean values instead of string arrays in dataTable
  • Comparing toggle values as booleans instead of indices (0, 1)
Remember: Toggle widgets are implemented as lookup widgets with exactly two options and radio button display enabled. This provides the clean toggle interface while maintaining the flexibility of the lookup widget system.