• Home
  • /
  • Stylish Login & Signup Form with Dark Mode

Stylish Login & Signup Form with Dark Mode | Glassmorphism UI Design

HTML

				
					<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Login & Signup | Learn with Arshyan</title>
  <link rel="stylesheet" href="style.css" />
    <link rel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"/>
  <script src="https://kit.fontawesome.com/yourkit.js" crossorigin="anonymous"></script>
</head>
<body>

  <div class="container">
  <!-- Theme Toggle Switch -->
<div class="theme-switch">
  <input type="checkbox" id="theme-toggle">
  <label for="theme-toggle" class="switch-label">
    <span class="switch-ball">
      <i class="fas fa-moon" id="moon-icon"></i>
      <i class="fas fa-sun" id="sun-icon"></i>
    </span>
  </label>
</div>



    <!-- Tabs -->
    <div class="tab-header">
      <button class="tab-btn active" id="login-tab">Login</button>
      <button class="tab-btn" id="signup-tab">Signup</button>
    </div>

    <!-- Login Form -->
    <form class="form active" id="login-form">
      <div class="input-group">
        <label for="login-email">Email</label>
        <input type="email" id="login-email" placeholder="Enter your email" required />
      </div>
     <div class="input-group">
  <label for="password">Password</label>
  <div class="password-wrapper">
    <input type="password" id="login-password" placeholder="Enter password">
    <i class="fas fa-eye toggle-password" data-target="login-password"></i>
  </div>
</div>
      <div class="input-options">
        <label><input type="checkbox" /> Remember me</label>
        <a href="#">Forgot password?</a>
      </div>
      <button type="submit" class="submit-btn">Login</button>

      <div class="social-login">
        <button type="button" class="google"><i class="fab fa-google"></i> Google</button>
        <button type="button" class="facebook"><i class="fab fa-facebook-f"></i> Facebook</button>
        <button type="button" class="twitter"><i class="fab fa-twitter"></i> Twitter</button>
      </div>
    </form>

    <!-- Signup Form -->
    <form class="form" id="signup-form">
      <div class="input-group">
        <label for="signup-name">Full Name</label>
        <input type="text" id="signup-name" placeholder="Enter your name" required />
      </div>
      <div class="input-group">
        <label for="signup-email">Email</label>
        <input type="email" id="signup-email" placeholder="Enter your email" required />
      </div>
    <div class="input-group">
  <label for="password">Password</label>
  <div class="password-wrapper">
    <input type="password" id="login-password" placeholder="Enter password">
    <i class="fas fa-eye toggle-password" data-target="login-password"></i>
  </div>
</div>
      <div class="input-options">
        <label><input type="checkbox" required /> I agree to terms</label>
      </div>
      <button type="submit" class="submit-btn">Signup</button>

      <div class="social-login">
        <button type="button" class="google"><i class="fab fa-google"></i> Google</button>
        <button type="button" class="facebook"><i class="fab fa-facebook-f"></i> Facebook</button>
        <button type="button" class="twitter"><i class="fab fa-twitter"></i> Twitter</button>
      </div>
    </form>
  </div>

  <script src="script.js"></script>
</body>
</html>

				
			

CSS

				
					/* ===== BASE RESET ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

/* ===== BODY STYLES ===== */
body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #8e2de2, #4a00e0);
  transition: background 0.4s ease;
  overflow: hidden;
}

body.dark {
  background: linear-gradient(135deg, #121212, #000000);
}

/* ===== CONTAINER ===== */
.container {
  position: relative;
  width: 400px;
  padding: 2rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  color: #fff;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ===== THEME TOGGLE SWITCH ===== */
.theme-switch {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.theme-switch input {
  display: none;
}

.switch-label {
  display: inline-block;
  width: 60px;
  height: 30px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

.switch-ball {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  color: #ffcc00;
  font-size: 0.9rem;
}

input:checked + .switch-label .switch-ball {
  transform: translateX(30px);
}

/* Icon visibility */
#sun-icon,
#moon-icon {
  position: absolute;
  transition: opacity 0.3s ease;
  font-size: 1rem;
}

#sun-icon {
  opacity: 0;
}

body.dark #sun-icon {
  opacity: 1;
}

body.dark #moon-icon {
  opacity: 0;
}

/* ===== TAB HEADERS ===== */
.tab-header {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1.5rem;
}

.tab-header button {
  flex: 1;
  padding: 0.6rem;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
}

.tab-header button.active {
  border-color: #fff;
  font-weight: 600;
}

body.dark .tab-header button.active {
  border-color: #ffd700;
}

/* ===== FORM STYLES ===== */
.form {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.form.active {
  display: flex;
}

.input-group label {
  font-size: 0.9rem;
  color: #eee;
  margin-bottom: 4px;
  display: block;
}

.input-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  outline: none;
  font-size: 0.95rem;
}

.input-group input::placeholder {
  color: #ccc;
}

.input-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #ddd;
}

.input-options a {
  color: #ffd700;
  text-decoration: none;
}

.input-options a:hover {
  text-decoration: underline;
}

.submit-btn {
  padding: 0.75rem;
  border: none;
  background: #fff;
  color: #4a00e0;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s ease;
}

.submit-btn:hover {
  background: #f0f0f0;
}

body.dark .submit-btn {
  background: #ffd700;
  color: #000;
}

body.dark .submit-btn:hover {
  background: #e6c200;
}

/* ===== SOCIAL LOGIN BUTTONS ===== */
.social-login {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 10px;
}

.social-login button {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 0.6rem;
  border-radius: 8px;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.3s ease;
}

.social-login .google {
  background: #db4437;
}

.social-login .facebook {
  background: #3b5998;
}

.social-login .twitter {
  background: #1da1f2;
}

.social-login button:hover {
  filter: brightness(1.1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 420px) {
  .container {
    width: 90%;
    padding: 1.5rem;
  }

  .tab-header button {
    font-size: 0.9rem;
  }

  .social-login {
    flex-direction: column;
  }
}

.password-wrapper {
  position: relative;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.toggle-password {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  cursor: pointer;
  color: #ccc;
  font-size: 1rem;
  transition: color 0.3s ease;
}

.toggle-password:hover {
  color: #fff;
}

body.dark .toggle-password:hover {
  color: #ffd700;
}


				
			

JavaScript

				
					// ===== THEME TOGGLE =====
const toggle = document.getElementById('theme-toggle');
const body = document.body;
const sunIcon = document.getElementById('sun-icon');
const moonIcon = document.getElementById('moon-icon');

// Optional: Remember theme across visits
if (localStorage.getItem('theme') === 'dark') {
  body.classList.add('dark');
  toggle.checked = true;
}

toggle.addEventListener('change', () => {
  body.classList.toggle('dark');
  if (body.classList.contains('dark')) {
    localStorage.setItem('theme', 'dark');
  } else {
    localStorage.setItem('theme', 'light');
  }
});

// ===== FORM TAB SWITCHING =====
const loginTab = document.getElementById('login-tab');
const signupTab = document.getElementById('signup-tab');
const loginForm = document.getElementById('login-form');
const signupForm = document.getElementById('signup-form');

loginTab.addEventListener('click', () => {
  loginTab.classList.add('active');
  signupTab.classList.remove('active');
  loginForm.classList.add('active');
  signupForm.classList.remove('active');
});

signupTab.addEventListener('click', () => {
  signupTab.classList.add('active');
  loginTab.classList.remove('active');
  signupForm.classList.add('active');
  loginForm.classList.remove('active');
});

// ===== BASIC FORM VALIDATION (Optional) =====
// You can add this if needed
const submitButtons = document.querySelectorAll('.submit-btn');

submitButtons.forEach(btn => {
  btn.addEventListener('click', (e) => {
    e.preventDefault();
    alert('Form submitted (you can connect this to a backend)');
  });
});
// ===== PASSWORD SHOW/HIDE =====
const toggles = document.querySelectorAll('.toggle-password');

toggles.forEach(toggle => {
  toggle.addEventListener('click', () => {
    const inputId = toggle.getAttribute('data-target');
    const input = document.getElementById(inputId);
    const isPassword = input.type === 'password';

    input.type = isPassword ? 'text' : 'password';
    toggle.classList.toggle('fa-eye');
    toggle.classList.toggle('fa-eye-slash');
  });
});

				
			

Share this post

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top