_custom-forms.scss 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 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: (($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: (($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. appearance: none;
  154. &:focus {
  155. border-color: $custom-select-focus-border-color;
  156. outline: 0;
  157. box-shadow: $custom-select-focus-box-shadow;
  158. &::-ms-value {
  159. // For visual consistency with other platforms/browsers,
  160. // suppress the default white text on blue background highlight given to
  161. // the selected option text when the (still closed) <select> receives focus
  162. // in IE and (under certain conditions) Edge.
  163. // See https://github.com/twbs/bootstrap/issues/19398.
  164. color: $input-color;
  165. background-color: $input-bg;
  166. }
  167. }
  168. &[multiple],
  169. &[size]:not([size="1"]) {
  170. height: auto;
  171. padding-right: $custom-select-padding-x;
  172. background-image: none;
  173. }
  174. &:disabled {
  175. color: $custom-select-disabled-color;
  176. background-color: $custom-select-disabled-bg;
  177. }
  178. // Hides the default caret in IE11
  179. &::-ms-expand {
  180. opacity: 0;
  181. }
  182. }
  183. .custom-select-sm {
  184. height: $custom-select-height-sm;
  185. padding-top: $custom-select-padding-y;
  186. padding-bottom: $custom-select-padding-y;
  187. font-size: $custom-select-font-size-sm;
  188. }
  189. .custom-select-lg {
  190. height: $custom-select-height-lg;
  191. padding-top: $custom-select-padding-y;
  192. padding-bottom: $custom-select-padding-y;
  193. font-size: $custom-select-font-size-lg;
  194. }
  195. // File
  196. //
  197. // Custom file input.
  198. .custom-file {
  199. position: relative;
  200. display: inline-block;
  201. width: 100%;
  202. height: $custom-file-height;
  203. margin-bottom: 0;
  204. }
  205. .custom-file-input {
  206. position: relative;
  207. z-index: 2;
  208. width: 100%;
  209. height: $custom-file-height;
  210. margin: 0;
  211. opacity: 0;
  212. &:focus ~ .custom-file-label {
  213. border-color: $custom-file-focus-border-color;
  214. box-shadow: $custom-file-focus-box-shadow;
  215. &::after {
  216. border-color: $custom-file-focus-border-color;
  217. }
  218. }
  219. @each $lang, $value in $custom-file-text {
  220. &:lang(#{$lang}) ~ .custom-file-label::after {
  221. content: $value;
  222. }
  223. }
  224. }
  225. .custom-file-label {
  226. position: absolute;
  227. top: 0;
  228. right: 0;
  229. left: 0;
  230. z-index: 1;
  231. height: $custom-file-height;
  232. padding: $custom-file-padding-y $custom-file-padding-x;
  233. line-height: $custom-file-line-height;
  234. color: $custom-file-color;
  235. background-color: $custom-file-bg;
  236. border: $custom-file-border-width solid $custom-file-border-color;
  237. @include border-radius($custom-file-border-radius);
  238. @include box-shadow($custom-file-box-shadow);
  239. &::after {
  240. position: absolute;
  241. top: 0;
  242. right: 0;
  243. bottom: 0;
  244. z-index: 3;
  245. display: block;
  246. height: $custom-file-height-inner;
  247. padding: $custom-file-padding-y $custom-file-padding-x;
  248. line-height: $custom-file-line-height;
  249. color: $custom-file-button-color;
  250. content: "Browse";
  251. @include gradient-bg($custom-file-button-bg);
  252. border-left: $custom-file-border-width solid $custom-file-border-color;
  253. @include border-radius(0 $custom-file-border-radius $custom-file-border-radius 0);
  254. }
  255. }
  256. // Range
  257. //
  258. // Style range inputs the same across browsers. Vendor-specific rules for pseudo
  259. // elements cannot be mixed. As such, there are no shared styles for focus or
  260. // active states on prefixed selectors.
  261. .custom-range {
  262. width: 100%;
  263. padding-left: 0; // Firefox specific
  264. background-color: transparent;
  265. appearance: none;
  266. &:focus {
  267. outline: none;
  268. }
  269. &::-moz-focus-outer {
  270. border: 0;
  271. }
  272. &::-webkit-slider-thumb {
  273. width: $custom-range-thumb-width;
  274. height: $custom-range-thumb-height;
  275. margin-top: -($custom-range-thumb-width * .25); // Webkit specific?
  276. @include gradient-bg($custom-range-thumb-bg);
  277. border: $custom-range-thumb-border;
  278. @include border-radius($custom-range-thumb-border-radius);
  279. @include box-shadow($custom-range-thumb-box-shadow);
  280. appearance: none;
  281. &:focus {
  282. outline: none;
  283. box-shadow: $custom-range-thumb-focus-box-shadow; // No mixin for focus accessibility
  284. }
  285. &:active {
  286. @include gradient-bg($custom-range-thumb-active-bg);
  287. }
  288. }
  289. &::-webkit-slider-runnable-track {
  290. width: $custom-range-track-width;
  291. height: $custom-range-track-height;
  292. color: transparent; // Why?
  293. cursor: $custom-range-track-cursor;
  294. background-color: $custom-range-track-bg;
  295. border-color: transparent;
  296. @include border-radius($custom-range-track-border-radius);
  297. @include box-shadow($custom-range-track-box-shadow);
  298. }
  299. &::-moz-range-thumb {
  300. width: $custom-range-thumb-width;
  301. height: $custom-range-thumb-height;
  302. @include gradient-bg($custom-range-thumb-bg);
  303. border: $custom-range-thumb-border;
  304. @include border-radius($custom-range-thumb-border-radius);
  305. @include box-shadow($custom-range-thumb-box-shadow);
  306. appearance: none;
  307. &:focus {
  308. outline: none;
  309. box-shadow: $custom-range-thumb-focus-box-shadow; // No mixin for focus accessibility
  310. }
  311. &:active {
  312. @include gradient-bg($custom-range-thumb-active-bg);
  313. }
  314. }
  315. &::-moz-range-track {
  316. width: $custom-range-track-width;
  317. height: $custom-range-track-height;
  318. color: transparent;
  319. cursor: $custom-range-track-cursor;
  320. background-color: $custom-range-track-bg;
  321. border-color: transparent; // Firefox specific?
  322. @include border-radius($custom-range-track-border-radius);
  323. @include box-shadow($custom-range-track-box-shadow);
  324. }
  325. &::-ms-thumb {
  326. width: $custom-range-thumb-width;
  327. height: $custom-range-thumb-height;
  328. @include gradient-bg($custom-range-thumb-bg);
  329. border: $custom-range-thumb-border;
  330. @include border-radius($custom-range-thumb-border-radius);
  331. @include box-shadow($custom-range-thumb-box-shadow);
  332. appearance: none;
  333. &:focus {
  334. outline: none;
  335. box-shadow: $custom-range-thumb-focus-box-shadow; // No mixin for focus accessibility
  336. }
  337. &:active {
  338. @include gradient-bg($custom-range-thumb-active-bg);
  339. }
  340. }
  341. &::-ms-track {
  342. width: $custom-range-track-width;
  343. height: $custom-range-track-height;
  344. color: transparent;
  345. cursor: $custom-range-track-cursor;
  346. background-color: transparent;
  347. border-color: transparent;
  348. border-width: ($custom-range-thumb-height * .5);
  349. @include box-shadow($custom-range-track-box-shadow);
  350. }
  351. &::-ms-fill-lower {
  352. background-color: $custom-range-track-bg;
  353. @include border-radius($custom-range-track-border-radius);
  354. }
  355. &::-ms-fill-upper {
  356. margin-right: 15px; // arbitrary?
  357. background-color: $custom-range-track-bg;
  358. @include border-radius($custom-range-track-border-radius);
  359. }
  360. }