_button-group.scss 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // stylelint-disable selector-no-qualifying-type
  2. // Make the div behave like a button
  3. .btn-group,
  4. .btn-group-vertical {
  5. position: relative;
  6. display: inline-flex;
  7. vertical-align: middle; // match .btn alignment given font-size hack above
  8. > .btn {
  9. position: relative;
  10. flex: 1 1 auto;
  11. // Bring the hover, focused, and "active" buttons to the front to overlay
  12. // the borders properly
  13. @include hover() {
  14. z-index: 1;
  15. }
  16. &:focus,
  17. &:active,
  18. &.active {
  19. z-index: 1;
  20. }
  21. }
  22. }
  23. // Optional: Group multiple button groups together for a toolbar
  24. .btn-toolbar {
  25. display: flex;
  26. flex-wrap: wrap;
  27. justify-content: flex-start;
  28. .input-group {
  29. width: auto;
  30. }
  31. }
  32. .btn-group {
  33. // Prevent double borders when buttons are next to each other
  34. > .btn:not(:first-child),
  35. > .btn-group:not(:first-child) {
  36. margin-left: -$btn-border-width;
  37. }
  38. // Reset rounded corners
  39. > .btn:not(:last-child):not(.dropdown-toggle),
  40. > .btn-group:not(:last-child) > .btn {
  41. @include border-right-radius(0);
  42. }
  43. > .btn:not(:first-child),
  44. > .btn-group:not(:first-child) > .btn {
  45. @include border-left-radius(0);
  46. }
  47. }
  48. // Sizing
  49. //
  50. // Remix the default button sizing classes into new ones for easier manipulation.
  51. .btn-group-sm > .btn {
  52. @extend .btn-sm;
  53. }
  54. .btn-group-lg > .btn {
  55. @extend .btn-lg;
  56. }
  57. //
  58. // Split button dropdowns
  59. //
  60. .dropdown-toggle-split {
  61. padding-right: $btn-padding-x * 0.75;
  62. padding-left: $btn-padding-x * 0.75;
  63. &::after,
  64. .dropup &::after,
  65. .dropright &::after {
  66. margin-left: 0;
  67. }
  68. .dropleft &::before {
  69. margin-right: 0;
  70. }
  71. }
  72. .btn-sm + .dropdown-toggle-split {
  73. padding-right: $btn-padding-x-sm * 0.75;
  74. padding-left: $btn-padding-x-sm * 0.75;
  75. }
  76. .btn-lg + .dropdown-toggle-split {
  77. padding-right: $btn-padding-x-lg * 0.75;
  78. padding-left: $btn-padding-x-lg * 0.75;
  79. }
  80. // The clickable button for toggling the menu
  81. // Set the same inset shadow as the :active state
  82. .btn-group.show .dropdown-toggle {
  83. @include box-shadow($btn-active-box-shadow);
  84. // Show no shadow for `.btn-link` since it has no other button styles.
  85. &.btn-link {
  86. @include box-shadow(none);
  87. }
  88. }
  89. //
  90. // Vertical button groups
  91. //
  92. .btn-group-vertical {
  93. flex-direction: column;
  94. align-items: flex-start;
  95. justify-content: center;
  96. > .btn,
  97. > .btn-group {
  98. width: 100%;
  99. }
  100. > .btn:not(:first-child),
  101. > .btn-group:not(:first-child) {
  102. margin-top: -$btn-border-width;
  103. }
  104. // Reset rounded corners
  105. > .btn:not(:last-child):not(.dropdown-toggle),
  106. > .btn-group:not(:last-child) > .btn {
  107. @include border-bottom-radius(0);
  108. }
  109. > .btn:not(:first-child),
  110. > .btn-group:not(:first-child) > .btn {
  111. @include border-top-radius(0);
  112. }
  113. }
  114. // Checkbox and radio options
  115. //
  116. // In order to support the browser's form validation feedback, powered by the
  117. // `required` attribute, we have to "hide" the inputs via `clip`. We cannot use
  118. // `display: none;` or `visibility: hidden;` as that also hides the popover.
  119. // Simply visually hiding the inputs via `opacity` would leave them clickable in
  120. // certain cases which is prevented by using `clip` and `pointer-events`.
  121. // This way, we ensure a DOM element is visible to position the popover from.
  122. //
  123. // See https://github.com/twbs/bootstrap/pull/12794 and
  124. // https://github.com/twbs/bootstrap/pull/14559 for more information.
  125. .btn-group-toggle {
  126. > .btn,
  127. > .btn-group > .btn {
  128. margin-bottom: 0; // Override default `<label>` value
  129. input[type='radio'],
  130. input[type='checkbox'] {
  131. position: absolute;
  132. clip: rect(0, 0, 0, 0);
  133. pointer-events: none;
  134. }
  135. }
  136. }