JSFiddle - React, Tailwind, and code Playground
HTML
<div class="fb-Search">
<input id="Input" class="fb-Search_Input" value="">
<span class="fb-Search_FauxInput" dir="rtl"></span>
<label class="fb-Search_Label" for="Input">Search</label>
</div>
CSS
* {
box-sizing: border-box;
}
body {
background-color: #555;
font-family: sans-serif;
}
.fb-Search {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
height: 44px;
padding: 5px 70px 5px 5px;
width: 400px;
position: relative;
background-color: #e4e4e4;
}
.fb-Search_Input {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.js .fb-Search_Input {
position: absolute;
left: -100vw;
}
.fb-Search_FauxInput {
display: none;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
max-width: 80%;
margin-top: 14px;
border: 0;
font-size: 20px;
font-size: 1.3rem;
color: #777;
background-color: #e4e4e4;
border-right: 3px solid transparent;
height: 3px;
}
.js .fb-Search_FauxInput {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.fb-Search_Input:focus ~ .fb-Search_FauxInput {
-webkit-animation: pulseAttention 1.5s cubic-bezier(.215, .61, .355, 1) forwards infinite;
animation: pulseAttention 1.5s cubic-bezier(.215, .61, .355, 1) forwards infinite;
}
.fb-Search_Label {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 5px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
color: #a7a7a7;
font-size: 15px;
}
.fb-Search_Input:not([value=""]) ~ .fb-Search_Label {
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
}
@-webkit-keyframes pulseAttention {
50% {
border-color: green;
}
}
@keyframes pulseAttention {
50% {
border-color: green;
}
}
JavaScript
document.documentElement.setAttribute("class", "js");
var searchFauxInput = document.querySelector(".fb-Search_FauxInput");
var searchBox = document.getElementById("Input");
searchBox.addEventListener("keyup", function copyInput(event) {
searchFauxInput.textContent = searchBox.value;
searchBox.setAttribute("value", searchBox.value);
}, false);
searchBox.focus();