I would like to apply the style to Formik's tag for react. How can I do?
<ErrorMessage name="email"></ErrorMessage>
I try with component={Custom} but don't work.
I use Tailwindcss.
Thanks if you want to help me.
To add a class to a React component, use className="theClass"
. Formik's ErrorMessage.component property takes a value of a custom component, e.g. component={Custom}
as you have, or it can take an HTML container, e.g. component="div"
. Assuming this is not a Tailwind port to React, "div" is appropriate. Putting these two together, you can apply Tailwind-style invalid message styling thus:
<ErrorMessage name="emailAddress" component="div" className="text-red-500 text-xs italic" />
<ErrorMessage name="field name" component="div" className="some classes" />
add "component" field for ErrorMessage component
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With