Home > Software engineering >  React Js - How to change a color in checkbox when it is checked?
React Js - How to change a color in checkbox when it is checked?

Time:11-10

Howto change the color in the checkbox when it is checked?
When my checkbox is checked, it has this color: enter image description here

But i want to change to red.

How i can do that?

  <input
        type="checkbox"
        disabled={isDisabled}
        defaultChecked={checked}
        onChange={() => setChecked(!checked)}
      />

CodePudding user response:

You can use accent-color css property:

JsFiddle

input[type='checkbox'] {
  accent-color: red;
}
 <input type="checkbox" />

Keep the browser support in mind when using this.

  • Related