JSFiddle - React, Tailwind, and code Playground

HTML

<div>
  <input type="text" value="My value">
</div>

CSS

input {
  position: relative;
  border: 0;
  background-color: transparent;
  border-bottom: 1px solid #a0a0a0;
  padding-bottom: 2px;
  outline: 0;
}
div {
  position: relative;
  display: inline-block;
}
div.hover:after {
  content: '';
  display: block;
  height: 2px;
  width: 0;
  background-color: purple;
  animation-duration: 1s;
  animation-name: hover;
  animation-fill-mode: forwards;
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translate(-50%, 0);
}
@keyframes hover {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

JavaScript

$(document).ready(function() {
	$("div").on("click", function() {
  	$(this).addClass("hover")
  })
});