Skip to main content

ToggleInput

Toggle switch input widget for capturing boolean values.

Examples

Basic Usage

This example runs a form with a single page containing the widget

Example Code

from abstra.forms import ToggleInput, run

# Create a page with the widget
example_page = [
ToggleInput(label="Toggle Input", key="my-toggle_input"),
]

# Run the form
result = run([example_page])

# Print the result
print(result)

Parameters

NameDescriptionTypeDefault
label (required)Text label displayed next to the toggle.strNone
keyIdentifier for the widget, defaults to label if not provided.strNone
on_textText to display when the toggle is on.str'Yes'
off_textText to display when the toggle is off.str'No'
requiredWhether the toggle must be switched on before proceeding.boolTrue
hintHelp text displayed below the toggle.strNone
full_widthWhether the widget should take up the full width of its container.boolFalse
disabledWhether the toggle is non-interactive.boolFalse
errorsPre-defined validation error messages to display.Union[List[str], str]None