Checkbox
A checkbox is a widget that allows the user to toggle a boolean state.
@reacton.value_component(bool)
def Checkbox(
*,
label=None,
value: Union[bool, solara.Reactive[bool]] = True,
on_value: Callable[[bool], None] = None,
disabled=False,
style: str = None,
):
...
Basic examples
import solara
turbo_boost = solara.reactive(True)
@solara.component
def Page():
checkbox = solara.Checkbox(label="Turbo boost", value=turbo_boost)
if turbo_boost.value:
solara.Success("Turbo boost is on")
else:
solara.Warning("Turbo boost is off, you might want to turn it on")
Turbo boost is on
Live output
Arguments
label
: The label to display next to the checkbox.value
: The current value of the checkbox (True or False).on_value
: A callback that is called when the checkbox is toggled.disabled
: If True, the checkbox is disabled and cannot be used.style
: A string of CSS styles to apply to the checkbox.