_form.css 1.67 KB
.checkbox,
.radio {
    position: relative;
    display: inline-block;

    label {
        padding-left: 33px;
        &:before {
            z-index: 8;
            border: 2px solid $black;
            content: "";
        }
        &:after {
            position: absolute;
            top: 6px;
            left: 12px;
            z-index: 9;
            display: none;
            content: "";
            width: 8px;
            height: 16px;
            transform: rotate(45deg);
            border: 2px solid $white;
            border-top: 0;
            border-left: 0;
        }
    }

    label:before,
    input {
        position: absolute;
        top: 0;
        left: 0;
        width: 30px;
        height: 30px;
    }
    input {
        z-index: 10;
        opacity: 0;
    }

    /* when checked */
    input:checked {
        ~ label:before {
            background: $black;
        }
        ~ label:after {
            display: block;
        }
    }

    /* when disabled */
    input:disabled {
        ~ label {
            color: #ccc;
        }
        ~ label:before {
            border-color: #e4e4e4;
        }
        &:checked {
            ~ label:before {
                background-color: #e4e4e4;
            }
        }
    }
}

.radio {
    label:before {
        border-radius: 50%;
    }

}

.switch {
    display: inline-block;
    input {
        display: none;
    }
    label {
        position: relative;
        display: block;
        width: 54px;
        height: 34px;
        background-color: $white;
        border: 1px solid #ddd;
        border-radius: 99999px;
        transition: 0.3s;

        &:after {
            content: "";
        }
    }
}