-4

Is it possible to customise regular <input tupe="checkbox"> ?Lets say i want it to be heart shape input element, and that heart changes color when its selected.

I was looking at this 2 articles, first documentation on MDN and i didnt see anything that can help me. Is there something I am missing is this even possbile?

Mladen Milosavljevic
  • 1,720
  • 1
  • 12
  • 23

1 Answers1

1

hide the checkbox itself with input { display none; }. Then add the heart either as SVG or as HTML/Unicode within the label. YOu can use input:checked ~ label as selector to add changes within CSS.

/* hides the checkbox */
input {
  display: none;
}

/* changes the color when selected */
input:checked ~ label {
  color: red;
}



/* for styling purpose only */
label {
  font-size: 5em;
}
<input type="checkbox" id="heart">
<label for="heart">&#9829</label>
tacoshy
  • 10,642
  • 5
  • 17
  • 34