button-groups.less 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. &:extend(.clearfix all);
  38. .btn-group,
  39. .input-group {
  40. float: left;
  41. }
  42. > .btn,
  43. > .btn-group,
  44. > .input-group {
  45. margin-left: 5px;
  46. }
  47. }
  48. .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
  49. border-radius: 0;
  50. }
  51. // 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
  52. .btn-group > .btn:first-child {
  53. margin-left: 0;
  54. &:not(:last-child):not(.dropdown-toggle) {
  55. .border-right-radius(0);
  56. }
  57. }
  58. // Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
  59. .btn-group > .btn:last-child:not(:first-child),
  60. .btn-group > .dropdown-toggle:not(:first-child) {
  61. .border-left-radius(0);
  62. }
  63. // Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
  64. .btn-group > .btn-group {
  65. float: left;
  66. }
  67. .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
  68. border-radius: 0;
  69. }
  70. .btn-group > .btn-group:first-child {
  71. > .btn:last-child,
  72. > .dropdown-toggle {
  73. .border-right-radius(0);
  74. }
  75. }
  76. .btn-group > .btn-group:last-child > .btn:first-child {
  77. .border-left-radius(0);
  78. }
  79. // On active and open, don't show outline
  80. .btn-group .dropdown-toggle:active,
  81. .btn-group.open .dropdown-toggle {
  82. outline: 0;
  83. }
  84. // Sizing
  85. //
  86. // Remix the default button sizing classes into new ones for easier manipulation.
  87. .btn-group-xs > .btn {
  88. &:extend(.btn-xs);
  89. }
  90. .btn-group-sm > .btn {
  91. &:extend(.btn-sm);
  92. }
  93. .btn-group-lg > .btn {
  94. &:extend(.btn-lg);
  95. }
  96. // Split button dropdowns
  97. // ----------------------
  98. // Give the line between buttons some depth
  99. .btn-group > .btn + .dropdown-toggle {
  100. padding-left: 8px;
  101. padding-right: 8px;
  102. }
  103. .btn-group > .btn-lg + .dropdown-toggle {
  104. padding-left: 12px;
  105. padding-right: 12px;
  106. }
  107. // The clickable button for toggling the menu
  108. // Remove the gradient and set the same inset shadow as the :active state
  109. .btn-group.open .dropdown-toggle {
  110. &.btn-secondary {
  111. background-color: @btn-secondary-hover-bg-color;
  112. }
  113. &.btn-primary {
  114. border-color: @btn-primary-hover-bg-color;
  115. background-color: @btn-primary-hover-bg-color;
  116. }
  117. }
  118. .btn-form-cross {
  119. display: block;
  120. }
  121. // Reposition the caret
  122. .btn .caret {
  123. margin-left: 0;
  124. }
  125. // Carets in other button sizes
  126. .btn-lg .caret {
  127. border-width: @caret-width-large @caret-width-large 0;
  128. border-bottom-width: 0;
  129. }
  130. // Upside down carets for .dropup
  131. .dropup .btn-lg .caret {
  132. border-width: 0 @caret-width-large @caret-width-large;
  133. }
  134. // Vertical button groups
  135. // ----------------------
  136. .btn-group-vertical {
  137. > .btn,
  138. > .btn-group,
  139. > .btn-group > .btn {
  140. display: block;
  141. float: none;
  142. width: 100%;
  143. max-width: 100%;
  144. }
  145. // Clear floats so dropdown menus can be properly placed
  146. > .btn-group {
  147. &:extend(.clearfix all);
  148. > .btn {
  149. float: none;
  150. }
  151. }
  152. > .btn + .btn,
  153. > .btn + .btn-group,
  154. > .btn-group + .btn,
  155. > .btn-group + .btn-group {
  156. margin-top: -1px;
  157. margin-left: 0;
  158. }
  159. }
  160. .btn-group-vertical > .btn {
  161. &:not(:first-child):not(:last-child) {
  162. border-radius: 0;
  163. }
  164. &:first-child:not(:last-child) {
  165. border-top-right-radius: @border-radius-base;
  166. .border-bottom-radius(0);
  167. }
  168. &:last-child:not(:first-child) {
  169. border-bottom-left-radius: @border-radius-base;
  170. .border-top-radius(0);
  171. }
  172. }
  173. .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  174. border-radius: 0;
  175. }
  176. .btn-group-vertical > .btn-group:first-child:not(:last-child) {
  177. > .btn:last-child,
  178. > .dropdown-toggle {
  179. .border-bottom-radius(0);
  180. }
  181. }
  182. .btn-group-vertical
  183. > .btn-group:last-child:not(:first-child)
  184. > .btn:first-child {
  185. .border-top-radius(0);
  186. }
  187. // Justified button groups
  188. // ----------------------
  189. .btn-group-justified {
  190. display: table;
  191. width: 100%;
  192. table-layout: fixed;
  193. border-collapse: separate;
  194. > .btn,
  195. > .btn-group {
  196. float: none;
  197. display: table-cell;
  198. width: 1%;
  199. }
  200. > .btn-group .btn {
  201. width: 100%;
  202. }
  203. }
  204. // Checkbox and radio options
  205. [data-toggle='buttons'] > .btn > input[type='radio'],
  206. [data-toggle='buttons'] > .btn > input[type='checkbox'] {
  207. display: none;
  208. }
  209. // button group as toolbar item
  210. .btn-group.toolbar-item {
  211. display: flex;
  212. flex-wrap: nowrap;
  213. }