Would be nice to style checkboxes without tricks. Right now to create a custom checkbox you need to hide the checkbox, use another element to replace the checkbox itself and handling some accessibility edge cases like avoiding to hide the input completely from screen reader…
Would not be simpler if we can define an svg to replace our checkbox with appearance property? As part of the proposal would nice we can change colors of the svg and use animations.
example of current situation
<label>
<span class="checkbox">
<input type="checkbox" class="checkbox-input"/>
<span class="checkbox-icon"></span>
</span>
label
</label>
.checkbox {}
.checkbox-input { visibility: hidden; height:0; width:0; }
.checkbox-icon:before {
content: "[]";
display: inline-block;
}
.checkbox-input:checked ~ .checkbox-icon:before {
content: "[x]";
}
Example proposal
<label>
<input type="checkbox" class="checkbox-3"/>
label
</label>
.checkbox-2 {
appearance: url(input.svg#checkbox);
transition: fill .5s;
}
.checkbox-2:checked {
appearance: url(input.svg#checkbox-checked);
}
.checkbox-2:checked .checkbox-2-tick {
fill: tomato;
}
.checkbox-2:disabled {
opacity: .4;
}
.checkbox-2:disabled .checkbox-2-tick {
fill: gray;
}