5

I'm using antd radios and checkboxes. I want to give custom colors to them. I found answer about checkbox but found no way to change radio button color.

Is there any way to do so?

Jonas
  • 121,568
  • 97
  • 310
  • 388
Ali Ahmad
  • 51
  • 1
  • 1
  • 4

1 Answers1

18

You can achive it by overriding following css classes:

.ant-radio-checked .ant-radio-inner{
  border-color: red !important ;
}

.ant-radio-checked .ant-radio-inner:after{
  background-color: red;
}

.ant-radio:hover .ant-radio-inner {
  border-color: red ;
}

First block is responsible for coloring the circle around the dot in radio. You can ignore !important rule but then you have to override :focus selector like:

.ant-radio-checked .ant-radio-inner:focus{
  border-color: red;
}

Second block color the dot in the middle of selected radio. The last one color circle on hover. I am not completely sure why ant-radio-inner should be inside radio:hover, but it works for me.

Pabblo13
  • 181
  • 1
  • 4
  • 1
    Do we need to reference the class in our code or it will be picked up on its own. See my post please and see if you can help there. https://stackoverflow.com/questions/63799078/ant-design-button-color-update – Sarah Sep 08 '20 at 17:48
  • @Pabblo13 How about changing the color of the text of the radio item? – Chervin Tanilon Sep 20 '21 at 07:30
  • what about the ring thats around the inner dot but inside the outer perimeter? – Embedded_Mugs Jul 06 '22 at 00:46