Alternatively, when checked, the box background can remain the same and a foreground check element may appear.
The style of the label can also change when the checkbox is checked.
When a checkbox’s value is neither true nor false, it is indeterminate. An indeterminate checkbox may be gray, or shown with a different mark inside the checkbox.
Indeterminate checkboxes are often used in a hierarchy of checkboxes, when not all children are checked, the parent remains indeterminate.
A checkbox visually changes depending on the element state: focused, disabled, hover, or active. This can mean adding a shadow, border, or changing color of the box and check. The label can also change style during each state.
A switch is usually larger and has more visual weight than a checkbox. The toggle often also has a primary label describing the state, and a secondary label describing the selected state.
Like a checkbox, a switch can also have unique styles per element state: focused, disabled, hover, or active.
A checkbox or switch may have animations on transitions between each element state:
Note: There should be no animation if disabled in the browser or system preferences.
Clicking the label or the checkbox should toggle the component. Being able to select the label is important, because the checkbox itself can be quite small and difficult to select on high resolution screens. Clicking the label or checkbox a subsequent time, should uncheck the checkbox.
A disabled checkbox should not change state when clicked.
It is very common for developers to build custom checkbox implementations that closely match a company’s brand. In order to understand how checkboxes are used across the web, we surveyed the public web sites of Interbrand’s top 100 brands. This list is useful because it includes brands with websites that are Alexa ranked from the top 10 to the top 500,000. We analyzed these custom checkbox implementations for the following issues:
All | Top 100 | Top 100-500 | Top 500-5k | Top 5k-50k | Top 50k - Million | |
---|---|---|---|---|---|---|
Invisible Focus State | 16.13% | 20.00% | 10.00% | 13.79% | 23.08% | 6.67% |
Non-interactable Label | 30.11% | 13.33% | 20.00% | 31.03% | 34.62% | 40.00% |
No Computed Name | 59.14% | 13.33% | 10.00% | 20.69% | 19.23% | 20.00% |
Has any issue | 44.09% | 26.67% | 40.00% | 48.28% | 50.00% | 46.67% |
The main takeaway from these numbers is that the industry massively fails to build custom checkboxes correctly. These are the biggest brands in the world. The survey was not exhaustive either. For each brand, we spent 5-10 minutes finding and accessing checkbox implementations. Undoubtedly an exhaustive search would discover many more issues.