How to change radio button color in ant design?
Asked Answered
C

1

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?

Chromoprotein answered 27/6, 2020 at 12:22 Comment(0)
C
19

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.

Calmative answered 2/7, 2020 at 9:20 Comment(3)
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. #63799578Detroit
@Calmative How about changing the color of the text of the radio item?Bravery
what about the ring thats around the inner dot but inside the outer perimeter?Belsen

© 2022 - 2024 — McMap. All rights reserved.