button-groups.less 5.3 KB

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