When I try to apply custom styling to checkboxes, they appear correctly on all browsers that I have tested except Safari on ipad.
I am using the method of giving the checkbox the appearance of none, and then applying styling to a span to mimic the checkbox.
.container{
width:300px;
border:solid 1px lightgrey;
padding:20px;
}
ul, li, label{
width:100%;
}
li{
list-style: none;
padding:5px;
}
input[type=checkbox], input[type=checkbox]:checked{
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
input[type=checkbox] + span{
height:16px;
width:16px;
border:solid 1px red;
color:white;
}
input[type=checkbox]:checked + span{
height:16px;
width:16px;
border:solid 1px #4b4b4b;
background: #4b4b4b;
color:#ff0000;
display:flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding-top:1px;
padding-left:1px;
font-size:0.75rem;
}
<div class="container">
<ul>
<li><label for="option1">Option 1<input id="option1" type=checkbox><span>✔</span></label></li>
<li><label for="option2">Option 2<input id="option2" type=checkbox><span>✔</span></label></li>
<li><label for="option3">Option 3<input id="option3" type=checkbox><span>✔</span></label></li>
<li><label for="option4">Option 4<input id="option4" type=checkbox><span>✔</span></label></li>
<li><label for="option5">Option 5<input id="option5" type=checkbox><span>✔</span></label></li>
</ul>
</div>
The result on firefox/chrome/safari (macOS)/edge looks like:
The result on safari on ipad:
On ipadOS version 16.2, the color property is not applied to checkbox. The tick symbol takes the color of the background property. How is it possible to fix this?