Skip to content

Glass Toggle Switch

A frosted glass toggle switch with a glowing gradient track and smooth knob physics.

Glass Toggle Switch

by FreeCsStyles Dev's

GlassmorphismGlassmorphism
🌐
#toggle#switch#glass#settings

Embed this component

Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/glass-toggle.

<iframe src="/embed/glass-toggle" sandbox="allow-scripts" loading="lazy" title="Glass Toggle Switch" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Glass Toggle Switch. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.

HTML
<label class="glass-toggle">
  <input type="checkbox" checked>
  <span class="glass-track">
    <span class="glass-knob"></span>
  </span>
</label>
CSS
.glass-toggle {
  display: inline-flex;
  cursor: pointer;
}

.glass-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.glass-track {
  width: 56px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  transition: background 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.glass-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: left 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.glass-toggle input:checked ~ .glass-track {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.glass-toggle input:checked ~ .glass-track .glass-knob {
  left: 28px;
}

Where Glass Toggle Switch fits

  • Settings
  • Dark Mode
  • Feature Flags

Topics

  • #toggle
  • #switch
  • #glass
  • #settings