JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<div class="field">
<label class="placeholder" for="email">
Email Address
<span class="red">*</span>
</label>
<input id="email" type="text" />
</div>
</form>
CSS
.field {
position: relative;
height: 30px;
width: 200px;
}
input, label {
position: absolute;
top: 0;
left: 0;
bottom: 0;
top: 0;
background: transparent;
border: 0;
padding: 0;
margin: 0;
text-indent: 5px;
line-height: 30px;
}
JavaScript
$('.field input')
.on( 'focus', function () { $(this).siblings('label').hide(); } )
.on( 'blur', function () { if ( !$(this).val() ) $(this).siblings('label').show(); } );