JSFiddle - React, Tailwind, and code Playground
HTML
<input id="test" type="text" />
<button />
awdaw
JavaScript
const input = document.getElementById('test');
input.addEventListener('input', (event) => {
input.value = input.value.replace(/^\s*(.*)$/, (wholeString, captureGroup) => captureGroup);
});