JSFiddle - React, Tailwind, and code Playground

by sesubash

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: 2px;
 font-family: serif;
}

JavaScript

function resizeInput() {
    $(this).css('width', $(this).val().length * 6);
}

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