Checkbox Example (Mixed-State)
This example demonstrates using the Checkbox Design Pattern to create a tri-state, or mixed-state, checkbox. In this implementation, the mixed-state checkbox represents the state of a set of standard HTML checkboxes. If none of the checkboxes in the set are checked, the mixed state checkbox is not checked, and if all members of the set are checked, the mixed state checkbox is checked. If the set contains both some checked and unchecked checkboxes, the mixed state checkbox is partially checked. Activating the tri-state checkbox changes the states of the checkboxes in the set.
This example also demonstrates use of fieldset
and Legend
elements for labeling the checkbox group.
Similar examples include:
- Checkbox (Two State): Simple two state checkbox.
Example
Keyboard Support
Key | Function |
---|---|
Tab | Moves keyboard focus among the checkboxes. |
Space |
|
Role, Property, State, and Tabindex Attributes
Role | Attribute | Element | Usage |
---|---|---|---|
checkbox |
div |
|
|
tabindex="0" |
div |
Includes the checkbox in the page tab sequence. | |
aria-controls="[IDREFS]" |
div |
identifies the set of checkboxes controlled by the mixed checkbox. | |
aria-checked="false" |
div |
|
|
aria-checked="true" |
div |
|
|
aria-checked="mixed" |
div |
|
Javascript and CSS Source Code
- CSS: checkbox.css
- Javascript: checkboxMixed.js
- Javascript: controlledCheckbox.js
HTML Source Code