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) );
});