JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="text"/>
<label for="text" id="hint">Some text<span style="color: red">*</span></label>
CSS
input {
width: 200px;
}
label {
z-index: 100;
position: relative;
left: -200px;
cursor: text;
}
JavaScript
$('#text').focus(function() {
$('#hint').hide();
});
$('#text').blur(function() {
if ($(this).val().trim() === '') {
$('#hint').show();
}
});