When using Bootstrap v5 and FontAwesome v5, I cannot get get the eyeball to appear to the right side of the form. Instead, it pulls the password field further to the right than the username field and the eye does not show.
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-lock"></i></span>
<input class="form-control" id="username" name="username" placeholder="Username" value="">
</div>
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-lock"></i></span>
<input class="form-control" id="password" name="password" placeholder="Password" value="">
<span class="input-group-text"><i class="far fa-eye-slash" id="togglePassword"></i></span>
</div>
Javascript
const togglePassword = document.querySelector("#togglePassword");
const password = document.querySelector("#password");
togglePassword.addEventListener("click", function () {
// toggle the type attribute
const type = password.getAttribute("type") === "password" ? "text" : "password";
password.setAttribute("type", type);
// toggle the eye icon
this.classList.toggle('fa-eye');
});