auto-resize-textarea

Auto resizes the height of any <textarea> according to the content.

Sources and documentation

Examples

Bootstrap 4



<textarea class="form-control auto-resize"></textarea>

Plain HTML


<textarea class="auto-resize"></textarea>

<textarea rows="2" cols="20" class="auto-resize"></textarea>

<textarea style="padding: 10px" rows="2" cols="20" class="auto-resize"></textarea>

<textarea style="padding: 10px; width: 280px; height: 30px;" rows="2" cols="10" class="auto-resize"></textarea>


<textarea id="textarea5" rows="1" cols="40" class="auto-resize"></textarea>

Script

<script src="src/auto-resize-textarea.js"></script>
<script>
    autoResizeTextarea(document.querySelectorAll("textarea.auto-resize"), { maxHeight: 320 })
</script>
By shaack.com engineering. License: MIT.