How to change radio button color in ant design?

前端 未结 1 1806
面向向阳花
面向向阳花 2021-01-28 08:26

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

1条回答
  •  迷失自我
    2021-01-28 09:24

    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.

    0 讨论(0)
提交回复
热议问题