Checkbox with Gradio

Learn how to include checkboxes in Gradio applications and the many ways to interact with them.

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.

Press + to interact
Checkbox in Gradio
Checkbox in Gradio

The Checkbox supports some parameters, including (but not limited to):

  • value: Boolean, either True or False.

  • label: Optional label for the component, will appear above the checkbox.

  • info: Additional description of the component that will be displayed.

  • container: If True, 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.

Press + to interact
Checkbox parameters in the UI
Checkbox parameters in the UI
...
Access this course and 1400+ top-rated courses and projects.