body {
    margin: 0;
    display: flex;
    justify-content: center;
    height: 100vh;
    align-items: center;
    transition: .4s;
}

.input {
    visibility: hidden;
}

.label {
    width: 80px;
    position: absolute;
    border-radius: 20px;
    height: 40px;
    background-color: lightgray;
}

.circle {
    width: 34px;
    background-color: white;
    height: 34px;
    border-radius: 50%;
    top: 3px;
    position: absolute;
    left: 3px;
    animation: toggleOff .4s linear forwards;
}

.input:checked + .label {
    background-color: salmon;
}

.input:checked + .label .circle {
    animation: toggleOn .4s linear forwards;
}

@keyframes toggleOn {
    0%{
        transform: translateX(0);
    }

    100%{
        transform: translateX(40px);
    }
}

@keyframes toggleOff {
    0%{
        transform: translateX(40px);
    }

    100%{
        transform: translateX(0);
    }
}