JSFiddle - React, Tailwind, and code Playground

by webwakko

HTML

<input type="text" value="For in that sleep of death, what dreams may come" />

<input type="text" value="what dreams?" />

CSS

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

JavaScript

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

$('input[type="text"]')
    // event handler
    .keyup(resizeInput)
    // resize on page load
    .each(resizeInput);