Glassmorphism Login & Signup UI
This blog contains a complete Glassmorphism Login and Signup UI design built using HTML, CSS, and vanilla JavaScript. The UI includes theme switching, animations, toggle forms, and responsive layout.
Full Source Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Glassmorphism Login & Signup</title>
<style>
:root {
--background: #1a1a2e;
--color: #ffffff;
--primary-color: #0f3460;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "Poppins", sans-serif;
background: var(--background);
color: var(--color);
letter-spacing: 1px;
transition: background 0.3s ease;
}
a { text-decoration: none; color: var(--color); cursor: pointer; }
h1 { font-size: 2.2rem; text-align: center; margin-bottom: 1rem; }
.container {
display: flex; justify-content: center; align-items: center;
height: 100vh; position: relative; overflow: hidden;
}
.login-container { position: relative; width: 22rem; }
.form-container {
border: 1px solid hsla(0, 0%, 65%, 0.158);
box-shadow: 0 0 36px 1px rgba(0, 0, 0, 0.2);
border-radius: 10px;
backdrop-filter: blur(20px);
z-index: 99;
padding: 2rem;
transition: all 0.4s ease;
overflow: hidden;
}
.illustration {
position: absolute; top: -14%; right: -2px; width: 90%; opacity: 0.9;
}
form { display: flex; flex-direction: column; transition: opacity 0.3s ease; }
input {
display: block; padding: 14px; width: 100%; margin: 1rem 0;
color: var(--color); outline: none; background-color: #9191911f;
border: none; border-radius: 5px; font-weight: 500; font-size: 15px;
backdrop-filter: blur(15px);
}
input:focus {
box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.2);
animation: wobble 0.3s ease-in;
}
button {
background-color: var(--primary-color); color: var(--color);
padding: 13px; border-radius: 5px; font-size: 17px;
letter-spacing: 1px; font-weight: bold; width: 100%;
cursor: pointer; margin-top: 0.5rem; transition: all 0.2s ease-in-out;
border: none;
}
button:hover {
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.15); transform: scale(1.02);
}
.circle {
width: 8rem; height: 8rem; background: var(--primary-color);
border-radius: 50%; position: absolute; transition: 0.3s ease;
}
.circle-one {
top: 0; left: 0; z-index: -1; transform: translate(-45%, -45%);
}
.circle-two {
bottom: 0; right: 0; z-index: -1; transform: translate(45%, 45%);
}
.register-forget {
margin: 1rem 0; display: flex; justify-content: space-between;
font-size: 0.9rem; opacity: 0.8;
}
.theme-btn-container {
position: absolute; left: 0; bottom: 2rem; display: flex;
gap: 10px; padding-left: 1rem;
}
.theme-btn {
cursor: pointer; transition: all 0.3s ease-in; border-radius: 50%;
}
.theme-btn:hover { width: 40px !important; height: 40px !important; }
.toggle-link {
display: block; text-align: center; margin-top: 1rem; opacity: 0.8;
}
@keyframes wobble {
0% { transform: scale(1.025); }
25% { transform: scale(1); }
75% { transform: scale(1.025); }
100% { transform: scale(1); }
}
.hidden { display: none; }
</style>
</head>
<body>
<section class="container">
<div class="login-container">
<div class="circle circle-one"></div>
<div class="form-container">
<img src="https://raw.githubusercontent.com/hicodersofficial/glassmorphism-login-form/master/assets/illustration.png" class="illustration" />
<form id="loginForm">
<h1>LOGIN</h1>
<input type="email" placeholder="EMAIL" required />
<input type="password" placeholder="PASSWORD" required />
<button type="submit">LOGIN</button>
<div class="register-forget">
<a id="showSignup">Create Account</a>
<a href="#">Forgot Password?</a>
</div>
</form>
<form id="signupForm" class="hidden">
<h1>SIGN UP</h1>
<input type="text" placeholder="FULL NAME" required />
<input type="email" placeholder="EMAIL" required />
<input type="password" placeholder="PASSWORD" required />
<input type="password" placeholder="CONFIRM PASSWORD" required />
<button type="submit">REGISTER</button>
<a id="showLogin" class="toggle-link">Already have an account? Login</a>
</form>
</div>
<div class="circle circle-two"></div>
</div>
<div class="theme-btn-container"></div>
</section>
<script>
const themes = [
{ background: "#1A1A2E", color: "#FFFFFF", primaryColor: "#0F3460" },
{ background: "#461220", color: "#FFFFFF", primaryColor: "#E94560" },
{ background: "#192A51", color: "#FFFFFF", primaryColor: "#967AA1" },
{ background: "#F7B267", color: "#000000", primaryColor: "#F4845F" },
{ background: "#F25F5C", color: "#000000", primaryColor: "#642B36" },
{ background: "#231F20", color: "#FFF", primaryColor: "#BB4430" }
];
const setTheme = (theme) => {
const root = document.querySelector(":root");
root.style.setProperty("--background", theme.background);
root.style.setProperty("--color", theme.color);
root.style.setProperty("--primary-color", theme.primaryColor);
};
const displayThemeButtons = () => {
const btnContainer = document.querySelector(".theme-btn-container");
themes.forEach((theme) => {
const div = document.createElement("div");
div.className = "theme-btn";
div.style.cssText = "background:" + theme.background + ";width:25px;height:25px;";
btnContainer.appendChild(div);
div.addEventListener("click", () => setTheme(theme));
});
};
displayThemeButtons();
const loginForm = document.getElementById("loginForm");
const signupForm = document.getElementById("signupForm");
const showSignup = document.getElementById("showSignup");
const showLogin = document.getElementById("showLogin");
showSignup.addEventListener("click", () => {
loginForm.classList.add("hidden");
signupForm.classList.remove("hidden");
});
showLogin.addEventListener("click", () => {
signupForm.classList.add("hidden");
loginForm.classList.remove("hidden");
});
loginForm.addEventListener("submit", (e) => {
e.preventDefault();
alert("Login Successful!");
});
signupForm.addEventListener("submit", (e) => {
e.preventDefault();
alert("Account Created Successfully!");
});
</script>
</body>
</html>
This complete code can be directly used in your project for a modern and stylish authentication UI.