_input-fields.scss 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /* Text Inputs + Textarea
  2. ========================================================================== */
  3. /* Style Placeholders */
  4. ::placeholder {
  5. color: $placeholder-text-color;
  6. }
  7. /* Text inputs */
  8. input:not([type]),
  9. input[type=text]:not(.browser-default),
  10. input[type=password]:not(.browser-default),
  11. input[type=email]:not(.browser-default),
  12. input[type=url]:not(.browser-default),
  13. input[type=time]:not(.browser-default),
  14. input[type=date]:not(.browser-default),
  15. input[type=datetime]:not(.browser-default),
  16. input[type=datetime-local]:not(.browser-default),
  17. input[type=tel]:not(.browser-default),
  18. input[type=number]:not(.browser-default),
  19. input[type=search]:not(.browser-default),
  20. textarea.materialize-textarea {
  21. // General Styles
  22. background-color: transparent;
  23. border: none;
  24. border-bottom: $input-border;
  25. border-radius: 0;
  26. outline: none;
  27. height: $input-height;
  28. width: 100%;
  29. font-size: $input-font-size;
  30. margin: $input-margin;
  31. padding: $input-padding;
  32. box-shadow: none;
  33. box-sizing: content-box;
  34. transition: box-shadow .3s, border .3s;
  35. // Disabled input style
  36. &:disabled,
  37. &[readonly="readonly"] {
  38. color: $input-disabled-color;
  39. border-bottom: $input-disabled-border;
  40. }
  41. // Disabled label style
  42. &:disabled+label,
  43. &[readonly="readonly"]+label {
  44. color: $input-disabled-color;
  45. }
  46. // Focused input style
  47. &:focus:not([readonly]) {
  48. border-bottom: 1px solid $input-focus-color;
  49. box-shadow: 0 1px 0 0 $input-focus-color;
  50. }
  51. // Focused label style
  52. &:focus:not([readonly])+label {
  53. color: $input-focus-color;
  54. }
  55. // Hide helper text on data message
  56. &.valid ~ .helper-text[data-success],
  57. &:focus.valid ~ .helper-text[data-success],
  58. &.invalid ~ .helper-text[data-error],
  59. &:focus.invalid ~ .helper-text[data-error] {
  60. @extend %hidden-text;
  61. }
  62. // Valid Input Style
  63. &.valid,
  64. &:focus.valid {
  65. @extend %valid-input-style;
  66. }
  67. // Custom Success Message
  68. &.valid ~ .helper-text:after,
  69. &:focus.valid ~ .helper-text:after {
  70. @extend %custom-success-message;
  71. }
  72. &:focus.valid ~ label {
  73. color: $input-success-color;
  74. }
  75. // Invalid Input Style
  76. &.invalid,
  77. &:focus.invalid {
  78. @extend %invalid-input-style;
  79. }
  80. // Custom Error message
  81. &.invalid ~ .helper-text:after,
  82. &:focus.invalid ~ .helper-text:after {
  83. @extend %custom-error-message;
  84. }
  85. &:focus.invalid ~ label {
  86. color: $input-error-color;
  87. }
  88. // Full width label when using validate for error messages
  89. &.validate + label {
  90. width: 100%;
  91. }
  92. // Form Message Shared Styles
  93. & + label:after {
  94. @extend %input-after-style;
  95. }
  96. }
  97. /* Validation Sass Placeholders */
  98. %valid-input-style {
  99. border-bottom: 1px solid $input-success-color;
  100. box-shadow: 0 1px 0 0 $input-success-color;
  101. }
  102. %invalid-input-style {
  103. border-bottom: $input-invalid-border;
  104. box-shadow: 0 1px 0 0 $input-error-color;
  105. }
  106. %hidden-text {
  107. color: transparent;
  108. user-select: none;
  109. pointer-events: none;
  110. }
  111. %custom-success-message {
  112. content: attr(data-success);
  113. color: $input-success-color;
  114. }
  115. %custom-error-message {
  116. content: attr(data-error);
  117. color: $input-error-color;
  118. }
  119. %input-after-style {
  120. display: block;
  121. content: "";
  122. position: absolute;
  123. top: 100%;
  124. left: 0;
  125. opacity: 0;
  126. transition: .2s opacity ease-out, .2s color ease-out;
  127. }
  128. // Styling for input field wrapper
  129. .input-field {
  130. // Inline styles
  131. &.inline {
  132. display: inline-block;
  133. vertical-align: middle;
  134. margin-left: 5px;
  135. input,
  136. .select-dropdown {
  137. margin-bottom: 1rem;
  138. }
  139. }
  140. // Gutter spacing
  141. &.col {
  142. label {
  143. left: $gutter-width / 2;
  144. }
  145. .prefix ~ label,
  146. .prefix ~ .validate ~ label {
  147. width: calc(100% - 3rem - #{$gutter-width});
  148. }
  149. }
  150. position: relative;
  151. margin-top: 1rem;
  152. margin-bottom: 1rem;
  153. & > label {
  154. color: $input-border-color;
  155. position: absolute;
  156. top: 0;
  157. left: 0;
  158. font-size: 1rem;
  159. cursor: text;
  160. transition: transform .2s ease-out, color .2s ease-out;
  161. transform-origin: 0% 100%;
  162. text-align: initial;
  163. transform: translateY(12px);
  164. &:not(.label-icon).active {
  165. transform: translateY(-14px) scale(.8);
  166. transform-origin: 0 0;
  167. }
  168. }
  169. // Autofill + date + time inputs
  170. & > input[type]:-webkit-autofill:not(.browser-default):not([type="search"]) + label,
  171. & > input[type=date]:not(.browser-default) + label,
  172. & > input[type=time]:not(.browser-default) + label {
  173. transform: translateY(-14px) scale(.8);
  174. transform-origin: 0 0;
  175. }
  176. .helper-text {
  177. &::after {
  178. opacity: 1;
  179. position: absolute;
  180. top: 0;
  181. left: 0;
  182. }
  183. position: relative;
  184. min-height: 18px;
  185. display: block;
  186. font-size: 12px;
  187. color: rgba(0,0,0,.54);
  188. }
  189. // Prefix Icons
  190. .prefix {
  191. position: absolute;
  192. width: $input-height;
  193. font-size: $input-icon-size;
  194. transition: color .2s;
  195. top: ($input-height - $input-icon-size) / 2;
  196. &.active { color: $input-focus-color; }
  197. }
  198. .prefix ~ input,
  199. .prefix ~ textarea,
  200. .prefix ~ label,
  201. .prefix ~ .validate ~ label,
  202. .prefix ~ .helper-text,
  203. .prefix ~ .autocomplete-content {
  204. margin-left: 3rem;
  205. width: 92%;
  206. width: calc(100% - 3rem);
  207. }
  208. .prefix ~ label { margin-left: 3rem; }
  209. @media #{$medium-and-down} {
  210. .prefix ~ input {
  211. width: 86%;
  212. width: calc(100% - 3rem);
  213. }
  214. }
  215. @media #{$small-and-down} {
  216. .prefix ~ input {
  217. width: 80%;
  218. width: calc(100% - 3rem);
  219. }
  220. }
  221. }
  222. /* Search Field */
  223. .input-field input[type=search] {
  224. display: block;
  225. line-height: inherit;
  226. transition: .3s background-color;
  227. .nav-wrapper & {
  228. height: inherit;
  229. padding-left: 4rem;
  230. width: calc(100% - 4rem);
  231. border: 0;
  232. box-shadow: none;
  233. }
  234. &:focus:not(.browser-default) {
  235. background-color: $input-background;
  236. border: 0;
  237. box-shadow: none;
  238. color: #444;
  239. & + label i,
  240. & ~ .mdi-navigation-close,
  241. & ~ .material-icons {
  242. color: #444;
  243. }
  244. }
  245. & + .label-icon {
  246. transform: none;
  247. left: 1rem;
  248. }
  249. & ~ .mdi-navigation-close,
  250. & ~ .material-icons {
  251. position: absolute;
  252. top: 0;
  253. right: 1rem;
  254. color: transparent;
  255. cursor: pointer;
  256. font-size: $input-icon-size;
  257. transition: .3s color;
  258. }
  259. }
  260. /* Textarea */
  261. // Default textarea
  262. textarea {
  263. width: 100%;
  264. height: $input-height;
  265. background-color: transparent;
  266. &.materialize-textarea {
  267. line-height: normal;
  268. overflow-y: hidden; /* prevents scroll bar flash */
  269. padding: .8rem 0 .8rem 0; /* prevents text jump on Enter keypress */
  270. resize: none;
  271. min-height: $input-height;
  272. box-sizing: border-box;
  273. }
  274. }
  275. // For textarea autoresize
  276. .hiddendiv {
  277. visibility: hidden;
  278. white-space: pre-wrap;
  279. word-wrap: break-word;
  280. overflow-wrap: break-word; /* future version of deprecated 'word-wrap' */
  281. padding-top: 1.2rem; /* prevents text jump on Enter keypress */
  282. // Reduces repaints
  283. position: absolute;
  284. top: 0;
  285. z-index: -1;
  286. }
  287. /* Autocomplete */
  288. .autocomplete-content {
  289. li {
  290. .highlight { color: #444; }
  291. img {
  292. height: $dropdown-item-height - 10;
  293. width: $dropdown-item-height - 10;
  294. margin: 5px 15px;
  295. }
  296. }
  297. }
  298. /* Character Counter */
  299. .character-counter {
  300. min-height: 18px;
  301. }