Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<title>Toggle Switch</title>
.switch {
position: relative;
.switch label {
width: 55px;
height: 23px;
position: absolute;
background-color: #999;
top: 0;
left: 0;
border-radius: 50px;
.switch input[type="checkbox"] {
visibility: hidden;
.switch label:after {
content: '';
width: 21px;
height: 21px;
border-radius: 50px;
position: absolute;
top: 1px;
left: 1px;
transition: all 0.1s;
background-color: white;
.switch input[type="checkbox"]:checked + label:after {
left: 33px;
.switch input[type="checkbox"]:checked + label {
background-color: green;
<div class="switch">
<input type="checkbox" id="checkbox1">
<label for="checkbox1"></label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.