How to make Textarea Auto Height?

Sometimes we may want our textarea height to expand depending on how much text user inputs.

We can do this with pure JavaScript by adding extra pixels to height when user changes the textarea input.

Here’s an example:

<textarea style="min-height: 50px" oninput="this.style.height = '5px'; this.style.height = (this.scrollHeight)+ 'px'"></textarea>

Output: