button-groups.less 5.2 KB

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