_forms.scss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. // Forms basic
  2. // Input + label wrapper styles
  3. .md-form {
  4. // Text inputs
  5. input[type=text],
  6. input[type=password],
  7. input[type=email],
  8. input[type=url],
  9. input[type=time],
  10. input[type=date],
  11. input[type=datetime-local],
  12. input[type=tel],
  13. input[type=number],
  14. input[type=search-md],
  15. input[type=search],
  16. textarea.md-textarea {
  17. // General Styles
  18. transition: $input-transition;
  19. outline: none;
  20. box-shadow: none;
  21. border: none;
  22. border-bottom: 1px solid $input-border-color;
  23. border-radius: 0;
  24. box-sizing: content-box;
  25. background-color: transparent;
  26. // Focused input style
  27. &:focus:not([readonly]) {
  28. box-shadow: 0 1px 0 0 $input-md-focus-color;
  29. border-bottom: 1px solid $input-md-focus-color;
  30. // Focused label style
  31. +label {
  32. color: $input-md-focus-color;
  33. }
  34. }
  35. // Form message shared styles
  36. +label:after {
  37. content: "";
  38. position: absolute;
  39. top: $input-label-after-top;
  40. display: block;
  41. opacity: 0;
  42. transition: $input-label-after-transition;
  43. }
  44. // Valid input style
  45. &.valid,
  46. &:focus.valid {
  47. border-bottom: 1px solid $input-success-color;
  48. box-shadow: 0 1px 0 0 $input-success-color;
  49. }
  50. &.valid+label:after,
  51. &:focus.valid+label:after {
  52. content: attr(data-success);
  53. color: $input-success-color;
  54. opacity: 1;
  55. }
  56. // Invalid input style
  57. &.invalid,
  58. &:focus.invalid {
  59. border-bottom: 1px solid $input-error-color;
  60. box-shadow: 0 1px 0 0 $input-error-color;
  61. }
  62. &.invalid+label:after,
  63. &:focus.invalid+label:after {
  64. content: attr(data-error);
  65. color: $input-error-color;
  66. opacity: 1;
  67. }
  68. &.form-control.valid+label:after,
  69. &.form-control:focus.valid+label:after {
  70. top: $input-label-valid-top;
  71. }
  72. &.form-control.invalid+label:after,
  73. &.form-control:focus.invalid+label:after {
  74. top: $input-label-invalid-top;
  75. }
  76. &.form-control-lg.valid+label:after,
  77. &.form-control-lg:focus.valid+label:after {
  78. top: $input-label-valid-top-lg;
  79. }
  80. &.form-control-lg.invalid+label:after,
  81. &.form-control-lg:focus.invalid+label:after {
  82. top: $input-label-invalid-top-lg;
  83. }
  84. &.form-control-sm.valid+label:after,
  85. &.form-control-sm:focus.valid+label:after {
  86. top: $input-label-valid-top-sm;
  87. }
  88. &.form-control-sm.invalid+label:after,
  89. &.form-control-sm:focus.invalid+label:after {
  90. top: $input-label-invalid-top-sm;
  91. }
  92. }
  93. >input[type=date]:not(.browser-default)+label {
  94. transform: translateY(-27px) scale(0.8);
  95. transform-origin: 0 0;
  96. }
  97. >input[type]:-webkit-autofill:not(.browser-default):not([type="search"])+label,
  98. >input[type=time]:not(.browser-default)+label {
  99. transform: translateY(-25px);
  100. transform-origin: 0 0;
  101. font-size: .8rem;
  102. }
  103. .was-validated {
  104. input[type=text] {
  105. &:valid {
  106. +label {
  107. color: $input-success-color !important;
  108. }
  109. }
  110. &:invalid {
  111. +label {
  112. color: $input-error-color !important;
  113. }
  114. }
  115. }
  116. .form-control {
  117. &:valid:focus {
  118. box-shadow: 0 1px 0 0 $input-success-color !important;
  119. }
  120. &:valid {
  121. border-color: $input-success-color !important;
  122. }
  123. &:invalid:focus {
  124. box-shadow: 0 1px 0 0 $input-error-color !important;
  125. }
  126. &:invalid {
  127. border-color: $input-error-color !important;
  128. }
  129. }
  130. }
  131. // Input with label
  132. .form-control {
  133. margin: 0 0 $input-form-control-margin-bottom 0;
  134. border-radius: 0;
  135. padding: $input-form-control-padding-top 0 $input-form-control-padding-bottom 0;
  136. // background-image: none;
  137. background-color: transparent;
  138. height: auto;
  139. &:focus {
  140. box-shadow: none;
  141. // background: transparent;
  142. }
  143. &:disabled,
  144. &[readonly] {
  145. border-bottom: 1px solid $grey-lighten-1;
  146. background-color: transparent;
  147. }
  148. &.is-valid {
  149. border-color: $input-success-color;
  150. &:focus {
  151. border-color: $input-success-color !important;
  152. box-shadow: 0 1px 0 0 $input-success-color !important;
  153. }
  154. }
  155. &.is-invalid {
  156. border-color: $input-error-color;
  157. &:focus {
  158. box-shadow: 0 1px 0 0 $input-error-color !important;
  159. border-color: $input-error-color !important;
  160. }
  161. }
  162. &.is-valid,
  163. &.is-invalid {
  164. background-position: center right !important;
  165. }
  166. }
  167. @include make-input($input-validate-mb, $input-label-font-size, $input-label-active-font-size, $input-prefix-top, $input-prefix-font-size, $input-prefix-margin-left, $input-prefix-width, $input-form-text-ml);
  168. position: relative;
  169. margin-top: $input-md-form-margin-top;
  170. margin-bottom: $input-md-form-margin-bottom;
  171. label {
  172. position: absolute;
  173. top: 0;
  174. left: 0;
  175. font-size: 1rem;
  176. transition: transform .2s ease-out, color .2s ease-out;
  177. transform-origin: 0% 100%;
  178. transform: translateY(12px);
  179. cursor: text;
  180. color: $input-label-color;
  181. &.active {
  182. transform: translateY(-14px) scale(.8);
  183. }
  184. }
  185. .prefix {
  186. position: absolute;
  187. transition: $input-prefix-transition;
  188. &.active {
  189. color: $input-md-focus-color;
  190. }
  191. }
  192. &.form-lg {
  193. @include make-input($input-validate-mb-lg, $input-label-font-size-lg, $input-label-active-font-size-lg, $input-prefix-top-lg, $input-prefix-font-size-lg, $input-prefix-margin-left-lg, $input-prefix-width-lg, $input-form-text-ml-lg);
  194. }
  195. &.form-sm {
  196. @include make-input($input-validate-mb-sm, $input-label-font-size-sm, $input-label-active-font-size-sm, $input-prefix-top-sm, $input-prefix-font-size-sm, $input-prefix-margin-left-sm, $input-prefix-width-sm, $input-form-text-ml-sm);
  197. }
  198. // Textarea
  199. textarea {
  200. &.md-textarea {
  201. overflow-y: hidden;
  202. padding: $textarea-padding 0;
  203. resize: none;
  204. }
  205. &.md-textarea-auto {
  206. padding: 0;
  207. padding-top: $textarea-padding;
  208. }
  209. // Label color for textarea
  210. ~label {
  211. &.active {
  212. color: $input-md-focus-color;
  213. }
  214. }
  215. }
  216. &.md-outline {
  217. position: relative;
  218. margin-top: 1.5rem;
  219. margin-bottom: 1.5rem;
  220. input[type=text],
  221. input[type=password],
  222. input[type=email],
  223. input[type=url],
  224. input[type=time],
  225. input[type=date],
  226. input[type=datetime-local],
  227. input[type=tel],
  228. input[type=number],
  229. input[type=search-md],
  230. input[type=search],
  231. textarea.md-textarea {
  232. // General Styles
  233. transition: all .3s;
  234. outline: none;
  235. box-shadow: none;
  236. border: 1px solid #dadce0;
  237. border-radius: 4px;
  238. background-color: transparent;
  239. box-sizing: border-box;
  240. // Focused input style
  241. &:focus:not([readonly]) {
  242. border-color: #4285f4;
  243. box-shadow: inset 0px 0px 0px 1px #4285f4;
  244. // Focused label style
  245. +label {
  246. color: #4285f4;
  247. }
  248. }
  249. // Valid input style
  250. &.valid,
  251. &:focus.valid {
  252. border-color: $input-success-color;
  253. box-shadow: inset 0px 0px 0px 1px $input-success-color;
  254. }
  255. &:focus:not([readonly]).valid+label,
  256. &.valid+label:after,
  257. &:focus.valid+label:after {
  258. content: attr(data-success);
  259. color: $input-success-color;
  260. opacity: 1;
  261. }
  262. // Invalid input style
  263. &.invalid,
  264. &:focus.invalid {
  265. border-color: $input-error-color;
  266. box-shadow: inset 0px 0px 0px 1px $input-error-color;
  267. }
  268. &:focus:not([readonly]).invalid+label,
  269. &.invalid+label:after,
  270. &:focus.invalid+label:after {
  271. content: attr(data-error);
  272. color: $input-error-color;
  273. opacity: 1;
  274. }
  275. &.form-control.valid+label:after,
  276. &.form-control:focus.valid+label:after {
  277. top: 2.75rem;
  278. left: 0;
  279. position: absolute;
  280. }
  281. &.form-control.invalid+label:after,
  282. &.form-control:focus.invalid+label:after {
  283. top: 2.75rem;
  284. left: 0;
  285. position: absolute;
  286. }
  287. }
  288. >input[type]:-webkit-autofill:not(.browser-default):not([type="search"])+label,
  289. >input[type=time]:not(.browser-default)+label {
  290. transform: translateY(-17px);
  291. transform-origin: 0 0;
  292. background: #fff;
  293. font-weight: 500;
  294. padding-right: 5px;
  295. padding-left: 5px;
  296. font-size: 11px;
  297. left: 8px;
  298. }
  299. >input[type]:-webkit-autofill:not(.browser-default):not([type="search"])+label.active,
  300. >input[type=time]:not(.browser-default)+label.active {
  301. transform: translateY(-17px);
  302. transform-origin: 0 0;
  303. }
  304. .form-control {
  305. padding: .375rem .75rem;
  306. }
  307. label {
  308. font-size: 1rem;
  309. position: absolute;
  310. top: 0;
  311. left: 0;
  312. padding-left: 10px;
  313. transition: transform .2s ease-out, color .2s ease-out;
  314. transform-origin: 0% 100%;
  315. transform: translateY(9px);
  316. cursor: text;
  317. color: #757575;
  318. &.active {
  319. transform: translateY(-13px) scale(.8);
  320. background: #fff;
  321. font-weight: 500;
  322. padding-right: 5px;
  323. padding-left: 5px;
  324. left: 8px;
  325. }
  326. }
  327. &.form-lg {
  328. .form-control {
  329. &.form-control-lg {
  330. padding: .5rem .725rem;
  331. }
  332. }
  333. label {
  334. font-size: 1.25rem;
  335. transform: translateY(10px);
  336. &.active {
  337. font-size: 1.1rem;
  338. transform: translateY(-14px) scale(.8);
  339. }
  340. }
  341. .prefix {
  342. top: .65rem;
  343. font-size: 25px;
  344. ~input,
  345. ~textarea {
  346. margin-left: 2.2rem;
  347. width: calc(100% - 2.2rem);
  348. }
  349. ~label {
  350. margin-left: 2.2rem;
  351. }
  352. ~.form-text {
  353. margin-left: 2.3rem;
  354. }
  355. }
  356. }
  357. &.form-sm {
  358. .form-control {
  359. &.form-control-sm {
  360. padding: .25rem .625rem;
  361. }
  362. }
  363. label {
  364. font-size: .8rem;
  365. transform: translateY(8px);
  366. &.active {
  367. font-size: .85rem;
  368. transform: translateY(-12px) scale(.8);
  369. }
  370. }
  371. .prefix {
  372. top: .5rem;
  373. font-size: 15px;
  374. ~input,
  375. ~textarea {
  376. margin-left: 1.6rem;
  377. width: calc(100% - 1.6rem);
  378. }
  379. ~label {
  380. margin-left: 1.6rem;
  381. }
  382. ~.form-text {
  383. margin-left: 1.7rem;
  384. }
  385. }
  386. }
  387. .prefix {
  388. position: absolute;
  389. transition: color .2s;
  390. &:focus {
  391. color: #4285f4;
  392. }
  393. }
  394. .prefix {
  395. top: .6rem;
  396. font-size: 20px;
  397. ~input,
  398. ~textarea {
  399. margin-left: 2rem;
  400. width: calc(100% - 2rem);
  401. }
  402. ~label {
  403. margin-left: 2rem;
  404. }
  405. ~.form-text {
  406. margin-left: 2.1rem;
  407. }
  408. }
  409. .character-counter {
  410. margin-top: -.5rem;
  411. }
  412. }
  413. &.md-bg {
  414. input[type=text],
  415. input[type=password],
  416. input[type=email],
  417. input[type=url],
  418. input[type=time],
  419. input[type=date],
  420. input[type=datetime-local],
  421. input[type=tel],
  422. input[type=number],
  423. input[type=search-md],
  424. input[type=search],
  425. textarea.md-textarea {
  426. &:focus:not([readonly]) {
  427. box-shadow: none;
  428. border-bottom: none;
  429. }
  430. box-sizing: border-box;
  431. padding: 10px 5px;
  432. border: 0;
  433. border-top-left-radius: .3rem;
  434. border-top-right-radius: .3rem;
  435. background: #f5f5f5 no-repeat;
  436. background-image: linear-gradient(to bottom, $input-md-focus-color, $input-md-focus-color),
  437. linear-gradient(to bottom, $input-border-color, $input-border-color);
  438. background-size: 0 2px,
  439. 100% 1px;
  440. background-position: 50% 100%,
  441. 50% 100%;
  442. transition: background-size 0.3s cubic-bezier(0.64, 0.09, 0.08, 1);
  443. &:focus {
  444. background-color: #dcdcdc;
  445. background-size: 100% 2px, 100% 1px;
  446. outline: none;
  447. }
  448. }
  449. >input[type=date]:not(.browser-default)+label {
  450. transform: translateY(-12px) scale(0.8);
  451. transform-origin: 0 0;
  452. }
  453. >input[type]:-webkit-autofill:not(.browser-default):not([type="search"])+label,
  454. >input[type=time]:not(.browser-default)+label {
  455. transform: translateY(-12px);
  456. transform-origin: 0 0;
  457. font-size: .8rem;
  458. }
  459. .form-control {
  460. padding: 1.1rem .7rem .4rem !important;
  461. }
  462. label {
  463. top: 0;
  464. padding-left: .7rem;
  465. font-size: 1rem;
  466. transition: transform .2s ease-out, color .2s ease-out;
  467. transform-origin: 0% 100%;
  468. transform: translateY(13px);
  469. &.active {
  470. transform: translateY(-3px) scale(.8);
  471. font-weight: 500;
  472. padding-left: .75rem;
  473. }
  474. }
  475. &.form-lg {
  476. label {
  477. transform: translateY(16px);
  478. &.active {
  479. transform: translateY(-4px) scale(.8);
  480. }
  481. }
  482. }
  483. &.form-sm {
  484. label {
  485. transform: translateY(11px);
  486. &.active {
  487. transform: translateY(-2px) scale(.8);
  488. }
  489. }
  490. }
  491. }
  492. }
  493. .md-form .form-control.is-invalid,
  494. .was-validated .md-form .form-control:invalid {
  495. padding-right: 0;
  496. }
  497. .md-form .form-control.is-valid,
  498. .was-validated .md-form .form-control:valid {
  499. padding-right: 0;
  500. }
  501. .needs-validation .md-form label {
  502. left: .3rem;
  503. }
  504. // Custom fille input browser support
  505. @each $lang,
  506. $text in $custom-mdb-file-text {
  507. .custom-file-input {
  508. &:lang(#{$lang}) {
  509. &~.custom-file-label {
  510. &::after {
  511. content: $text;
  512. }
  513. }
  514. }
  515. }
  516. }