Skip to content

Change the checkbox colour dynamically #2833

Answered by maddhruv
DiegoMcDipster asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @DiegoMcDipster
The easiest was you can achieve this is -
let's say the checkbox field name is tac, so now formik (useFormik) can give you an object of all the values on your form (which can be signup/login, depends upon your use case) and now you can simply use values.tac to refer if the checkbox is selected or not. And on the basis of this value (values.tac) you can change the corresponding properties/stylings for the checkbox

<Checkbox color={values.tac ? 'green' : 'red'} />

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@DiegoMcDipster
Comment options

Answer selected by maddhruv
Comment options

You must be logged in to vote
1 reply
@DiegoMcDipster
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants