Kevin Powell - CommunityKP-C
Kevin Powell - Community2mo ago
39 replies
Kamran

label color change when radio input checked

Hi everyone
In this code:
<label
className="relative bg-very-dark-cyan text-white text-2xl py-1.5 px-4 text-center rounded-md hover:bg-cyan/40 hover:text-very-dark-cyan [&:has(input:checked)]:bg-cyan [&:has(input:checked)]:text-very-dark-cyan"
>
  <input className="group absolute w-full h-full top-0 left-0 cursor-pointer opacity-0" />
  {label}
</label>

with this structure, Is there any other way without using has pseudo class to change the color of label when input hover/checked?
Was this page helpful?