JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" maxlength="3">

JavaScript

setTimeout(() => {
document.querySelector('input').setAttribute('maxlength', 3);
}, 1000);