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.

132 lines
3.8 KiB

8 months ago
  1. //
  2. // Base styles
  3. //
  4. .input-group {
  5. position: relative;
  6. display: flex;
  7. flex-wrap: wrap; // For form validation feedback
  8. align-items: stretch;
  9. width: 100%;
  10. > .form-control,
  11. > .form-select,
  12. > .form-floating {
  13. position: relative; // For focus state's z-index
  14. flex: 1 1 auto;
  15. width: 1%;
  16. min-width: 0; // https://stackoverflow.com/questions/36247140/why-dont-flex-items-shrink-past-content-size
  17. }
  18. // Bring the "active" form control to the top of surrounding elements
  19. > .form-control:focus,
  20. > .form-select:focus,
  21. > .form-floating:focus-within {
  22. z-index: 5;
  23. }
  24. // Ensure buttons are always above inputs for more visually pleasing borders.
  25. // This isn't needed for `.input-group-text` since it shares the same border-color
  26. // as our inputs.
  27. .btn {
  28. position: relative;
  29. z-index: 2;
  30. &:focus {
  31. z-index: 5;
  32. }
  33. }
  34. }
  35. // Textual addons
  36. //
  37. // Serves as a catch-all element for any text or radio/checkbox input you wish
  38. // to prepend or append to an input.
  39. .input-group-text {
  40. display: flex;
  41. align-items: center;
  42. padding: $input-group-addon-padding-y $input-group-addon-padding-x;
  43. @include font-size($input-font-size); // Match inputs
  44. font-weight: $input-group-addon-font-weight;
  45. line-height: $input-line-height;
  46. color: $input-group-addon-color;
  47. text-align: center;
  48. white-space: nowrap;
  49. background-color: $input-group-addon-bg;
  50. border: $input-border-width solid $input-group-addon-border-color;
  51. @include border-radius($input-border-radius);
  52. }
  53. // Sizing
  54. //
  55. // Remix the default form control sizing classes into new ones for easier
  56. // manipulation.
  57. .input-group-lg > .form-control,
  58. .input-group-lg > .form-select,
  59. .input-group-lg > .input-group-text,
  60. .input-group-lg > .btn {
  61. padding: $input-padding-y-lg $input-padding-x-lg;
  62. @include font-size($input-font-size-lg);
  63. @include border-radius($input-border-radius-lg);
  64. }
  65. .input-group-sm > .form-control,
  66. .input-group-sm > .form-select,
  67. .input-group-sm > .input-group-text,
  68. .input-group-sm > .btn {
  69. padding: $input-padding-y-sm $input-padding-x-sm;
  70. @include font-size($input-font-size-sm);
  71. @include border-radius($input-border-radius-sm);
  72. }
  73. .input-group-lg > .form-select,
  74. .input-group-sm > .form-select {
  75. padding-right: $form-select-padding-x + $form-select-indicator-padding;
  76. }
  77. // Rounded corners
  78. //
  79. // These rulesets must come after the sizing ones to properly override sm and lg
  80. // border-radius values when extending. They're more specific than we'd like
  81. // with the `.input-group >` part, but without it, we cannot override the sizing.
  82. // stylelint-disable-next-line no-duplicate-selectors
  83. .input-group {
  84. &:not(.has-validation) {
  85. > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
  86. > .dropdown-toggle:nth-last-child(n + 3),
  87. > .form-floating:not(:last-child) > .form-control,
  88. > .form-floating:not(:last-child) > .form-select {
  89. @include border-end-radius(0);
  90. }
  91. }
  92. &.has-validation {
  93. > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating),
  94. > .dropdown-toggle:nth-last-child(n + 4),
  95. > .form-floating:nth-last-child(n + 3) > .form-control,
  96. > .form-floating:nth-last-child(n + 3) > .form-select {
  97. @include border-end-radius(0);
  98. }
  99. }
  100. $validation-messages: "";
  101. @each $state in map-keys($form-validation-states) {
  102. $validation-messages: $validation-messages + ":not(." + unquote($state) + "-tooltip)" + ":not(." + unquote($state) + "-feedback)";
  103. }
  104. > :not(:first-child):not(.dropdown-menu)#{$validation-messages} {
  105. margin-left: calc(#{$input-border-width} * -1); // stylelint-disable-line function-disallowed-list
  106. @include border-start-radius(0);
  107. }
  108. > .form-floating:not(:first-child) > .form-control,
  109. > .form-floating:not(:first-child) > .form-select {
  110. @include border-start-radius(0);
  111. }
  112. }