JSFiddle - React, Tailwind, and code Playground

HTML

<div id="parent">
<input>
<div id="icon">

</div>
</div>

CSS

#icon {
  width: 10px;
  height: 10px;
  background-color: black;
  
  position: absolute;
  top: 0;
  left: 1ch;
}

#parent {
  position: relative;
}

JavaScript

let offset = 0;
const input = document.querySelector('input')
const icon = document.getElementById("icon")

input.addEventListener("input", (e) => {
 const newOff = e.target.value.length
 icon.style.left = `${newOff}ch`
})