JSFiddle - React, Tailwind, and code Playground

by mcake

HTML

<div class="border-input">
  <input type="text" class="border-input__input">
  <div class="border-input__label">
     Имя
  </div>
</div>
<div class="border-input">
  <input type="text" class="border-input__input">
  <div class="border-input__label">
    Фамилия
  </div>
</div>

SCSS

*{
  box-sizing: border-box;
}
body{
  background-color: #ccc;
}

.border-input {
  position: relative;
  height: 50px;
  width: 200px;
  margin: 20px 0px;
  background-color: #fff;
  &__label{
    position: absolute;
    z-index: 2;
    left: 10px;
    top: -6px;
    line-height: 12px;
    font-size: 12px;
    padding: 0px 5px;
    background-position: 0px 5px;
    background-size: 100% 2px;
    background-repeat: no-repeat;
  }
  &__input{
    height: 100%;
    width: 100%;
    border: 0;
    position: relative;
    z-index: 2;
    background-color: transparent;
    padding: 0px 15px;
    &:focus{
      border: 1px solid #add8e6;
      & ~ .border-input__label {
        background-image: linear-gradient(to right, #fff, #fff);
      }
    }
  }
}