JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<input size="10">
CSS
input {
font-family:Courier;
}
JavaScript
var input = document.getElementsByTagName('input')[0];
input.onkeypress = input.onkeydown = function() {
this.size = ( this.value.length > 10 ) ? this.value.length : 10;
};