body {
    margin: 0px;
    display: flex;
    justify-content: center;
    height: 100vh;
    align-items: center;
    transition: 0.4s;
}

.input {
    visibility: hidden;
}

.label {
    height: 40px;
    width: 80px;
    background-color: lightgrey;
    position: absolute;
    border-radius: 20px;
    cursor: pointer;
}

.circle {
    width: 34px;
    height: 34px;
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 3px; 
    left: 3px; 
    animation: toggleOff 0.4s linear forwards;
}

.input:checked + .label {
    background-color: white;

}

.input:checked + .label .circle{
    animation: toggleOn 0.4s linear forwards;
    background-color: black;
}

@keyframes toggleOn {
    0% {
        transform: translateX(0px);
    } 
    100% {
        transform: translateX(40px);
    }
}

@keyframes toggleOff {
    0% {
        transform: translateX(40px);
    } 
    100% {
        transform: translateX(0px);
    }
}