_forms.scss 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. //
  2. // Component: Forms
  3. //
  4. .form-group {
  5. &.has-icon {
  6. position: relative;
  7. .form-control {
  8. padding-right: 35px;
  9. }
  10. .form-icon {
  11. background-color: transparent;
  12. border: 0;
  13. cursor: pointer;
  14. font-size: 1rem;
  15. // margin-top: -3px;
  16. padding: $input-btn-padding-y $input-btn-padding-x;
  17. position: absolute;
  18. right: 3px;
  19. top: 0;
  20. }
  21. }
  22. }
  23. // Button groups
  24. .btn-group-vertical {
  25. .btn {
  26. &.btn-flat:first-of-type,
  27. &.btn-flat:last-of-type {
  28. @include border-radius(0);
  29. }
  30. }
  31. }
  32. /* stylelint-disable selector-class-pattern */
  33. // Support icons in form-control
  34. .form-control-feedback {
  35. &.fa,
  36. &.fas,
  37. &.far,
  38. &.fab,
  39. &.fal,
  40. &.fad,
  41. &.svg-inline--fa,
  42. &.ion {
  43. line-height: $input-height;
  44. }
  45. }
  46. .input-lg + .form-control-feedback,
  47. .input-group-lg + .form-control-feedback {
  48. &.fa,
  49. &.fas,
  50. &.far,
  51. &.fab,
  52. &.fal,
  53. &.fad,
  54. &.svg-inline--fa,
  55. &.ion {
  56. line-height: $input-height-lg;
  57. }
  58. }
  59. .form-group-lg {
  60. .form-control + .form-control-feedback {
  61. &.fa,
  62. &.fas,
  63. &.far,
  64. &.fab,
  65. &.fal,
  66. &.fad,
  67. &.svg-inline--fa,
  68. &.ion {
  69. line-height: $input-height-lg;
  70. }
  71. }
  72. }
  73. .input-sm + .form-control-feedback,
  74. .input-group-sm + .form-control-feedback {
  75. &.fa,
  76. &.fas,
  77. &.far,
  78. &.fab,
  79. &.fal,
  80. &.fad,
  81. &.svg-inline--fa,
  82. &.ion {
  83. line-height: $input-height-sm;
  84. }
  85. }
  86. .form-group-sm {
  87. .form-control + .form-control-feedback {
  88. &.fa,
  89. &.fas,
  90. &.far,
  91. &.fab,
  92. &.fal,
  93. &.fad,
  94. &.svg-inline--fa,
  95. &.ion {
  96. line-height: $input-height-sm;
  97. }
  98. }
  99. }
  100. /* stylelint-enable selector-class-pattern */
  101. label:not(.form-check-label):not(.custom-file-label) {
  102. font-weight: $font-weight-bold;
  103. }
  104. .warning-feedback {
  105. @include font-size($form-feedback-font-size);
  106. color: theme-color("warning");
  107. display: none;
  108. margin-top: $form-feedback-margin-top;
  109. width: 100%;
  110. }
  111. .warning-tooltip {
  112. @include border-radius($form-feedback-tooltip-border-radius);
  113. @include font-size($form-feedback-tooltip-font-size);
  114. background-color: rgba(theme-color("warning"), $form-feedback-tooltip-opacity);
  115. color: color-yiq(theme-color("warning"));
  116. display: none;
  117. line-height: $form-feedback-tooltip-line-height;
  118. margin-top: .1rem;
  119. max-width: 100%; // Contain to parent when possible
  120. padding: $form-feedback-tooltip-padding-y $form-feedback-tooltip-padding-x;
  121. position: absolute;
  122. top: 100%;
  123. z-index: 5;
  124. }
  125. .form-control {
  126. &.is-warning {
  127. border-color: theme-color("warning");
  128. @if $enable-validation-icons {
  129. // padding-right: $input-height-inner;
  130. // background-image: none;
  131. // background-repeat: no-repeat;
  132. // background-position: center right $input-height-inner-quarter;
  133. // background-size: $input-height-inner-half $input-height-inner-half;
  134. }
  135. &:focus {
  136. border-color: theme-color("warning");
  137. box-shadow: 0 0 0 $input-focus-width rgba(theme-color("warning"), .25);
  138. }
  139. ~ .warning-feedback,
  140. ~ .warning-tooltip {
  141. display: block;
  142. }
  143. }
  144. }
  145. // stylelint-disable-next-line selector-no-qualifying-type
  146. textarea.form-control {
  147. &.is-warning {
  148. @if $enable-validation-icons {
  149. padding-right: $input-height-inner;
  150. background-position: top $input-height-inner-quarter right $input-height-inner-quarter;
  151. }
  152. }
  153. }
  154. .custom-select {
  155. &.is-warning {
  156. border-color: theme-color("warning");
  157. @if $enable-validation-icons {
  158. // padding-right: $custom-select-feedback-icon-padding-right;
  159. // background: $custom-select-background, none $custom-select-bg no-repeat $custom-select-feedback-icon-position / $custom-select-feedback-icon-size;
  160. }
  161. &:focus {
  162. border-color: theme-color("warning");
  163. box-shadow: 0 0 0 $input-focus-width rgba(theme-color("warning"), .25);
  164. }
  165. ~ .warning-feedback,
  166. ~ .warning-tooltip {
  167. display: block;
  168. }
  169. }
  170. }
  171. .form-control-file {
  172. &.is-warning {
  173. ~ .warning-feedback,
  174. ~ .warning-tooltip {
  175. display: block;
  176. }
  177. }
  178. }
  179. .form-check-input {
  180. &.is-warning {
  181. ~ .form-check-label {
  182. color: theme-color("warning");
  183. }
  184. ~ .warning-feedback,
  185. ~ .warning-tooltip {
  186. display: block;
  187. }
  188. }
  189. }
  190. .custom-control-input.is-warning {
  191. ~ .custom-control-label {
  192. color: theme-color("warning");
  193. &::before {
  194. border-color: theme-color("warning");
  195. }
  196. }
  197. ~ .warning-feedback,
  198. ~ .warning-tooltip {
  199. display: block;
  200. }
  201. &:checked {
  202. ~ .custom-control-label::before {
  203. @include gradient-bg(lighten(theme-color("warning"), 10%));
  204. border-color: lighten(theme-color("warning"), 10%);
  205. }
  206. }
  207. &:focus {
  208. ~ .custom-control-label::before {
  209. box-shadow: 0 0 0 $input-focus-width rgba(theme-color("warning"), .25);
  210. }
  211. &:not(:checked) ~ .custom-control-label::before {
  212. border-color: theme-color("warning");
  213. }
  214. }
  215. }
  216. // custom file
  217. .custom-file-input {
  218. &.is-warning {
  219. ~ .custom-file-label {
  220. border-color: theme-color("warning");
  221. }
  222. ~ .warning-feedback,
  223. ~ .warning-tooltip {
  224. display: block;
  225. }
  226. &:focus {
  227. ~ .custom-file-label {
  228. border-color: theme-color("warning");
  229. box-shadow: 0 0 0 $input-focus-width rgba(theme-color("warning"), .25);
  230. }
  231. }
  232. }
  233. }
  234. // body.text-sm support
  235. body.text-sm {
  236. .input-group-text {
  237. font-size: $font-size-sm;
  238. }
  239. }
  240. // custom .form-control styles
  241. .form-control,
  242. .custom-select {
  243. &.form-control-border {
  244. border-top: 0;
  245. border-left: 0;
  246. border-right: 0;
  247. border-radius: 0;
  248. box-shadow: inherit;
  249. &.border-width-2 {
  250. border-bottom-width: 2px;
  251. }
  252. &.border-width-3 {
  253. border-bottom-width: 3px;
  254. }
  255. }
  256. }
  257. // custom switch color variations
  258. .custom-switch {
  259. @each $name, $color in $theme-colors {
  260. @include custom-switch-variant($name, $color);
  261. }
  262. @each $name, $color in $colors {
  263. @include custom-switch-variant($name, $color);
  264. }
  265. }
  266. // custom range color variations
  267. .custom-range {
  268. @each $name, $color in $theme-colors {
  269. @include custom-range-variant($name, $color);
  270. }
  271. @each $name, $color in $colors {
  272. @include custom-range-variant($name, $color);
  273. }
  274. }
  275. // custom control input variations
  276. @each $name, $color in $theme-colors {
  277. @include custom-control-input-variant($name, $color);
  278. }
  279. @each $name, $color in $colors {
  280. @include custom-control-input-variant($name, $color);
  281. }
  282. .custom-control-input-outline {
  283. ~ .custom-control-label::before {
  284. background-color: transparent !important;
  285. box-shadow: none;
  286. }
  287. &:checked ~ .custom-control-label::before {
  288. @include gradient-bg(transparent);
  289. }
  290. }
  291. .navbar-dark {
  292. .btn-navbar,
  293. .form-control-navbar {
  294. background-color: lighten($sidebar-dark-bg, 5%);
  295. border: 1px solid lighten($sidebar-dark-bg, 15%);
  296. color: lighten(color-yiq(lighten($sidebar-dark-bg, 5%)), 15%);
  297. }
  298. .btn-navbar {
  299. &:hover {
  300. background-color: lighten($sidebar-dark-bg, 7.5%);
  301. }
  302. &:focus {
  303. background-color: lighten($sidebar-dark-bg, 10%);
  304. }
  305. }
  306. .form-control-navbar + .input-group-prepend,
  307. .form-control-navbar + .input-group-append {
  308. > .btn-navbar {
  309. background-color: lighten($sidebar-dark-bg, 5%);
  310. color: $white;
  311. border: 1px solid lighten($sidebar-dark-bg, 15%);
  312. border-left: none;
  313. }
  314. }
  315. }
  316. @include dark-mode () {
  317. .form-control:not(.form-control-navbar):not(.form-control-sidebar),
  318. .custom-select,
  319. .custom-file-label,
  320. .custom-file-label::after,
  321. .custom-control-label::before,
  322. .input-group-text {
  323. background-color: $dark;
  324. color: $white;
  325. }
  326. .form-control:not(.form-control-navbar):not(.form-control-sidebar):not(.is-invalid):not(:focus),
  327. .custom-file-label,
  328. .custom-file-label::after {
  329. border-color: $gray-600;
  330. }
  331. select {
  332. background-color: $dark;
  333. color: $white;
  334. border-color: $gray-600;
  335. }
  336. .custom-select {
  337. background: $dark $custom-select-dark-background;
  338. &[multiple]{
  339. background: $dark;
  340. }
  341. }
  342. .input-group-text {
  343. border-color: $gray-600;
  344. }
  345. .custom-control-input:disabled ~ .custom-control-label::before,
  346. .custom-control-input[disabled] ~ .custom-control-label::before {
  347. background-color: lighten($dark, 5%);
  348. border-color: $gray-600;
  349. color: $white;
  350. }
  351. input:-webkit-autofill,
  352. input:-webkit-autofill:hover,
  353. input:-webkit-autofill:focus,
  354. textarea:-webkit-autofill,
  355. textarea:-webkit-autofill:hover,
  356. textarea:-webkit-autofill:focus,
  357. select:-webkit-autofill,
  358. select:-webkit-autofill:hover,
  359. select:-webkit-autofill:focus {
  360. -webkit-text-fill-color: $white;
  361. }
  362. .custom-range {
  363. &::-webkit-slider-runnable-track {
  364. background-color: lighten($dark, 7.5%);
  365. }
  366. &::-moz-range-track {
  367. background-color: lighten($dark, 7.5%);
  368. }
  369. &::-ms-track {
  370. background-color: lighten($dark, 7.5%);
  371. }
  372. @each $name, $color in $theme-colors-alt {
  373. @include custom-range-variant($name, $color);
  374. }
  375. @each $name, $color in $colors-alt {
  376. @include custom-range-variant($name, $color);
  377. }
  378. }
  379. // custom switch color variations
  380. .custom-switch {
  381. @each $name, $color in $theme-colors-alt {
  382. @include custom-switch-variant($name, $color);
  383. }
  384. @each $name, $color in $colors-alt {
  385. @include custom-switch-variant($name, $color);
  386. }
  387. }
  388. @each $name, $color in $theme-colors-alt {
  389. @include custom-control-input-variant($name, $color);
  390. }
  391. @each $name, $color in $colors-alt {
  392. @include custom-control-input-variant($name, $color);
  393. }
  394. }