Checkbox with Gradio
Learn how to include checkboxes in Gradio applications and the many ways to interact with them.
We'll cover the following...
Checkbox
A common UI element is a Checkbox
, allowing the user to toggle between True
or False
. To instantiate a Checkbox
, we type: gr.Checkbox()
.
A Checkbox
can only take on a boolean value (True
or False
). If it is passed as an input into a function, it will pass the status of the Checkbox
as a boolean. As an output, it expects a boolean returned from the function, and if True
will check the checkbox.
The Checkbox
supports some parameters, including (but not limited to):
value
: Boolean, eitherTrue
orFalse
.label
: Optional label for the component, will appear above the checkbox.info
: Additional description of the component that will be displayed.container
: IfTrue
, will place the checkbox in a container, and have extra padding.
These parameters are illustrated in the image below. We can see that the label
affects the main text shown next to the checkbox, whereas the info
is displayed in the smaller text above. The value
affects whether the box is ticked. Finally, the container
if set to True
will wrap the checkbox in a box.