JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" maxlength="2" onkeypress="if (!isNaN(String.fromCharCode(window.event.keyCode))) return true; else return false;">