button-groups.less 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // Button groups
  3. // --------------------------------------------------
  4. // Make the div behave like a button
  5. .btn-group,
  6. .btn-group-vertical {
  7. position: relative;
  8. display: inline-block;
  9. vertical-align: middle; // match .btn alignment given font-size hack above
  10. > .btn {
  11. position: relative;
  12. float: left;
  13. // Bring the "active" button to the front
  14. &:hover,
  15. &:focus,
  16. &:active,
  17. &.active {
  18. z-index: 2;
  19. }
  20. &:focus {
  21. // Remove focus outline when dropdown JS adds it after closing the menu
  22. outline: none;
  23. }
  24. }
  25. }
  26. // Prevent double borders when buttons are next to each other
  27. .btn-group {
  28. .btn + .btn,
  29. .btn + .btn-group,
  30. .btn-group + .btn,
  31. .btn-group + .btn-group {
  32. margin-left: -1px;
  33. }
  34. }
  35. // Optional: Group multiple button groups together for a toolbar
  36. .btn-toolbar {
  37. margin-left: -5px; // Offset the first child's margin
  38. &:extend(.clearfix all);
  39. .btn-group,
  40. .input-group {
  41. float: left;
  42. }
  43. > .btn,
  44. > .btn-group,
  45. > .input-group {
  46. margin-left: 5px;
  47. }
  48. }
  49. .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
  50. border-radius: 0;
  51. }
  52. // Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
  53. .btn-group > .btn:first-child {
  54. margin-left: 0;
  55. &:not(:last-child):not(.dropdown-toggle) {
  56. .border-right-radius(0);
  57. }
  58. }
  59. // Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
  60. .btn-group > .btn:last-child:not(:first-child),
  61. .btn-group > .dropdown-toggle:not(:first-child) {
  62. .border-left-radius(0);
  63. }
  64. // Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
  65. .btn-group > .btn-group {
  66. float: left;
  67. }
  68. .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
  69. border-radius: 0;
  70. }
  71. .btn-group > .btn-group:first-child {
  72. > .btn:last-child,
  73. > .dropdown-toggle {
  74. .border-right-radius(0);
  75. }
  76. }
  77. .btn-group > .btn-group:last-child > .btn:first-child {
  78. .border-left-radius(0);
  79. }
  80. // On active and open, don't show outline
  81. .btn-group .dropdown-toggle:active,
  82. .btn-group.open .dropdown-toggle {
  83. outline: 0;
  84. }
  85. // Sizing
  86. //
  87. // Remix the default button sizing classes into new ones for easier manipulation.
  88. .btn-group-xs > .btn {
  89. &:extend(.btn-xs);
  90. }
  91. .btn-group-sm > .btn {
  92. &:extend(.btn-sm);
  93. }
  94. .btn-group-lg > .btn {
  95. &:extend(.btn-lg);
  96. }
  97. // Split button dropdowns
  98. // ----------------------
  99. // Give the line between buttons some depth
  100. .btn-group > .btn + .dropdown-toggle {
  101. padding-left: 8px;
  102. padding-right: 8px;
  103. }
  104. .btn-group > .btn-lg + .dropdown-toggle {
  105. padding-left: 12px;
  106. padding-right: 12px;
  107. }
  108. // The clickable button for toggling the menu
  109. // Remove the gradient and set the same inset shadow as the :active state
  110. .btn-group.open .dropdown-toggle {
  111. &.btn-secondary {
  112. background-color: @btn-secondary-hover-bg-color;
  113. }
  114. &.btn-primary {
  115. border-color: @btn-primary-hover-bg-color;
  116. background-color: @btn-primary-hover-bg-color;
  117. }
  118. }
  119. .btn-form-cross {
  120. display: block;
  121. }
  122. // Reposition the caret
  123. .btn .caret {
  124. margin-left: 0;
  125. }
  126. // Carets in other button sizes
  127. .btn-lg .caret {
  128. border-width: @caret-width-large @caret-width-large 0;
  129. border-bottom-width: 0;
  130. }
  131. // Upside down carets for .dropup
  132. .dropup .btn-lg .caret {
  133. border-width: 0 @caret-width-large @caret-width-large;
  134. }
  135. // Vertical button groups
  136. // ----------------------
  137. .btn-group-vertical {
  138. > .btn,
  139. > .btn-group,
  140. > .btn-group > .btn {
  141. display: block;
  142. float: none;
  143. width: 100%;
  144. max-width: 100%;
  145. }
  146. // Clear floats so dropdown menus can be properly placed
  147. > .btn-group {
  148. &:extend(.clearfix all);
  149. > .btn {
  150. float: none;
  151. }
  152. }
  153. > .btn + .btn,
  154. > .btn + .btn-group,
  155. > .btn-group + .btn,
  156. > .btn-group + .btn-group {
  157. margin-top: -1px;
  158. margin-left: 0;
  159. }
  160. }
  161. .btn-group-vertical > .btn {
  162. &:not(:first-child):not(:last-child) {
  163. border-radius: 0;
  164. }
  165. &:first-child:not(:last-child) {
  166. border-top-right-radius: @border-radius-base;
  167. .border-bottom-radius(0);
  168. }
  169. &:last-child:not(:first-child) {
  170. border-bottom-left-radius: @border-radius-base;
  171. .border-top-radius(0);
  172. }
  173. }
  174. .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  175. border-radius: 0;
  176. }
  177. .btn-group-vertical > .btn-group:first-child:not(:last-child) {
  178. > .btn:last-child,
  179. > .dropdown-toggle {
  180. .border-bottom-radius(0);
  181. }
  182. }
  183. .btn-group-vertical
  184. > .btn-group:last-child:not(:first-child)
  185. > .btn:first-child {
  186. .border-top-radius(0);
  187. }
  188. // Justified button groups
  189. // ----------------------
  190. .btn-group-justified {
  191. display: table;
  192. width: 100%;
  193. table-layout: fixed;
  194. border-collapse: separate;
  195. > .btn,
  196. > .btn-group {
  197. float: none;
  198. display: table-cell;
  199. width: 1%;
  200. }
  201. > .btn-group .btn {
  202. width: 100%;
  203. }
  204. }
  205. // Checkbox and radio options
  206. [data-toggle='buttons'] > .btn > input[type='radio'],
  207. [data-toggle='buttons'] > .btn > input[type='checkbox'] {
  208. display: none;
  209. }
  210. // button group as toolbar item
  211. .btn-group.toolbar-item {
  212. display: flex;
  213. flex-wrap: nowrap;
  214. }