JSFiddle - React, Tailwind, and code Playground

by John Doe

HTML

<input type="password" id="pass">
<button id="showPassBtn">Show Pass</button>

JavaScript

const passwordInput = document.getElementById('pass');
const showPassBtn = document.getElementById('showPassBtn');

showPassBtn.addEventListener('click', function() {
  if (passwordInput.type === 'password') {
    passwordInput.type = 'text';
  } else {
    passwordInput.type = 'password';
  }
});