aboutsummaryrefslogtreecommitdiff
path: root/scss/_custom-forms.scss
diff options
context:
space:
mode:
authorGijs Boddeus <[email protected]>2018-12-12 14:28:25 +0100
committerXhmikosR <[email protected]>2018-12-12 15:28:25 +0200
commit180a06eeb7484048c6bfb381b04bd96a858d42e5 (patch)
tree5d05da005cb1023d4e20261c5231b95bd6297fff /scss/_custom-forms.scss
parentdbadf24bb31379d1310c50bce5c40457fe1b729e (diff)
downloadbootstrap-180a06eeb7484048c6bfb381b04bd96a858d42e5.tar.xz
bootstrap-180a06eeb7484048c6bfb381b04bd96a858d42e5.zip
Add switch custom form control (#23004)
Diffstat (limited to 'scss/_custom-forms.scss')
-rw-r--r--scss/_custom-forms.scss41
1 files changed, 41 insertions, 0 deletions
diff --git a/scss/_custom-forms.scss b/scss/_custom-forms.scss
index e999daf0c..71eb746b8 100644
--- a/scss/_custom-forms.scss
+++ b/scss/_custom-forms.scss
@@ -161,6 +161,47 @@
}
+// switches
+//
+// Tweak a few things for switches
+
+.custom-switch {
+ padding-left: $custom-switch-width + ($custom-control-gutter - $custom-control-indicator-size);
+
+ .custom-control-label {
+ &::before {
+ left: -($custom-switch-width + ($custom-control-gutter - $custom-control-indicator-size));
+ width: $custom-switch-width;
+ pointer-events: all;
+ border-radius: $custom-switch-indicator-border-radius;
+ }
+
+ &::after {
+ top: calc(#{(($font-size-base * $line-height-base - $custom-control-indicator-size) / 2)} + #{$custom-control-indicator-border-width * 2});
+ left: calc(#{-($custom-switch-width + ($custom-control-gutter - $custom-control-indicator-size))} + #{$custom-control-indicator-border-width * 2});
+ width: $custom-switch-indicator-size;
+ height: $custom-switch-indicator-size;
+ background-color: $custom-control-indicator-border-color;
+ border-radius: $custom-switch-indicator-border-radius;
+ @include transition(transform .15s ease-in-out, $custom-forms-transition);
+ }
+ }
+
+ .custom-control-input:checked ~ .custom-control-label {
+ &::after {
+ background-color: $custom-control-indicator-bg;
+ transform: translateX($custom-switch-width - $custom-control-indicator-size);
+ }
+ }
+
+ .custom-control-input:disabled {
+ &:checked ~ .custom-control-label::before {
+ background-color: $custom-control-indicator-checked-disabled-bg;
+ }
+ }
+}
+
+
// Select
//
// Replaces the browser default select with a custom one, mostly pulled from