I have implemented a function to change the background color of the checkbox, but it makes the tick marks black, which I don't want, I want the marks to remain white, how can I achieve this? p>
HTML:-
<div v-for="category in categories" :key="category.id"> <div> <input type="checkbox" class="categoryInput" @change="input()" :true-value="category.id" false-value="0" v-model="currentCategory"/> <label class="form-label">{{category.name}}</label> </div> </div>
This is the function:-
input(){ var color = JSON.parse(localStorage.getItem('coloring') || '[]').CTAButtons let collection = document.getElementsByClassName("categoryInput"); for (let i = 0; i < collection.length; i++) { collection[i].style.accentColor = color } }
This is the output:- The background change is successful but the tick marks are changed to black
The advantage of using vue is to build custom components. So you can try the method shown below.
WORKStackBlitz
You may need to adjust the code to your specific requirements.
important
Add the following to your index.html header
The default HTML checkbox tick mark color is determined by the browser and cannot be changed. However, you can create your own custom checkbox and style it however you want.
HTML
CSS
JSFiddle