// Checkboxes and radios // // Base class takes care of all the key behavioral aspects. .custom-control { padding-left: 0; .custom-control-input { &:checked { ~ .custom-control-label, ~ .custom-control-label::before { border-color: $input-focus-border-color; } } &:focus:not(:checked) ~ .custom-control-label::before { border-color: $input-border-color; } } + .custom-control:not(.custom-control-inline) { margin-top: ($spacer * .25); } } .custom-checkbox, .custom-radio { min-width: $custom-control-gutter + $custom-control-indicator-size; } // sets minimum width to have space even if custom-control-label isn't there // Custom control indicators // // Build the custom controls out of pseudo-elements. .custom-control-label { padding-left: $custom-control-gutter + $custom-control-indicator-size; min-width: $custom-control-gutter + $custom-control-indicator-size; min-height: $custom-control-indicator-size; font-weight: $font-weight-normal; cursor: pointer; // Background-color and icon &::before, &::after { top: .3rem; left: 0; } &::before { border: $border-width solid $border-color; } &::after { cursor: pointer; } } // Radios // // Tweak just a few things for radios. .custom-radio { .custom-control-label::after { background-size: 45% 45%; } } // Select // // Replaces the browser default select with a custom one, mostly pulled from // https://primer.github.io/. // .custom-select { display: block; width: auto; max-width: 100%; font-weight: $btn-font-weight; cursor: pointer; box-shadow: none; } // File // // Custom file input. .custom-file-label { font-weight: $font-weight-normal; cursor: pointer; border-radius: 0 $btn-border-radius $btn-border-radius 0; overflow: hidden; &::after { font-weight: $btn-font-weight; border-radius: 0 $btn-border-radius $btn-border-radius 0; } } // Block // // Custom control block (ex: for images) .custom-control-block { padding: 0; .custom-control-label { margin-bottom: 0; padding: ($spacer * 1.5) $spacer ($spacer * 2); border: $border-width solid $border-color; border-radius: $border-radius; cursor: pointer; transition: $transition-base; &:hover { border-color: $gray-600; } &::before, &::after { top: auto; left: 50%; bottom: ($spacer * .5); margin-left: -9px; } } } // Without radio or checkbox indicator .custom-control-block:not(.custom-radio):not(.custom-checkbox) { .custom-control-label { padding: ($spacer * .5); &::before, &::after { display: none; } } } // switches // // Tweak a few things for switches .custom-switch { padding-left: 0; .custom-control-label { padding-left: $custom-switch-width + $custom-control-gutter; &::before, &::after { left: 0; } &::before { padding-left: 28px; font-size: 12px; line-height: 16px; color: $text-muted; font-family: "FontAwesome"; content: "\f00d"; background-color: $body-bg; } &::after { top: 0; background-color: $white; border: $border-width solid $border-color; border-radius: 50%; @include transition(transform .15s ease-in-out, $custom-forms-transition); } } .custom-control-input:checked ~ .custom-control-label { &::after { border-color: $input-focus-border-color; transform: translateX($custom-switch-width - $custom-switch-indicator-size); } &::before { content: ""; background-repeat: no-repeat; background-size: 30%; background-position: 6px 1px; background-image: $custom-checkbox-indicator-icon-checked; background-color: $custom-control-indicator-checked-bg; border-color: $input-focus-border-color; } } } // Styles needed to override :valid success styles provided by bootstrap... this is for server side forms only .custom-control-input { .was-validated &:valid { ~ .custom-control-label { color: inherit; &::before { background-color: inherit; } } &:checked { ~ .custom-control-label::before { background-color: $custom-control-indicator-checked-bg; } } } } .custom-file-input { .was-validated &:valid { ~ .custom-file-label { border-color: $custom-file-border-color; } } }