Created
July 1, 2020 12:03
-
-
Save ricardocanelas/e473d7f859372f7dd577922a261f4cb5 to your computer and use it in GitHub Desktop.
get-boostrap-custom-checkbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$custom-checkbox-color: $color-brand-wcag-3-1; | |
$custom-checkbox-size: 24px; | |
.custom-checkbox { | |
.custom-control-input { | |
opacity: 0; | |
width: $custom-checkbox-size; | |
height: $custom-checkbox-size; | |
} | |
.custom-control-label { | |
position: relative; | |
margin-bottom: 0; | |
vertical-align: top; | |
padding-left: 0.5rem; | |
} | |
.custom-control-label::before { | |
content: ''; | |
position: absolute !important; | |
top: 0rem; | |
left: -$custom-checkbox-size; | |
display: block; | |
width: $custom-checkbox-size; | |
height: $custom-checkbox-size; | |
pointer-events: none; | |
border: #909090 solid 1px !important; | |
border-radius: 4px; | |
box-sizing: border-box; | |
} | |
// stick | |
.custom-control-label::after { | |
content: ''; | |
position: absolute; | |
top: 0; | |
left: -$custom-checkbox-size; | |
display: block; | |
width: $custom-checkbox-size; | |
height: $custom-checkbox-size; | |
background-size: 40%; | |
background-position: center; | |
background-repeat: no-repeat; | |
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26l2.974 2.99L8 2.193z'/%3e%3c/svg%3e"); | |
box-sizing: border-box; | |
} | |
.custom-control-input:focus ~ .custom-control-label::before { | |
border-color: #909090 !important; | |
box-shadow: 0 0 0 0.2rem rgba(1, 160, 160, 0.25) !important; | |
} | |
.custom-control-input:checked ~ .custom-control-label::before { | |
border-color: $custom-checkbox-color !important; | |
background-color: $custom-checkbox-color !important; | |
} | |
.custom-control-input:focus:not(:checked) ~ .custom-control-label::before { | |
border-color: #909090 !important; | |
} | |
.custom-control-input:not(:disabled):active ~ .custom-control-label::before { | |
background-color: #c3ecec !important; | |
border-color: #c3ecec !important; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment