JSFiddle - React, Tailwind, and code Playground
HTML
<div class="input">
<input type="text" placeholder=" ">
<label class="placeholder">Name <span>*</span></label>
</div>
CSS
body {
text-align: center;
}
input {
padding: 0.4em 1.4em;
font-size: 2em;
}
input:placeholder-shown+.placeholder {
opacity: 1;
transform: translateX(0);
}
input:active+.placeholder,
input:focus+.placeholder {
opacity: 0;
transform: translateX(20px);
}
.input {
display: inline;
position: relative
}
.placeholder {
position: absolute;
left: 1em;
top: -0.5em;
font-size: 1.4em;
font-family: sans-serif;
transition: 200ms all;
opacity: 0;
transform: translateX(20px);
pointer-events: none;
}
.placeholder span {
color: blue;
font-weight: 700;
}