Skip to main content

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

NameDescriptionType
labelThe label to display to the userstr
initial_valueThe initial value to display to the user.str
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
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 value entered by the user