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
Name | Description | Type |
---|---|---|
label | The label to display to the user | str |
on_text | Text of On Toggle option | str |
off_text | Text of Off Toggle option | str |
initial_value | Initial value of the toggle | bool |
disabled | whether the input is disabled. Defaults to False. | bool |
required | Whether the input is required or not eg. "this field is required". Defaults to True. | Union[bool, str] |
hint | A tooltip displayed to the user. Defaults to None. | str |
full_width | Whether the input should use full screen width. Defaults to False. | bool |
button_text | What text to display on the button when the widget is not part of a Page. Defaults to 'Next'. | str |
Return Values
Type | Description |
---|---|
bool | The toggle value |