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.

219 lines
6.6 KiB

  1. //
  2. // General form controls (plus a few specific high-level interventions)
  3. //
  4. .form-control {
  5. display: block;
  6. width: 100%;
  7. padding: $input-padding-y $input-padding-x;
  8. font-family: $input-font-family;
  9. @include font-size($input-font-size);
  10. font-weight: $input-font-weight;
  11. line-height: $input-line-height;
  12. color: $input-color;
  13. background-color: $input-bg;
  14. background-clip: padding-box;
  15. border: $input-border-width solid $input-border-color;
  16. appearance: none; // Fix appearance for date inputs in Safari
  17. // Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
  18. @include border-radius($input-border-radius, 0);
  19. @include box-shadow($input-box-shadow);
  20. @include transition($input-transition);
  21. &[type="file"] {
  22. overflow: hidden; // prevent pseudo element button overlap
  23. &:not(:disabled):not([readonly]) {
  24. cursor: pointer;
  25. }
  26. }
  27. // Customize the `:focus` state to imitate native WebKit styles.
  28. &:focus {
  29. color: $input-focus-color;
  30. background-color: $input-focus-bg;
  31. border-color: $input-focus-border-color;
  32. outline: 0;
  33. @if $enable-shadows {
  34. @include box-shadow($input-box-shadow, $input-focus-box-shadow);
  35. } @else {
  36. // Avoid using mixin so we can pass custom focus shadow properly
  37. box-shadow: $input-focus-box-shadow;
  38. }
  39. }
  40. // Add some height to date inputs on iOS
  41. // https://github.com/twbs/bootstrap/issues/23307
  42. // TODO: we can remove this workaround once https://bugs.webkit.org/show_bug.cgi?id=198959 is resolved
  43. &::-webkit-date-and-time-value {
  44. // Multiply line-height by 1em if it has no unit
  45. height: if(unit($input-line-height) == "", $input-line-height * 1em, $input-line-height);
  46. }
  47. // Placeholder
  48. &::placeholder {
  49. color: $input-placeholder-color;
  50. // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
  51. opacity: 1;
  52. }
  53. // Disabled and read-only inputs
  54. //
  55. // HTML5 says that controls under a fieldset > legend:first-child won't be
  56. // disabled if the fieldset is disabled. Due to implementation difficulty, we
  57. // don't honor that edge case; we style them as disabled anyway.
  58. &:disabled,
  59. &[readonly] {
  60. background-color: $input-disabled-bg;
  61. border-color: $input-disabled-border-color;
  62. // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
  63. opacity: 1;
  64. }
  65. // File input buttons theming
  66. &::file-selector-button {
  67. padding: $input-padding-y $input-padding-x;
  68. margin: (-$input-padding-y) (-$input-padding-x);
  69. margin-inline-end: $input-padding-x;
  70. color: $form-file-button-color;
  71. @include gradient-bg($form-file-button-bg);
  72. pointer-events: none;
  73. border-color: inherit;
  74. border-style: solid;
  75. border-width: 0;
  76. border-inline-end-width: $input-border-width;
  77. border-radius: 0; // stylelint-disable-line property-disallowed-list
  78. @include transition($btn-transition);
  79. }
  80. &:hover:not(:disabled):not([readonly])::file-selector-button {
  81. background-color: $form-file-button-hover-bg;
  82. }
  83. &::-webkit-file-upload-button {
  84. padding: $input-padding-y $input-padding-x;
  85. margin: (-$input-padding-y) (-$input-padding-x);
  86. margin-inline-end: $input-padding-x;
  87. color: $form-file-button-color;
  88. @include gradient-bg($form-file-button-bg);
  89. pointer-events: none;
  90. border-color: inherit;
  91. border-style: solid;
  92. border-width: 0;
  93. border-inline-end-width: $input-border-width;
  94. border-radius: 0; // stylelint-disable-line property-disallowed-list
  95. @include transition($btn-transition);
  96. }
  97. &:hover:not(:disabled):not([readonly])::-webkit-file-upload-button {
  98. background-color: $form-file-button-hover-bg;
  99. }
  100. }
  101. // Readonly controls as plain text
  102. //
  103. // Apply class to a readonly input to make it appear like regular plain
  104. // text (without any border, background color, focus indicator)
  105. .form-control-plaintext {
  106. display: block;
  107. width: 100%;
  108. padding: $input-padding-y 0;
  109. margin-bottom: 0; // match inputs if this class comes on inputs with default margins
  110. line-height: $input-line-height;
  111. color: $input-plaintext-color;
  112. background-color: transparent;
  113. border: solid transparent;
  114. border-width: $input-border-width 0;
  115. &.form-control-sm,
  116. &.form-control-lg {
  117. padding-right: 0;
  118. padding-left: 0;
  119. }
  120. }
  121. // Form control sizing
  122. //
  123. // Build on `.form-control` with modifier classes to decrease or increase the
  124. // height and font-size of form controls.
  125. //
  126. // Repeated in `_input_group.scss` to avoid Sass extend issues.
  127. .form-control-sm {
  128. min-height: $input-height-sm;
  129. padding: $input-padding-y-sm $input-padding-x-sm;
  130. @include font-size($input-font-size-sm);
  131. @include border-radius($input-border-radius-sm);
  132. &::file-selector-button {
  133. padding: $input-padding-y-sm $input-padding-x-sm;
  134. margin: (-$input-padding-y-sm) (-$input-padding-x-sm);
  135. margin-inline-end: $input-padding-x-sm;
  136. }
  137. &::-webkit-file-upload-button {
  138. padding: $input-padding-y-sm $input-padding-x-sm;
  139. margin: (-$input-padding-y-sm) (-$input-padding-x-sm);
  140. margin-inline-end: $input-padding-x-sm;
  141. }
  142. }
  143. .form-control-lg {
  144. min-height: $input-height-lg;
  145. padding: $input-padding-y-lg $input-padding-x-lg;
  146. @include font-size($input-font-size-lg);
  147. @include border-radius($input-border-radius-lg);
  148. &::file-selector-button {
  149. padding: $input-padding-y-lg $input-padding-x-lg;
  150. margin: (-$input-padding-y-lg) (-$input-padding-x-lg);
  151. margin-inline-end: $input-padding-x-lg;
  152. }
  153. &::-webkit-file-upload-button {
  154. padding: $input-padding-y-lg $input-padding-x-lg;
  155. margin: (-$input-padding-y-lg) (-$input-padding-x-lg);
  156. margin-inline-end: $input-padding-x-lg;
  157. }
  158. }
  159. // Make sure textareas don't shrink too much when resized
  160. // https://github.com/twbs/bootstrap/pull/29124
  161. // stylelint-disable selector-no-qualifying-type
  162. textarea {
  163. &.form-control {
  164. min-height: $input-height;
  165. }
  166. &.form-control-sm {
  167. min-height: $input-height-sm;
  168. }
  169. &.form-control-lg {
  170. min-height: $input-height-lg;
  171. }
  172. }
  173. // stylelint-enable selector-no-qualifying-type
  174. .form-control-color {
  175. width: $form-color-width;
  176. height: auto; // Override fixed browser height
  177. padding: $input-padding-y;
  178. &:not(:disabled):not([readonly]) {
  179. cursor: pointer;
  180. }
  181. &::-moz-color-swatch {
  182. height: if(unit($input-line-height) == "", $input-line-height * 1em, $input-line-height);
  183. @include border-radius($input-border-radius);
  184. }
  185. &::-webkit-color-swatch {
  186. height: if(unit($input-line-height) == "", $input-line-height * 1em, $input-line-height);
  187. @include border-radius($input-border-radius);
  188. }
  189. }