Skip to main content

Toggle

Offers a toggle switch between two defined options.

Examples

Basic Example

The following example demonstrate some of the available functionality for read_toggle

from abstra.forms import read_toggle

ans = read_toggle("Toggle")
# ans = True or False
print(ans)

Custom Example

The following example demonstrate how to customize the toggle options text

from abstra.forms import read_toggle

ans = read_toggle("Custom Toggle", on_text="Confirm", off_text="Cancel")
# ans = True or False

Parameters

NameDescriptionType
labelThe label to display to the userstr
on_textText of On Toggle optionstr
off_textText of Off Toggle optionstr
initial_valueInitial value of the togglebool
disabledwhether the input is disabled. Defaults to False.bool
requiredWhether the input is required or not eg. "this field is required". Defaults to True.Union[bool, str]
hintA tooltip displayed to the user. Defaults to None.str
end_programWhether the program should end after the widget is shown. Defaults to False.bool
full_widthWhether the input should use full screen width. Defaults to False.bool
button_textWhat text to display on the button when the widget is not part of a Page. Defaults to 'Next'.str

Return Values

TypeDescription
boolThe toggle value