Thursday, November 21, 2019

The indeterminate state at checkbox type input controls is a thing in HTML and by HTML I mean JavaScript.

I found this example here of setting the setting and what the setting does is make the checkbox appear visually to be in some wishy-washy in-between state between checked and unchecked although this is all really just a visual cue as the checkbox is either checked or unchecked in the end in spite of appearances.

var checkbox = document.getElementById("some-checkbox");
checkbox.indeterminate = true;

 
 

In an Angular 5 template you could have something like this. Perhaps a good use case is for when a checkbox "governs" or "oversees" a bunch of other checkboxes and should only appear checked or unchecked if all of the children are checked or unchecked and should otherwise appear indeterminate if there is a splotchy what's what.

<input #foo type="checkbox" [indeterminate]="isSomethingErOther" />

No comments:

Post a Comment