JSFiddle - React, Tailwind, and code Playground

by graphettion

HTML

<div class="container">
  <form>
    <div class="rc-form-group">
      <input type="text" required>
      <span class="rc-input-highlight"></span>
      <span class="rc-input-bar"></span>
      <label>Name</label>
    </div>

    <div class="rc-form-group">
      <input type="email" required>
      <span class="rc-input-highlight"></span>
      <span class="rc-input-bar"></span>
      <label>Email</label>
    </div>

    <button type="submit">
      asdf
    </button>
  </form>
</div>

CSS

.container {
  margin-top: 3rem;
}


/* form starting stylings ------------------------------- */

.rc-form-group {
  position: relative;
  margin-bottom: 45px;
}

.rc-form-group > input {
  font-size: 18px;
  padding: 10px 10px 10px 5px;
  display: block;
  width: 300px;
  border: none;
  border-bottom: 1px solid #757575;
}

.rc-form-group > input:focus {
  outline: none;
}


/* LABEL ======================================= */

.rc-form-group > label {
  color: #999;
  font-size: 18px;
  font-weight: normal;
  position: absolute;
  pointer-events: none;
  left: 5px;
  top: 10px;
  transition: 0.2s ease all;
  -moz-transition: 0.2s ease all;
  -webkit-transition: 0.2s ease all;
}


/* active state */

.rc-form-group > input:focus ~ label,
.rc-form-group > input:valid ~ label {
  top: -20px;
  font-size: 14px;
  color: #5264AE;
}


/* BOTTOM BARS ================================= */

.rc-input-bar {
  position: relative;
  display: block;
  width: 315px;
}

.rc-input-bar:before,
.rc-input-bar:after {
  content: '';
  height: 2px;
  width: 0;
  bottom: 1px;
  position: absolute;
  background: #0275d8;
  transition: 0.2s ease all;
  -moz-transition: 0.2s ease all;
  -webkit-transition: 0.2s ease all;
}

.rc-input-bar:before {
  left: 50%;
}

.rc-input-bar:after {
  right: 50%;
}


/* active state */

.rc-form-group > input:focus ~ .rc-input-bar:before,
.rc-form-group > input:focus ~ .rc-input-bar:after {
  width: 50%;
}


/* HIGHLIGHTER ================================== */

.rc-input-highlight {
  position: absolute;
  height: 60%;
  width: 100px;
  top: 25%;
  left: 0;
  pointer-events: none;
  opacity: 0.5;
}


/* active state */

.rc-form-group > input:focus ~ .rc-input-highlight {
  -webkit-animation: inputHighlighter 0.3s ease;
  -moz-animation: inputHighlighter 0.3s ease;
  animation: inputHighlighter 0.3s ease;
}


/* ANIMATIONS ================ */

@-webkit-keyframes inputHighlighter {
  from {
    background: #5264AE;
  }
  to {
    width: 0;
   ...