JSFiddle - React, Tailwind, and code Playground

HTML

<textarea></textarea>

CSS

textarea{
    background-color:#FFFFB6;
    line-height:18px;
}

JavaScript

$('textarea').keyup(function() {
    var that = $(this);
  	var rows = that.val().split("\n").length;
	var lh = parseInt(that.css('line-height'));     
    if(2<rows)
        that.stop().animate({height:lh*rows},50,'linear',function(){
           that.attr('rows', rows);
        })
}).attr('rows', 2);