008 — When use switch and checkbox?
by Óscar Otero
1 min read
Switches and checkboxes are form controls to enable or disable options. The main difference is the expected behavior after changing the state:
- The checkbox, like any other form input, requires a button to submit the selection, so it should be used to select/unselect different options.
- The switch must have an immediate effect, so it suits better to enable/disable features. Technically it's not an input but a button because the new state is submitted on clicking it.
In the following example, we use checkboxes to select different options. We need a button to submit the selection:
This is an example to enable/disable some features and the effect is immediate, so we don't have a button to submit. We use switches: