Checkbox
Enables a selection through a single checkbox interaction.
Examples
Basic Example
Basic use of read_checkbox
from abstra.forms import read_checkbox
ans = read_checkbox("I have read and agree to the terms of services")
print(ans)
Optional field
If check the box is optional, pass the optional parameter required
from abstra.forms import read_checkbox
ans = read_checkbox(
"Would you like to receive product updates and announcements via email?",
required=False,
)
print(ans)
Use markdown to customize label
Use markdown syntax to customize the label
from abstra.forms import read_checkbox
ans = read_checkbox(
"I have read and agree to the [terms of services](https://example.com)"
)
Parameters
Name | Description | Type |
---|---|---|
label | The label to display to the user | str |
initial_value | The initial value to display to the user. | str |
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 value entered by the user |