JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' size='10'/>
JavaScript
$("input[type='text']").bind('keydown', function () {
$(this).attr("size", Math.max(10,$(this).val().length) );
});
<input type='text' size='10'/>
$("input[type='text']").bind('keydown', function () {
$(this).attr("size", Math.max(10,$(this).val().length) );
});