<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto Resize Textarea</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<div class="container mt-5">
<h3>Bootstrap Textarea Height Auto Resize
<label for="exampleTextarea">Example Textarea</label>
<textarea class="form-control" id="exampleTextarea" rows="1"></textarea>
// Use jQuery to select the textarea by ID
$(document).ready(function(){
$('#exampleTextarea').on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';