JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.fakeyourbeauty.com/jquery.autosize.input.js"></script>
<textarea placeholder="Autosize" data-autosize-input='{ "space": 40 }'></textarea>
CSS
textarea {
width: 200px;
height:15px;
line-height:15px;
min-width: 200px;
max-width: 300px;
transition: width 0.25s;
resize:none;
overflow:hidden;
}
JavaScript
$('textarea').on({input: function(){
var totalHeight = $(this).prop('scrollHeight') - parseInt($(this).css('padding-top')) - parseInt($(this).css('padding-bottom'));
$(this).css({'height':totalHeight});
}
});