JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" value="" />

CSS

input {
 display: block;
 margin: 20px;
 width: auto;
 font-family: serif;
}

JavaScript

function resizeInput() {
    $(this).attr('size', $(this).val().length);
}

$('input[type="text"]')
    .keyup(resizeInput)
    .each(resizeInput);