JSFiddle - React, Tailwind, and code Playground

HTML

<div><input type="password"><button title="Show hide password"></button></div>

CSS

body {background: #333;}

input {
  box-sizing: border-box;
  width: 200px;
  height: 30px;
  padding-left: 8px;
  border: none;
}

button {
  vertical-align: top;
  width: 30px;
  height: 30px;
  border: none;
  background: #fff url(http://uxrepo.com/static/icon-sets/foundation/svg/fi-eye.svg) no-repeat center;
  background-size: 65%;
  cursor: pointer;
}

JavaScript

document.querySelector("button").addEventListener("click", function (){
	this.parentNode.querySelector("input").type = (this.parentNode.querySelector("input").type == "text") ? "password" : "texe";
}, false);