JSFiddle - React, Tailwind, and code Playground

by henriqpohl

HTML

<div class="container">
  <div class="text">MY FORM</div>

  <form action="#">
    <div class="form-row">
      <div class="input-data">
        <input type="text" required />
        <div class="underline"></div>
        <label for="">Nome</label>
      </div>
      <div class="input-data">
        <input type="text" />
        <div class="underline"></div>
        <label for="">Empresa</label>
      </div>
    </div>

  </form>
</div>

CSS

* {
    margin: 0;
    padding: 0;
    outline: none;
    box-sizing: border-box;
    font-family:sans-serif;
  }
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    font-family: sans-serif;
  }
  .container {
    max-width: 950px;
    background: #fff;
    width: 950px;
    padding: 25px 40px 10px 40px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.8);
  }
  .container .text {
    text-align: center;
    font-size: 41px;
    font-weight: 600;
    font-family: "Poppins", sans-serif;
  }
  .container form {
    padding: 30px 0 0 0;
  }
  .container form .form-row {
    display: flex;
    margin: 32px 0;
  }
  form .form-row .input-data {
    width: 100%;
    height: 40px;
    margin: 0 20px;
    position: relative;
  }

  form .form-row .input-data-check {
    width: 100%;
    margin: 0 20px;
    position: relative;
  }
  
  .input-data input {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    font-size: 17px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  }

  .input-data input:focus ~ label,
  .input-data input:valid label {
    transform: translateY(-20px);
    font-size: 14px;
    color: #2e4f5c;
  }
  
  .input-data label {
    position: absolute;
    pointer-events: none;
    bottom: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
  }

  .input-data .underline {
    position: absolute;
    bottom: 0;
    height: 2px;
    width: 100%;
  }
  .input-data .underline:before {
    position: absolute;
    content: "";
    height: 2px;
    width: 100%;
    background: #2e4f5c;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s ease;
  }
  .input-data input:focus ~ .underline:before,
  .input-data input:valid ~ .underline:before {
    transform: scale(1);
  }