JSFiddle - React, Tailwind, and code Playground

HTML

<div class="field">
  <label for="input-name">Email address</label>
  <input id="input-name" type="name" />
</div>

CSS

body {
  font-family: sans-serif;
}
.field {
  position: relative;
  max-width: 250px;
}
label {
  box-sizing: border-box;
  display: block;
  font-size: .8125em;
  padding: .75em 12px;
  pointer-events: none;
  position: absolute;
  text-overflow: ellipsis;
  top: 0;
  text-align: left;

  user-select: none;
  white-space: nowrap;
  width: 100%;
  z-index: 1;
}
input {
  background-color: #f5f5f5;
  border:0;
  border-bottom:2px solid grey;
  font-size: 1.3125em;
  outline:0;
  padding-top:24px;
  padding-left:12px;
  padding-bottom:2px;
  width: 100%;
  
}

input:focus + label{
  color:red;
}

input:focus {
   border-bottom:2px solid red;
}