The Textarea Component
Learn how to create a reusable Textarea component with React and Formik.
We'll cover the following
While the input field allows us to enter the text, we can only enter the text on one line. So whenever we want our users to enter multiline texts, like descriptions or comments, our best bet is to use the textarea
field. The textarea
will have more height than an input field so the user knows that they can enter multiline texts.
In general, creating a reusable Textarea
component is done the same way as creating a reusable input field component. One difference is that when we use the Field
component, we have to pass an as
prop with a value of "textarea"
. And if we are not using the Field
component, we have to use the textarea
HTML tag instead of the input
tag.
Get hands-on with 1400+ tech skills courses.