1

How can I change the color of thing tick inside a checkbox? This is what I have done:

.ant-checkbox-checked .ant-checkbox-inner { color: #000000; background-color: #008000; } .ant-checkbox-checked .ant-checkbox-input { color: #000000; background-color: #000000; } 
6
  • Questions seeking code help must include the shortest code necessary to reproduce it in the question itself preferably in a Stack Snippet. See How to create a Minimal, Reproducible Example Commented Jun 29, 2020 at 9:01
  • w3schools.com/howto/howto_css_custom_checkbox.asp Try this, it has all that you want and more styling which you can use. Pretty good for a start. Commented Jun 29, 2020 at 9:03
  • @Paulie_D didn't I already produce the code? When you are using ANTD you just need to call <Checkbox/> and it will return my checkbox with my CSS Commented Jun 29, 2020 at 9:07
  • No you didn't. You gave a snippet of CSS that does not demonstrate the issue, We don't all have ANTD available, your demo should be runnable in the question. Commented Jun 29, 2020 at 9:09
  • @Paulie_D this is possibly only a styling issues and you do not need to mention explicitly how to return a checkbox (e.g. <input type="checkbox"/>) Commented Jun 29, 2020 at 9:29

2 Answers 2

4

Add this css to your styles:

.ant-checkbox-checked .ant-checkbox-inner:after { border-color: red !important; } 
Sign up to request clarification or add additional context in comments.

5 Comments

it is not working. I will now have a rectangle instead of a tick. I will edit my post to show you how it looks like now.
i am using V4.4.0 though
is there any documentations or website that i can read up more on? cause it does not seems to work for me
sorry, it is still not working. I even created a codesandbox code to test it out: codesandbox.io/s/hello-antd-77jxp
hey I was wondering, since adding a border will make the tick look square, then how could I change the thickness of it? stackoverflow.com/questions/62674344/…
0

Well, if someone still want to know the answer in 2023. For antd v5, you would add prefixCls prop in the Checkbox component like this

<Checkbox prefixCls="show-error" ...other props> {`ShowError`} </Checkbox> 

Then in your CSS file, you would add

.show-error-wrapper-checked > .show-error > .show-error-inner { background-color: #ff4d4f !important; border-color: #ff4d4f !important; } .show-error-wrapper > .show-error:hover > .show-error-inner { border-color: #ff4d4f !important; } 

Importantly, don't forget to add !important in your code, and that won't be any caveats of adding it here, since the class name is unique.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.