button-groups.less 5.3 KB

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