Checkbox
Usage notes
Checkboxes allow users to select multiple items from a list of individual items, or to mark one individual item as selected.
Default
Toggle markup
<coral-checkbox></coral-checkbox>
Checked
Toggle markup
<coral-checkbox checked="">Checked</coral-checkbox>
Indeterminate
Toggle markup
<coral-checkbox indeterminate="">Indeterminate</coral-checkbox>
Disabled
Toggle markup
<coral-checkbox disabled="">Disabled</coral-checkbox>
Checked and disabled
Toggle markup
<coral-checkbox checked="" disabled="">Checked and disabled</coral-checkbox>
Labelled
Toggle markup
<coral-checkbox>Check</coral-checkbox>
<coral-checkbox labelled="Check"></coral-checkbox>
From JavaScript
Toggle markup
<div id="from-javascript"></div>
<script>
window.addEventListener('load', function() {
var checkboxFromJS = document.createElement('coral-checkbox');
checkboxFromJS.style.width = '149px';
checkboxFromJS.textContent = 'Add Adobe Stock. Get one month free.*';
document.getElementById('from-javascript').appendChild(checkboxFromJS);
});
</script>
Tri-State Cycling
Toggle markup
<div id="tri-state"></div>
<script type="text/javascript">
window.addEventListener('load', function() {
var checkbox = document.createElement('coral-checkbox');
checkbox.innerHTML = 'Cycle States by Clicking Me';
var exampleDiv = document.getElementById('tri-state');
exampleDiv.appendChild(checkbox);
var state = 0;
checkbox.addEventListener('change', function() {
state++;
switch(state) {
case 1:
checkbox.checked = true;
checkbox.indeterminate = false;
break;
case 2:
checkbox.checked = true;
checkbox.indeterminate = true;
break;
case 3:
checkbox.checked = false;
checkbox.indeterminate = false;
state = 0;
break;
}
});
});
</script>