JSFiddle - React, Tailwind, and code Playground
HTML
<div class="form-fields-group">
<input type="text" id="name" class="form-fields-input" placeholder="Введите название группы" required>
<label class="form-fields-group-label" for="name">Название Группы</label>
<div class="bg"></div>
</div>
CSS
.form-fields-group {
position: relative;
}
.form-fields-group .bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #EAEAEE;
z-index: -1;
}
.form-fields-group-label {
position: absolute; top: 5px; left: 16px;
font-size: 13px;
color: #27252a;
font-family: 'Roboto', sans-serif;
padding-top: 5px;
}
.form-fields-input {
width: 100%;
padding: 30px 142px 8px 16px;
border: none;
border-radius: 5px;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background: transparent;
}
.form-fields-input:focus ~ .form-fields-group-label,
.form-fields-input:valid ~ .form-fields-group-label {
color: #00f;
}
.form-fields-input:focus ~ .bg,
.form-fields-input:valid ~ .bg{
background: red;
}