_custom-forms.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // Embedded icons from Open Iconic.
  2. // Released under MIT and copyright 2014 Waybury.
  3. // https://useiconic.com/open
  4. // Checkboxes and radios
  5. //
  6. // Base class takes care of all the key behavioral aspects.
  7. .custom-control {
  8. position: relative;
  9. display: block;
  10. min-height: (1rem * $line-height-base);
  11. padding-left: $custom-control-gutter;
  12. }
  13. .custom-control-inline {
  14. display: inline-flex;
  15. margin-right: $custom-control-spacer-x;
  16. }
  17. .custom-control-input {
  18. position: absolute;
  19. z-index: -1; // Put the input behind the label so it doesn't overlay text
  20. opacity: 0;
  21. &:checked ~ .custom-control-label::before {
  22. color: $custom-control-indicator-checked-color;
  23. @include gradient-bg($custom-control-indicator-checked-bg);
  24. @include box-shadow($custom-control-indicator-checked-box-shadow);
  25. }
  26. &:focus ~ .custom-control-label::before {
  27. // the mixin is not used here to make sure there is feedback
  28. box-shadow: $custom-control-indicator-focus-box-shadow;
  29. }
  30. &:active ~ .custom-control-label::before {
  31. color: $custom-control-indicator-active-color;
  32. background-color: $custom-control-indicator-active-bg;
  33. @include box-shadow($custom-control-indicator-active-box-shadow);
  34. }
  35. &:disabled {
  36. ~ .custom-control-label {
  37. color: $custom-control-label-disabled-color;
  38. &::before {
  39. background-color: $custom-control-indicator-disabled-bg;
  40. }
  41. }
  42. }
  43. }
  44. // Custom control indicators
  45. //
  46. // Build the custom controls out of psuedo-elements.
  47. .custom-control-label {
  48. margin-bottom: 0;
  49. // Background-color and (when enabled) gradient
  50. &::before {
  51. position: absolute;
  52. top: (($line-height-base - $custom-control-indicator-size) / 2);
  53. left: 0;
  54. display: block;
  55. width: $custom-control-indicator-size;
  56. height: $custom-control-indicator-size;
  57. pointer-events: none;
  58. content: "";
  59. user-select: none;
  60. background-color: $custom-control-indicator-bg;
  61. @include box-shadow($custom-control-indicator-box-shadow);
  62. }
  63. // Foreground (icon)
  64. &::after {
  65. position: absolute;
  66. top: (($line-height-base - $custom-control-indicator-size) / 2);
  67. left: 0;
  68. display: block;
  69. width: $custom-control-indicator-size;
  70. height: $custom-control-indicator-size;
  71. content: "";
  72. background-repeat: no-repeat;
  73. background-position: center center;
  74. background-size: $custom-control-indicator-bg-size;
  75. }
  76. }
  77. // Checkboxes
  78. //
  79. // Tweak just a few things for checkboxes.
  80. .custom-checkbox {
  81. .custom-control-label::before {
  82. @include border-radius($custom-checkbox-indicator-border-radius);
  83. }
  84. .custom-control-input:checked ~ .custom-control-label {
  85. &::before {
  86. @include gradient-bg($custom-control-indicator-checked-bg);
  87. }
  88. &::after {
  89. background-image: $custom-checkbox-indicator-icon-checked;
  90. }
  91. }
  92. .custom-control-input:indeterminate ~ .custom-control-label {
  93. &::before {
  94. @include gradient-bg($custom-checkbox-indicator-indeterminate-bg);
  95. @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
  96. }
  97. &::after {
  98. background-image: $custom-checkbox-indicator-icon-indeterminate;
  99. }
  100. }
  101. .custom-control-input:disabled {
  102. &:checked ~ .custom-control-label::before {
  103. background-color: $custom-control-indicator-checked-disabled-bg;
  104. }
  105. &:indeterminate ~ .custom-control-label::before {
  106. background-color: $custom-control-indicator-checked-disabled-bg;
  107. }
  108. }
  109. }
  110. // Radios
  111. //
  112. // Tweak just a few things for radios.
  113. .custom-radio {
  114. .custom-control-label::before {
  115. border-radius: $custom-radio-indicator-border-radius;
  116. }
  117. .custom-control-input:checked ~ .custom-control-label {
  118. &::before {
  119. @include gradient-bg($custom-control-indicator-checked-bg);
  120. }
  121. &::after {
  122. background-image: $custom-radio-indicator-icon-checked;
  123. }
  124. }
  125. .custom-control-input:disabled {
  126. &:checked ~ .custom-control-label::before {
  127. background-color: $custom-control-indicator-checked-disabled-bg;
  128. }
  129. }
  130. }
  131. // Select
  132. //
  133. // Replaces the browser default select with a custom one, mostly pulled from
  134. // http://primercss.io.
  135. //
  136. .custom-select {
  137. display: inline-block;
  138. width: 100%;
  139. height: $custom-select-height;
  140. padding: $custom-select-padding-y ($custom-select-padding-x + $custom-select-indicator-padding) $custom-select-padding-y $custom-select-padding-x;
  141. line-height: $custom-select-line-height;
  142. color: $custom-select-color;
  143. vertical-align: middle;
  144. background: $custom-select-bg $custom-select-indicator no-repeat right $custom-select-padding-x center;
  145. background-size: $custom-select-bg-size;
  146. border: $custom-select-border-width solid $custom-select-border-color;
  147. @if $enable-rounded {
  148. border-radius: $custom-select-border-radius;
  149. } @else {
  150. border-radius: 0;
  151. }
  152. appearance: none;
  153. &:focus {
  154. border-color: $custom-select-focus-border-color;
  155. outline: 0;
  156. box-shadow: $custom-select-focus-box-shadow;
  157. &::-ms-value {
  158. // For visual consistency with other platforms/browsers,
  159. // suppress the default white text on blue background highlight given to
  160. // the selected option text when the (still closed) <select> receives focus
  161. // in IE and (under certain conditions) Edge.
  162. // See https://github.com/twbs/bootstrap/issues/19398.
  163. color: $input-color;
  164. background-color: $input-bg;
  165. }
  166. }
  167. &[multiple],
  168. &[size]:not([size="1"]) {
  169. height: auto;
  170. padding-right: $custom-select-padding-x;
  171. background-image: none;
  172. }
  173. &:disabled {
  174. color: $custom-select-disabled-color;
  175. background-color: $custom-select-disabled-bg;
  176. }
  177. // Hides the default caret in IE11
  178. &::-ms-expand {
  179. opacity: 0;
  180. }
  181. }
  182. .custom-select-sm {
  183. height: $custom-select-height-sm;
  184. padding-top: $custom-select-padding-y;
  185. padding-bottom: $custom-select-padding-y;
  186. font-size: $custom-select-font-size-sm;
  187. }
  188. .custom-select-lg {
  189. height: $custom-select-height-lg;
  190. padding-top: $custom-select-padding-y;
  191. padding-bottom: $custom-select-padding-y;
  192. font-size: $custom-select-font-size-lg;
  193. }
  194. // File
  195. //
  196. // Custom file input.
  197. .custom-file {
  198. position: relative;
  199. display: inline-block;
  200. width: 100%;
  201. height: $custom-file-height;
  202. margin-bottom: 0;
  203. }
  204. .custom-file-input {
  205. position: relative;
  206. z-index: 2;
  207. width: 100%;
  208. height: $custom-file-height;
  209. margin: 0;
  210. opacity: 0;
  211. &:focus ~ .custom-file-control {
  212. border-color: $custom-file-focus-border-color;
  213. box-shadow: $custom-file-focus-box-shadow;
  214. &::before {
  215. border-color: $custom-file-focus-border-color;
  216. }
  217. }
  218. @each $lang, $value in $custom-file-text {
  219. &:lang(#{$lang}) ~ .custom-file-label::after {
  220. content: $value;
  221. }
  222. }
  223. }
  224. .custom-file-label {
  225. position: absolute;
  226. top: 0;
  227. right: 0;
  228. left: 0;
  229. z-index: 1;
  230. height: $custom-file-height;
  231. padding: $custom-file-padding-y $custom-file-padding-x;
  232. line-height: $custom-file-line-height;
  233. color: $custom-file-color;
  234. background-color: $custom-file-bg;
  235. border: $custom-file-border-width solid $custom-file-border-color;
  236. @include border-radius($custom-file-border-radius);
  237. @include box-shadow($custom-file-box-shadow);
  238. &::after {
  239. position: absolute;
  240. top: 0;
  241. right: 0;
  242. bottom: 0;
  243. z-index: 3;
  244. display: block;
  245. height: calc(#{$custom-file-height} - #{$custom-file-border-width} * 2);
  246. padding: $custom-file-padding-y $custom-file-padding-x;
  247. line-height: $custom-file-line-height;
  248. color: $custom-file-button-color;
  249. content: "Browse";
  250. @include gradient-bg($custom-file-button-bg);
  251. border-left: $custom-file-border-width solid $custom-file-border-color;
  252. @include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
  253. }
  254. }