JSFiddle - React, Tailwind, and code Playground
by Alin Guta
HTML
<textarea>
$(document).ready(function(){
setTimeout(function(){
alert('I'm just a piece of code');
},2000);
});
</textarea>
CSS
body{
background:#222;
}
textarea{
width:500px !important;
height:auto;
color:#fff;
background:#333;
border:none;
display:table;
}
JavaScript
$('textarea').each(function () {
this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
}).on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
$('textarea').trigger('input');