JSFiddle - React, Tailwind, and code Playground

HTML

<div id="casella" contenteditable="true">ciao<input type="hidden" name="casella" /></div>

CSS

div {
    border:1px solid black;
    padding:2px;
    display:inline;
}

JavaScript

var div = document.getElementById("casella");

div.onkeyup = function() {
    this.childNodes[1].value = this.textContent;
};