button-groups.less 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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 when (@is-new-css = false) {
  111. .box-shadow(inset 0 3px 5px rgba(0, 0, 0, 0.125));
  112. // Show no shadow for `.btn-link` since it has no other button styles.
  113. &.btn-link {
  114. .box-shadow(none);
  115. }
  116. }
  117. .btn-group.open .dropdown-toggle when (@is-new-css = true) {
  118. &.btn-secondary {
  119. background-color: @btn-secondary-hover-bg-color;
  120. }
  121. &.btn-primary {
  122. border-color: @btn-primary-hover-bg-color;
  123. background-color: @btn-primary-hover-bg-color;
  124. }
  125. }
  126. .btn-form-cross {
  127. display: block;
  128. }
  129. // Reposition the caret
  130. .btn .caret {
  131. margin-left: 0;
  132. }
  133. // Carets in other button sizes
  134. .btn-lg .caret {
  135. border-width: @caret-width-large @caret-width-large 0;
  136. border-bottom-width: 0;
  137. }
  138. // Upside down carets for .dropup
  139. .dropup .btn-lg .caret {
  140. border-width: 0 @caret-width-large @caret-width-large;
  141. }
  142. // Vertical button groups
  143. // ----------------------
  144. .btn-group-vertical {
  145. > .btn,
  146. > .btn-group,
  147. > .btn-group > .btn {
  148. display: block;
  149. float: none;
  150. width: 100%;
  151. max-width: 100%;
  152. }
  153. // Clear floats so dropdown menus can be properly placed
  154. > .btn-group {
  155. &:extend(.clearfix all);
  156. > .btn {
  157. float: none;
  158. }
  159. }
  160. > .btn + .btn,
  161. > .btn + .btn-group,
  162. > .btn-group + .btn,
  163. > .btn-group + .btn-group {
  164. margin-top: -1px;
  165. margin-left: 0;
  166. }
  167. }
  168. .btn-group-vertical > .btn {
  169. &:not(:first-child):not(:last-child) {
  170. border-radius: 0;
  171. }
  172. &:first-child:not(:last-child) {
  173. border-top-right-radius: @border-radius-base;
  174. .border-bottom-radius(0);
  175. }
  176. &:last-child:not(:first-child) {
  177. border-bottom-left-radius: @border-radius-base;
  178. .border-top-radius(0);
  179. }
  180. }
  181. .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  182. border-radius: 0;
  183. }
  184. .btn-group-vertical > .btn-group:first-child:not(:last-child) {
  185. > .btn:last-child,
  186. > .dropdown-toggle {
  187. .border-bottom-radius(0);
  188. }
  189. }
  190. .btn-group-vertical
  191. > .btn-group:last-child:not(:first-child)
  192. > .btn:first-child {
  193. .border-top-radius(0);
  194. }
  195. // Justified button groups
  196. // ----------------------
  197. .btn-group-justified {
  198. display: table;
  199. width: 100%;
  200. table-layout: fixed;
  201. border-collapse: separate;
  202. > .btn,
  203. > .btn-group {
  204. float: none;
  205. display: table-cell;
  206. width: 1%;
  207. }
  208. > .btn-group .btn {
  209. width: 100%;
  210. }
  211. }
  212. // Checkbox and radio options
  213. [data-toggle='buttons'] > .btn > input[type='radio'],
  214. [data-toggle='buttons'] > .btn > input[type='checkbox'] {
  215. display: none;
  216. }
  217. // button group as toolbar item
  218. .btn-group.toolbar-item {
  219. display: flex;
  220. flex-wrap: nowrap;
  221. }
  222. // allow hiding toolbar content at various breakpoints
  223. .toolbar-large .toolbar-hide-large {
  224. display: none !important;
  225. }
  226. .toolbar-medium .toolbar-hide-medium {
  227. display: none !important;
  228. }
  229. .toolbar-small .toolbar-hide-small {
  230. display: none !important;
  231. }