You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.1 KiB

3 months ago
  1. // Make the div behave like a button
  2. .btn-group,
  3. .btn-group-vertical {
  4. position: relative;
  5. display: inline-flex;
  6. vertical-align: middle; // match .btn alignment given font-size hack above
  7. > .btn {
  8. position: relative;
  9. flex: 1 1 auto;
  10. }
  11. // Bring the hover, focused, and "active" buttons to the front to overlay
  12. // the borders properly
  13. > .btn-check:checked + .btn,
  14. > .btn-check:focus + .btn,
  15. > .btn:hover,
  16. > .btn:focus,
  17. > .btn:active,
  18. > .btn.active {
  19. z-index: 1;
  20. }
  21. }
  22. // Optional: Group multiple button groups together for a toolbar
  23. .btn-toolbar {
  24. display: flex;
  25. flex-wrap: wrap;
  26. justify-content: flex-start;
  27. .input-group {
  28. width: auto;
  29. }
  30. }
  31. .btn-group {
  32. @include border-radius($btn-border-radius);
  33. // Prevent double borders when buttons are next to each other
  34. > :not(.btn-check:first-child) + .btn,
  35. > .btn-group:not(:first-child) {
  36. margin-left: calc(#{$btn-border-width} * -1); // stylelint-disable-line function-disallowed-list
  37. }
  38. // Reset rounded corners
  39. > .btn:not(:last-child):not(.dropdown-toggle),
  40. > .btn.dropdown-toggle-split:first-child,
  41. > .btn-group:not(:last-child) > .btn {
  42. @include border-end-radius(0);
  43. }
  44. // The left radius should be 0 if the button is:
  45. // - the "third or more" child
  46. // - the second child and the previous element isn't `.btn-check` (making it the first child visually)
  47. // - part of a btn-group which isn't the first child
  48. > .btn:nth-child(n + 3),
  49. > :not(.btn-check) + .btn,
  50. > .btn-group:not(:first-child) > .btn {
  51. @include border-start-radius(0);
  52. }
  53. }
  54. // Sizing
  55. //
  56. // Remix the default button sizing classes into new ones for easier manipulation.
  57. .btn-group-sm > .btn { @extend .btn-sm; }
  58. .btn-group-lg > .btn { @extend .btn-lg; }
  59. //
  60. // Split button dropdowns
  61. //
  62. .dropdown-toggle-split {
  63. padding-right: $btn-padding-x * .75;
  64. padding-left: $btn-padding-x * .75;
  65. &::after,
  66. .dropup &::after,
  67. .dropend &::after {
  68. margin-left: 0;
  69. }
  70. .dropstart &::before {
  71. margin-right: 0;
  72. }
  73. }
  74. .btn-sm + .dropdown-toggle-split {
  75. padding-right: $btn-padding-x-sm * .75;
  76. padding-left: $btn-padding-x-sm * .75;
  77. }
  78. .btn-lg + .dropdown-toggle-split {
  79. padding-right: $btn-padding-x-lg * .75;
  80. padding-left: $btn-padding-x-lg * .75;
  81. }
  82. // The clickable button for toggling the menu
  83. // Set the same inset shadow as the :active state
  84. .btn-group.show .dropdown-toggle {
  85. @include box-shadow($btn-active-box-shadow);
  86. // Show no shadow for `.btn-link` since it has no other button styles.
  87. &.btn-link {
  88. @include box-shadow(none);
  89. }
  90. }
  91. //
  92. // Vertical button groups
  93. //
  94. .btn-group-vertical {
  95. flex-direction: column;
  96. align-items: flex-start;
  97. justify-content: center;
  98. > .btn,
  99. > .btn-group {
  100. width: 100%;
  101. }
  102. > .btn:not(:first-child),
  103. > .btn-group:not(:first-child) {
  104. margin-top: calc(#{$btn-border-width} * -1); // stylelint-disable-line function-disallowed-list
  105. }
  106. // Reset rounded corners
  107. > .btn:not(:last-child):not(.dropdown-toggle),
  108. > .btn-group:not(:last-child) > .btn {
  109. @include border-bottom-radius(0);
  110. }
  111. > .btn ~ .btn,
  112. > .btn-group:not(:first-child) > .btn {
  113. @include border-top-radius(0);
  114. }
  115. }