1
+ // BS5 switch
2
+ $form-check-input-width : 1.25em !default ;
3
+ $form-check-min-height : $font-size-base * $line-height-base !default ;
4
+ $form-check-padding-left : $form-check-input-width + .5em !default ;
5
+ $form-check-margin-bottom : .125rem !default ;
6
+ $form-check-label-color : null !default ;
7
+ $form-check-label-cursor : null !default ;
8
+ $form-check-transition : background-color .15s ease-in-out , background-position .15s ease-in-out , border-color .15s ease-in-out , box-shadow .15s ease-in-out !default ;
9
+
10
+ $form-check-input-active-filter : brightness (90% ) !default ;
11
+
12
+ $form-check-input-bg : $body-bg !default ;
13
+ $form-check-input-border : 1px solid rgba (0 , 0 , 0 , .25 ) !default ;
14
+ $form-check-input-border-radius : .25em !default ;
15
+ $form-check-radio-border-radius : 50% !default ;
16
+ $form-check-input-focus-border : $input-focus-border-color !default ;
17
+ $form-check-input-focus-box-shadow : $input-btn-focus-box-shadow !default ;
18
+
19
+ $form-check-input-checked-color : $component-active-color !default ;
20
+ $form-check-input-checked-bg-color : $component-active-bg !default ;
21
+ $form-check-input-checked-border-color : $form-check-input-checked-bg-color !default ;
22
+ $form-check-input-checked-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='#{$form-check-input-checked-color } ' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/></svg>" ) !default ;
23
+ $form-check-radio-checked-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='2' fill='#{$form-check-input-checked-color } '/></svg>" ) !default ;
24
+
25
+ $form-check-input-indeterminate-color : $component-active-color !default ;
26
+ $form-check-input-indeterminate-bg-color : $component-active-bg !default ;
27
+ $form-check-input-indeterminate-border-color : $form-check-input-indeterminate-bg-color !default ;
28
+ $form-check-input-indeterminate-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='#{$form-check-input-indeterminate-color } ' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/></svg>" ) !default ;
29
+
30
+ $form-switch-color : rgba (0 , 0 , 0 , .25 ) !default ;
31
+ $form-switch-width : 2em !default ;
32
+ $form-switch-padding-left : $form-switch-width + .5em !default ;
33
+ $form-switch-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-color } '/></svg>" ) !default ;
34
+ $form-switch-border-radius : $form-switch-width !default ;
35
+
36
+ $form-switch-focus-color : hsla (211 , 100% , 75% , 1 ) !default ;
37
+ $form-switch-focus-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-focus-color } '/></svg>" ) !default ;
38
+
39
+ $form-switch-checked-color : $component-active-color !default ;
40
+ $form-switch-checked-bg-image : url (" data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='3' fill='#{$form-switch-checked-color } '/></svg>" ) !default ;
41
+ $form-switch-checked-bg-position : right center !default ;
42
+
43
+ .form-check-input {
44
+ width : $form-check-input-width ;
45
+ height : $form-check-input-width ;
46
+ margin-top : ($line-height-base - $form-check-input-width ) / 2 ; // line-height minus check height
47
+ vertical-align : top ;
48
+ background-color : $form-check-input-bg ;
49
+ background-repeat : no-repeat ;
50
+ background-position : center ;
51
+ background-size : contain ;
52
+ border : $form-check-input-border ;
53
+ appearance : none ;
54
+ color-adjust : exact ; // Keep themed appearance for print
55
+ @include transition ($form-check-transition );
56
+
57
+ & [type = " checkbox" ] {
58
+ @include border-radius ($form-check-input-border-radius );
59
+ }
60
+
61
+ & [type = " radio" ] {
62
+ @include border-radius ($form-check-radio-border-radius );
63
+ }
64
+
65
+ & :active {
66
+ filter : $form-check-input-active-filter ;
67
+ }
68
+
69
+ & :focus {
70
+ border-color : $form-check-input-focus-border ;
71
+ outline : 0 ;
72
+ box-shadow : $form-check-input-focus-box-shadow ;
73
+ }
74
+
75
+ & :checked {
76
+ background-color : $form-check-input-checked-bg-color ;
77
+ border-color : $form-check-input-checked-border-color ;
78
+
79
+ & [type = " checkbox" ] {
80
+ @if $enable-gradients {
81
+ background-image : escape-svg ($form-check-input-checked-bg-image ), linear-gradient (180deg , lighten ($form-check-input-checked-bg-color , 10% ), $form-check-input-checked-bg-color );
82
+ } @else {
83
+ background-image : escape-svg ($form-check-input-checked-bg-image );
84
+ }
85
+ }
86
+
87
+ & [type = " radio" ] {
88
+ @if $enable-gradients {
89
+ background-image : escape-svg ($form-check-radio-checked-bg-image ), linear-gradient (180deg , lighten ($form-check-input-checked-bg-color , 10% ), $form-check-input-checked-bg-color );
90
+ } @else {
91
+ background-image : escape-svg ($form-check-radio-checked-bg-image );
92
+ }
93
+ }
94
+ }
95
+
96
+ & [type = " checkbox" ]:indeterminate {
97
+ background-color : $form-check-input-indeterminate-bg-color ;
98
+ border-color : $form-check-input-indeterminate-border-color ;
99
+
100
+ @if $enable-gradients {
101
+ background-image : escape-svg ($form-check-input-indeterminate-bg-image ), linear-gradient (180deg , lighten ($form-check-input-checked-bg-color , 10% ), $form-check-input-checked-bg-color );
102
+ } @else {
103
+ background-image : escape-svg ($form-check-input-indeterminate-bg-image );
104
+ }
105
+ }
106
+
107
+ & :disabled {
108
+ pointer-events : none ;
109
+ filter : none ;
110
+ opacity : .5 ;
111
+ }
112
+
113
+ // Use disabled attribute in addition of :disabled pseudo-class
114
+ // See: https://github.com/twbs/bootstrap/issues/28247
115
+ & [disabled ],
116
+ & :disabled {
117
+ ~ .form-check-label {
118
+ opacity : .5 ;
119
+ }
120
+ }
121
+ }
122
+
123
+ .form-switch {
124
+ padding-left : $form-switch-padding-left ;
125
+
126
+ .form-check-input {
127
+ width : $form-switch-width ;
128
+ margin-left : $form-switch-padding-left * -1 ;
129
+ background-image : escape-svg ($form-switch-bg-image );
130
+ background-position : left center ;
131
+ @include border-radius ($form-switch-border-radius );
132
+
133
+ & :focus {
134
+ background-image : escape-svg ($form-switch-focus-bg-image );
135
+ }
136
+
137
+ & :checked {
138
+ background-position : $form-switch-checked-bg-position ;
139
+
140
+ @if $enable-gradients {
141
+ background-image : escape-svg ($form-switch-checked-bg-image ), linear-gradient (180deg , $form-check-input-checked-bg-color , lighten ($form-check-input-checked-bg-color , 10% ));
142
+ } @else {
143
+ background-image : escape-svg ($form-switch-checked-bg-image );
144
+ }
145
+ }
146
+ }
147
+ }
0 commit comments