Toggle Sidebar
Tools99
Open Search
Toggle theme
Home
All Tools
CSS Switch Generator
CSS Switch Generator
Create CSS toggle switches.
Width
60px
Height
34px
"On" Color
"Off" Color
Knob Color
Preview
HTML
<label class="switch"> <input type="checkbox"> <span class="slider"></span> </label>
Copy
CSS
.switch { position: relative; display: inline-block; width: 60px; height: 34px; } .switch input { opacity: 0; width: 0; height: 0; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #9ca3af; transition: .4s; border-radius: 34px; } .slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: #ffffff; transition: .4s; border-radius: 50%; } input:checked + .slider { background-color: #2563eb; } input:focus + .slider { box-shadow: 0 0 1px #2563eb; } input:checked + .slider:before { transform: translateX(30px); }
Copy