No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_custom-forms.scss 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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: ($font-size-base * $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 pseudo-elements.
  47. .custom-control-label {
  48. position: relative;
  49. margin-bottom: 0;
  50. // Background-color and (when enabled) gradient
  51. &::before {
  52. position: absolute;
  53. top: (($font-size-base * $line-height-base - $custom-control-indicator-size) / 2);
  54. left: -$custom-control-gutter;
  55. display: block;
  56. width: $custom-control-indicator-size;
  57. height: $custom-control-indicator-size;
  58. pointer-events: none;
  59. content: "";
  60. user-select: none;
  61. background-color: $custom-control-indicator-bg;
  62. @include box-shadow($custom-control-indicator-box-shadow);
  63. }
  64. // Foreground (icon)
  65. &::after {
  66. position: absolute;
  67. top: (($font-size-base * $line-height-base - $custom-control-indicator-size) / 2);
  68. left: -$custom-control-gutter;
  69. display: block;
  70. width: $custom-control-indicator-size;
  71. height: $custom-control-indicator-size;
  72. content: "";
  73. background-repeat: no-repeat;
  74. background-position: center center;
  75. background-size: $custom-control-indicator-bg-size;
  76. }
  77. }
  78. // Checkboxes
  79. //
  80. // Tweak just a few things for checkboxes.
  81. .custom-checkbox {
  82. .custom-control-label::before {
  83. @include border-radius($custom-checkbox-indicator-border-radius);
  84. }
  85. .custom-control-input:checked ~ .custom-control-label {
  86. &::before {
  87. @include gradient-bg($custom-control-indicator-checked-bg);
  88. }
  89. &::after {
  90. background-image: $custom-checkbox-indicator-icon-checked;
  91. }
  92. }
  93. .custom-control-input:indeterminate ~ .custom-control-label {
  94. &::before {
  95. @include gradient-bg($custom-checkbox-indicator-indeterminate-bg);
  96. @include box-shadow($custom-checkbox-indicator-indeterminate-box-shadow);
  97. }
  98. &::after {
  99. background-image: $custom-checkbox-indicator-icon-indeterminate;
  100. }
  101. }
  102. .custom-control-input:disabled {
  103. &:checked ~ .custom-control-label::before {
  104. background-color: $custom-control-indicator-checked-disabled-bg;
  105. }
  106. &:indeterminate ~ .custom-control-label::before {
  107. background-color: $custom-control-indicator-checked-disabled-bg;
  108. }
  109. }
  110. }
  111. // Radios
  112. //
  113. // Tweak just a few things for radios.
  114. .custom-radio {
  115. .custom-control-label::before {
  116. border-radius: $custom-radio-indicator-border-radius;
  117. }
  118. .custom-control-input:checked ~ .custom-control-label {
  119. &::before {
  120. @include gradient-bg($custom-control-indicator-checked-bg);
  121. }
  122. &::after {
  123. background-image: $custom-radio-indicator-icon-checked;
  124. }
  125. }
  126. .custom-control-input:disabled {
  127. &:checked ~ .custom-control-label::before {
  128. background-color: $custom-control-indicator-checked-disabled-bg;
  129. }
  130. }
  131. }
  132. // Select
  133. //
  134. // Replaces the browser default select with a custom one, mostly pulled from
  135. // https://primer.github.io/.
  136. //
  137. .custom-select {
  138. display: inline-block;
  139. width: 100%;
  140. height: $custom-select-height;
  141. padding: $custom-select-padding-y ($custom-select-padding-x + $custom-select-indicator-padding) $custom-select-padding-y $custom-select-padding-x;
  142. line-height: $custom-select-line-height;
  143. color: $custom-select-color;
  144. vertical-align: middle;
  145. background: $custom-select-bg $custom-select-indicator no-repeat right $custom-select-padding-x center;
  146. background-size: $custom-select-bg-size;
  147. border: $custom-select-border-width solid $custom-select-border-color;
  148. @if $enable-rounded {
  149. border-radius: $custom-select-border-radius;
  150. } @else {
  151. border-radius: 0;
  152. }
  153. @include box-shadow($custom-select-box-shadow);
  154. appearance: none;
  155. &:focus {
  156. border-color: $custom-select-focus-border-color;
  157. outline: 0;
  158. @if $enable-shadows {
  159. box-shadow: $custom-select-box-shadow, $custom-select-focus-box-shadow;
  160. } @else {
  161. box-shadow: $custom-select-focus-box-shadow;
  162. }
  163. &::-ms-value {
  164. // For visual consistency with other platforms/browsers,
  165. // suppress the default white text on blue background highlight given to
  166. // the selected option text when the (still closed) <select> receives focus
  167. // in IE and (under certain conditions) Edge.
  168. // See https://github.com/twbs/bootstrap/issues/19398.
  169. color: $input-color;
  170. background-color: $input-bg;
  171. }
  172. }
  173. &[multiple],
  174. &[size]:not([size="1"]) {
  175. height: auto;
  176. padding-right: $custom-select-padding-x;
  177. background-image: none;
  178. }
  179. &:disabled {
  180. color: $custom-select-disabled-color;
  181. background-color: $custom-select-disabled-bg;
  182. }
  183. // Hides the default caret in IE11
  184. &::-ms-expand {
  185. opacity: 0;
  186. }
  187. }
  188. .custom-select-sm {
  189. height: $custom-select-height-sm;
  190. padding-top: $custom-select-padding-y;
  191. padding-bottom: $custom-select-padding-y;
  192. font-size: $custom-select-font-size-sm;
  193. }
  194. .custom-select-lg {
  195. height: $custom-select-height-lg;
  196. padding-top: $custom-select-padding-y;
  197. padding-bottom: $custom-select-padding-y;
  198. font-size: $custom-select-font-size-lg;
  199. }
  200. // File
  201. //
  202. // Custom file input.
  203. .custom-file {
  204. position: relative;
  205. display: inline-block;
  206. width: 100%;
  207. height: $custom-file-height;
  208. margin-bottom: 0;
  209. }
  210. .custom-file-input {
  211. position: relative;
  212. z-index: 2;
  213. width: 100%;
  214. height: $custom-file-height;
  215. margin: 0;
  216. opacity: 0;
  217. &:focus ~ .custom-file-label {
  218. border-color: $custom-file-focus-border-color;
  219. box-shadow: $custom-file-focus-box-shadow;
  220. &::after {
  221. border-color: $custom-file-focus-border-color;
  222. }
  223. }
  224. &:disabled ~ .custom-file-label {
  225. background-color: $custom-file-disabled-bg;
  226. }
  227. @each $lang, $value in $custom-file-text {
  228. &:lang(#{$lang}) ~ .custom-file-label::after {
  229. content: $value;
  230. }
  231. }
  232. }
  233. .custom-file-label {
  234. position: absolute;
  235. top: 0;
  236. right: 0;
  237. left: 0;
  238. z-index: 1;
  239. height: $custom-file-height;
  240. padding: $custom-file-padding-y $custom-file-padding-x;
  241. line-height: $custom-file-line-height;
  242. color: $custom-file-color;
  243. background-color: $custom-file-bg;
  244. border: $custom-file-border-width solid $custom-file-border-color;
  245. @include border-radius($custom-file-border-radius);
  246. @include box-shadow($custom-file-box-shadow);
  247. &::after {
  248. position: absolute;
  249. top: 0;
  250. right: 0;
  251. bottom: 0;
  252. z-index: 3;
  253. display: block;
  254. height: $custom-file-height-inner;
  255. padding: $custom-file-padding-y $custom-file-padding-x;
  256. line-height: $custom-file-line-height;
  257. color: $custom-file-button-color;
  258. content: "Browse";
  259. @include gradient-bg($custom-file-button-bg);
  260. border-left: $custom-file-border-width solid $custom-file-border-color;
  261. @include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
  262. }
  263. }
  264. // Range
  265. //
  266. // Style range inputs the same across browsers. Vendor-specific rules for pseudo
  267. // elements cannot be mixed. As such, there are no shared styles for focus or
  268. // active states on prefixed selectors.
  269. .custom-range {
  270. width: 100%;
  271. padding-left: 0; // Firefox specific
  272. background-color: transparent;
  273. appearance: none;
  274. &:focus {
  275. outline: none;
  276. // Pseudo-elements must be split across multiple rulesets to have an affect.
  277. // No box-shadow() mixin for focus accessibility.
  278. &::-webkit-slider-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  279. &::-moz-range-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  280. &::-ms-thumb { box-shadow: $custom-range-thumb-focus-box-shadow; }
  281. }
  282. &::-moz-focus-outer {
  283. border: 0;
  284. }
  285. &::-webkit-slider-thumb {
  286. width: $custom-range-thumb-width;
  287. height: $custom-range-thumb-height;
  288. margin-top: (($custom-range-track-height - $custom-range-thumb-height) / 2); // Webkit specific
  289. @include gradient-bg($custom-range-thumb-bg);
  290. border: $custom-range-thumb-border;
  291. @include border-radius($custom-range-thumb-border-radius);
  292. @include box-shadow($custom-range-thumb-box-shadow);
  293. @include transition($custom-forms-transition);
  294. appearance: none;
  295. &:active {
  296. @include gradient-bg($custom-range-thumb-active-bg);
  297. }
  298. }
  299. &::-webkit-slider-runnable-track {
  300. width: $custom-range-track-width;
  301. height: $custom-range-track-height;
  302. color: transparent; // Why?
  303. cursor: $custom-range-track-cursor;
  304. background-color: $custom-range-track-bg;
  305. border-color: transparent;
  306. @include border-radius($custom-range-track-border-radius);
  307. @include box-shadow($custom-range-track-box-shadow);
  308. }
  309. &::-moz-range-thumb {
  310. width: $custom-range-thumb-width;
  311. height: $custom-range-thumb-height;
  312. @include gradient-bg($custom-range-thumb-bg);
  313. border: $custom-range-thumb-border;
  314. @include border-radius($custom-range-thumb-border-radius);
  315. @include box-shadow($custom-range-thumb-box-shadow);
  316. @include transition($custom-forms-transition);
  317. appearance: none;
  318. &:active {
  319. @include gradient-bg($custom-range-thumb-active-bg);
  320. }
  321. }
  322. &::-moz-range-track {
  323. width: $custom-range-track-width;
  324. height: $custom-range-track-height;
  325. color: transparent;
  326. cursor: $custom-range-track-cursor;
  327. background-color: $custom-range-track-bg;
  328. border-color: transparent; // Firefox specific?
  329. @include border-radius($custom-range-track-border-radius);
  330. @include box-shadow($custom-range-track-box-shadow);
  331. }
  332. &::-ms-thumb {
  333. width: $custom-range-thumb-width;
  334. height: $custom-range-thumb-height;
  335. margin-top: 0; // Edge specific
  336. margin-right: $custom-range-thumb-focus-box-shadow-width; // Workaround that overflowed box-shadow is hidden.
  337. margin-left: $custom-range-thumb-focus-box-shadow-width; // Workaround that overflowed box-shadow is hidden.
  338. @include gradient-bg($custom-range-thumb-bg);
  339. border: $custom-range-thumb-border;
  340. @include border-radius($custom-range-thumb-border-radius);
  341. @include box-shadow($custom-range-thumb-box-shadow);
  342. @include transition($custom-forms-transition);
  343. appearance: none;
  344. &:active {
  345. @include gradient-bg($custom-range-thumb-active-bg);
  346. }
  347. }
  348. &::-ms-track {
  349. width: $custom-range-track-width;
  350. height: $custom-range-track-height;
  351. color: transparent;
  352. cursor: $custom-range-track-cursor;
  353. background-color: transparent;
  354. border-color: transparent;
  355. border-width: ($custom-range-thumb-height * .5);
  356. @include box-shadow($custom-range-track-box-shadow);
  357. }
  358. &::-ms-fill-lower {
  359. background-color: $custom-range-track-bg;
  360. @include border-radius($custom-range-track-border-radius);
  361. }
  362. &::-ms-fill-upper {
  363. margin-right: 15px; // arbitrary?
  364. background-color: $custom-range-track-bg;
  365. @include border-radius($custom-range-track-border-radius);
  366. }
  367. }
  368. .custom-control-label::before,
  369. .custom-file-label,
  370. .custom-select {
  371. @include transition($custom-forms-transition);
  372. }