JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="tb" />

JavaScript

$(function() {
$('#tb').keypress(function() {
    $(this).prop('type', 'password');
}).blur(function() {
    if ($(this).val() === '')
        $(this).prop('type', 'text');
});
});