_custom-forms.scss 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // scss-lint:disable PropertyCount
  2. // Embedded icons from Open Iconic.
  3. // Released under MIT and copyright 2014 Waybury.
  4. // https://useiconic.com/open
  5. // Checkboxes and radios
  6. //
  7. // Base class takes care of all the key behavioral aspects.
  8. .custom-control {
  9. position: relative;
  10. display: inline-block;
  11. padding-left: $custom-control-gutter;
  12. cursor: pointer;
  13. + .custom-control {
  14. margin-left: $custom-control-spacer-x;
  15. }
  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-indicator {
  22. color: $custom-control-checked-indicator-color;
  23. background-color: $custom-control-checked-indicator-bg;
  24. @include box-shadow($custom-control-checked-indicator-box-shadow);
  25. }
  26. &:focus ~ .custom-control-indicator {
  27. // the mixin is not used here to make sure there is feedback
  28. box-shadow: $custom-control-focus-indicator-box-shadow;
  29. }
  30. &:active ~ .custom-control-indicator {
  31. color: $custom-control-active-indicator-color;
  32. background-color: $custom-control-active-indicator-bg;
  33. @include box-shadow($custom-control-active-indicator-box-shadow);
  34. }
  35. &:disabled {
  36. ~ .custom-control-indicator {
  37. cursor: $custom-control-disabled-cursor;
  38. background-color: $custom-control-disabled-indicator-bg;
  39. }
  40. ~ .custom-control-description {
  41. color: $custom-control-disabled-description-color;
  42. cursor: $custom-control-disabled-cursor;
  43. }
  44. }
  45. }
  46. // Custom indicator
  47. //
  48. // Generates a shadow element to create our makeshift checkbox/radio background.
  49. .custom-control-indicator {
  50. position: absolute;
  51. top: .25rem;
  52. left: 0;
  53. display: block;
  54. width: $custom-control-indicator-size;
  55. height: $custom-control-indicator-size;
  56. pointer-events: none;
  57. user-select: none;
  58. background-color: $custom-control-indicator-bg;
  59. background-repeat: no-repeat;
  60. background-position: center center;
  61. background-size: $custom-control-indicator-bg-size;
  62. @include box-shadow($custom-control-indicator-box-shadow);
  63. }
  64. // Checkboxes
  65. //
  66. // Tweak just a few things for checkboxes.
  67. .custom-checkbox {
  68. .custom-control-indicator {
  69. @include border-radius($custom-checkbox-radius);
  70. }
  71. .custom-control-input:checked ~ .custom-control-indicator {
  72. background-image: $custom-checkbox-checked-icon;
  73. }
  74. .custom-control-input:indeterminate ~ .custom-control-indicator {
  75. background-color: $custom-checkbox-indeterminate-bg;
  76. background-image: $custom-checkbox-indeterminate-icon;
  77. @include box-shadow($custom-checkbox-indeterminate-box-shadow);
  78. }
  79. }
  80. // Radios
  81. //
  82. // Tweak just a few things for radios.
  83. .custom-radio {
  84. .custom-control-indicator {
  85. border-radius: $custom-radio-radius;
  86. }
  87. .custom-control-input:checked ~ .custom-control-indicator {
  88. background-image: $custom-radio-checked-icon;
  89. }
  90. }
  91. // Layout options
  92. //
  93. // By default radios and checkboxes are `inline-block` with no additional spacing
  94. // set. Use these optional classes to tweak the layout.
  95. .custom-controls-stacked {
  96. .custom-control {
  97. float: left;
  98. clear: left;
  99. + .custom-control {
  100. margin-left: 0;
  101. }
  102. }
  103. }
  104. // Select
  105. //
  106. // Replaces the browser default select with a custom one, mostly pulled from
  107. // http://primercss.io.
  108. //
  109. // Includes IE9-specific hacks (noted by ` \9`).
  110. .custom-select {
  111. display: inline-block;
  112. max-width: 100%;
  113. $select-border-width: ($border-width * 2);
  114. height: calc(#{$input-height} - #{$select-border-width});
  115. padding: $custom-select-padding-y ($custom-select-padding-x + $custom-select-indicator-padding) $custom-select-padding-y $custom-select-padding-x;
  116. padding-right: $custom-select-padding-x \9;
  117. color: $custom-select-color;
  118. vertical-align: middle;
  119. background: $custom-select-bg $custom-select-indicator no-repeat right $custom-select-padding-x center;
  120. background-image: none \9;
  121. background-size: $custom-select-bg-size;
  122. border: $custom-select-border-width solid $custom-select-border-color;
  123. @include border-radius($custom-select-border-radius);
  124. // Use vendor prefixes as `appearance` isn't part of the CSS spec.
  125. -moz-appearance: none;
  126. -webkit-appearance: none;
  127. &:focus {
  128. border-color: $custom-select-focus-border-color;
  129. outline: none;
  130. @include box-shadow($custom-select-focus-box-shadow);
  131. &::-ms-value {
  132. // For visual consistency with other platforms/browsers,
  133. // supress the default white text on blue background highlight given to
  134. // the selected option text when the (still closed) <select> receives focus
  135. // in IE and (under certain conditions) Edge.
  136. // See https://github.com/twbs/bootstrap/issues/19398.
  137. color: $input-color;
  138. background-color: $input-bg;
  139. }
  140. }
  141. &:disabled {
  142. color: $custom-select-disabled-color;
  143. cursor: $cursor-disabled;
  144. background-color: $custom-select-disabled-bg;
  145. }
  146. // Hides the default caret in IE11
  147. &::-ms-expand {
  148. opacity: 0;
  149. }
  150. }
  151. .custom-select-sm {
  152. padding-top: $custom-select-padding-y;
  153. padding-bottom: $custom-select-padding-y;
  154. font-size: $custom-select-sm-font-size;
  155. // &:not([multiple]) {
  156. // height: 26px;
  157. // min-height: 26px;
  158. // }
  159. }
  160. // File
  161. //
  162. // Custom file input.
  163. .custom-file {
  164. position: relative;
  165. display: inline-block;
  166. max-width: 100%;
  167. height: $custom-file-height;
  168. cursor: pointer;
  169. }
  170. .custom-file-input {
  171. min-width: $custom-file-width;
  172. max-width: 100%;
  173. margin: 0;
  174. filter: alpha(opacity = 0);
  175. opacity: 0;
  176. &:focus ~ .custom-file-control {
  177. @include box-shadow($custom-file-focus-box-shadow);
  178. }
  179. }
  180. .custom-file-control {
  181. position: absolute;
  182. top: 0;
  183. right: 0;
  184. left: 0;
  185. z-index: 5;
  186. height: $custom-file-height;
  187. padding: $custom-file-padding-x $custom-file-padding-y;
  188. line-height: $custom-file-line-height;
  189. color: $custom-file-color;
  190. user-select: none;
  191. background-color: $custom-file-bg;
  192. border: $custom-file-border-width solid $custom-file-border-color;
  193. @include border-radius($custom-file-border-radius);
  194. @include box-shadow($custom-file-box-shadow);
  195. @each $lang, $text in map-get($custom-file-text, placeholder) {
  196. &:lang(#{$lang})::after {
  197. content: $text;
  198. }
  199. }
  200. &::before {
  201. position: absolute;
  202. top: -$custom-file-border-width;
  203. right: -$custom-file-border-width;
  204. bottom: -$custom-file-border-width;
  205. z-index: 6;
  206. display: block;
  207. height: $custom-file-height;
  208. padding: $custom-file-padding-x $custom-file-padding-y;
  209. line-height: $custom-file-line-height;
  210. color: $custom-file-button-color;
  211. background-color: $custom-file-button-bg;
  212. border: $custom-file-border-width solid $custom-file-border-color;
  213. @include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
  214. }
  215. @each $lang, $text in map-get($custom-file-text, button-label) {
  216. &:lang(#{$lang})::before {
  217. content: $text;
  218. }
  219. }
  220. }