AI CSS Animations

Glassmorphism Login Form

A frosted sign in card with glass inputs and a solid button, floating between two slow orbs. Fields glow on focus with :focus-within, and the button gets a shine sweep on hover.

Also known as: glassmorphism login form html css, glass login page css, frosted login form.

HTML

<div class="gls-glassmorphism-login-form">
  <span class="gls-glassmorphism-login-form-orb gls-glassmorphism-login-form-orb-a" aria-hidden="true"></span>
  <span class="gls-glassmorphism-login-form-orb gls-glassmorphism-login-form-orb-b" aria-hidden="true"></span>
  <form class="gls-glassmorphism-login-form-card" action="#">
    <p class="gls-glassmorphism-login-form-title">Welcome back</p>
    <label class="gls-glassmorphism-login-form-field">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></svg>
      <input type="email" placeholder="Email" aria-label="Email" autocomplete="email">
    </label>
    <label class="gls-glassmorphism-login-form-field">
      <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>
      <input type="password" placeholder="Password" aria-label="Password" autocomplete="current-password">
    </label>
    <button class="gls-glassmorphism-login-form-submit" type="submit">Log in</button>
  </form>
</div>

CSS

.gls-glassmorphism-login-form {
  --c: var(--gls-color, #3b82f6);
  font-size: var(--gls-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 1.25em;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #0f172a), color-mix(in srgb, var(--c) 25%, #581c87));
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
}
.gls-glassmorphism-login-form-orb {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
}
.gls-glassmorphism-login-form-orb-a {
  left: 3.2em;
  top: 0.6em;
  width: 5.6em;
  height: 5.6em;
  background: linear-gradient(140deg, color-mix(in srgb, var(--c) 45%, #fff), var(--c));
  animation: gls-glassmorphism-login-form-float 6s ease-in-out infinite alternate;
}
.gls-glassmorphism-login-form-orb-b {
  right: 3.4em;
  bottom: 0.5em;
  width: 4.8em;
  height: 4.8em;
  background: linear-gradient(140deg, #fcd34d, #f43f5e);
  animation: gls-glassmorphism-login-form-float 7s ease-in-out -3s infinite alternate-reverse;
}
.gls-glassmorphism-login-form-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45em;
  width: 11.5em;
  margin: 0;
  padding: 0.85em 0.95em 0.95em;
  border-radius: 1em;
  background: color-mix(in srgb, #fff 16%, transparent);
  -webkit-backdrop-filter: blur(0.9em) saturate(1.5);
  backdrop-filter: blur(0.9em) saturate(1.5);
  border: 1px solid color-mix(in srgb, #fff 45%, transparent);
  box-shadow: 0 0.5em 1.5em -0.5em rgb(0 0 0 / 0.35), inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent);
}
.gls-glassmorphism-login-form-title {
  margin: 0 0 0.15em;
  font-size: 0.95em;
  font-weight: 700;
  text-align: center;
}
.gls-glassmorphism-login-form-field {
  display: flex;
  align-items: center;
  gap: 0.45em;
  height: 2.1em;
  padding: 0 0.7em;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: 0.65em;
  background: rgb(255 255 255 / 0.12);
  cursor: text;
  transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}
.gls-glassmorphism-login-form-field svg {
  flex: none;
  width: 0.85em;
  height: 0.85em;
  opacity: 0.8;
}
.gls-glassmorphism-login-form-field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.75em;
}
.gls-glassmorphism-login-form-field input::placeholder { color: rgb(255 255 255 / 0.7); }
.gls-glassmorphism-login-form-field:hover { background: rgb(255 255 255 / 0.17); }
.gls-glassmorphism-login-form-field:focus-within {
  border-color: rgb(255 255 255 / 0.75);
  background: rgb(255 255 255 / 0.2);
  box-shadow: 0 0 0 0.2em color-mix(in srgb, var(--c) 45%, transparent);
}
.gls-glassmorphism-login-form-submit {
  position: relative;
  overflow: hidden;
  height: 2.2em;
  margin-top: 0.2em;
  border: 0;
  border-radius: 0.65em;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
  color: #fff;
  font: 650 0.8em/1 system-ui, sans-serif;
  box-shadow: 0 0.4em 1em -0.4em color-mix(in srgb, var(--c) 80%, #000);
  cursor: pointer;
}
.gls-glassmorphism-login-form-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.5) 50%, transparent 65%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.gls-glassmorphism-login-form-submit:hover::after { transform: translateX(100%); }
.gls-glassmorphism-login-form-submit:focus-visible { outline: 2px solid #fff; outline-offset: 0.15em; }
@keyframes gls-glassmorphism-login-form-float {
  to { transform: translate(0.8em, 1.4em) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .gls-glassmorphism-login-form, .gls-glassmorphism-login-form *, .gls-glassmorphism-login-form::before, .gls-glassmorphism-login-form::after, .gls-glassmorphism-login-form *::before, .gls-glassmorphism-login-form *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --gls-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --gls-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar glass effects