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.

250 lines
7.9 KiB

8 months ago
  1. // The dropdown wrapper (`<div>`)
  2. .dropup,
  3. .dropend,
  4. .dropdown,
  5. .dropstart,
  6. .dropup-center,
  7. .dropdown-center {
  8. position: relative;
  9. }
  10. .dropdown-toggle {
  11. white-space: nowrap;
  12. // Generate the caret automatically
  13. @include caret();
  14. }
  15. // The dropdown menu
  16. .dropdown-menu {
  17. // scss-docs-start dropdown-css-vars
  18. --#{$prefix}dropdown-zindex: #{$zindex-dropdown};
  19. --#{$prefix}dropdown-min-width: #{$dropdown-min-width};
  20. --#{$prefix}dropdown-padding-x: #{$dropdown-padding-x};
  21. --#{$prefix}dropdown-padding-y: #{$dropdown-padding-y};
  22. --#{$prefix}dropdown-spacer: #{$dropdown-spacer};
  23. @include rfs($dropdown-font-size, --#{$prefix}dropdown-font-size);
  24. --#{$prefix}dropdown-color: #{$dropdown-color};
  25. --#{$prefix}dropdown-bg: #{$dropdown-bg};
  26. --#{$prefix}dropdown-border-color: #{$dropdown-border-color};
  27. --#{$prefix}dropdown-border-radius: #{$dropdown-border-radius};
  28. --#{$prefix}dropdown-border-width: #{$dropdown-border-width};
  29. --#{$prefix}dropdown-inner-border-radius: #{$dropdown-inner-border-radius};
  30. --#{$prefix}dropdown-divider-bg: #{$dropdown-divider-bg};
  31. --#{$prefix}dropdown-divider-margin-y: #{$dropdown-divider-margin-y};
  32. --#{$prefix}dropdown-box-shadow: #{$dropdown-box-shadow};
  33. --#{$prefix}dropdown-link-color: #{$dropdown-link-color};
  34. --#{$prefix}dropdown-link-hover-color: #{$dropdown-link-hover-color};
  35. --#{$prefix}dropdown-link-hover-bg: #{$dropdown-link-hover-bg};
  36. --#{$prefix}dropdown-link-active-color: #{$dropdown-link-active-color};
  37. --#{$prefix}dropdown-link-active-bg: #{$dropdown-link-active-bg};
  38. --#{$prefix}dropdown-link-disabled-color: #{$dropdown-link-disabled-color};
  39. --#{$prefix}dropdown-item-padding-x: #{$dropdown-item-padding-x};
  40. --#{$prefix}dropdown-item-padding-y: #{$dropdown-item-padding-y};
  41. --#{$prefix}dropdown-header-color: #{$dropdown-header-color};
  42. --#{$prefix}dropdown-header-padding-x: #{$dropdown-header-padding-x};
  43. --#{$prefix}dropdown-header-padding-y: #{$dropdown-header-padding-y};
  44. // scss-docs-end dropdown-css-vars
  45. position: absolute;
  46. z-index: var(--#{$prefix}dropdown-zindex);
  47. display: none; // none by default, but block on "open" of the menu
  48. min-width: var(--#{$prefix}dropdown-min-width);
  49. padding: var(--#{$prefix}dropdown-padding-y) var(--#{$prefix}dropdown-padding-x);
  50. margin: 0; // Override default margin of ul
  51. @include font-size(var(--#{$prefix}dropdown-font-size));
  52. color: var(--#{$prefix}dropdown-color);
  53. text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  54. list-style: none;
  55. background-color: var(--#{$prefix}dropdown-bg);
  56. background-clip: padding-box;
  57. border: var(--#{$prefix}dropdown-border-width) solid var(--#{$prefix}dropdown-border-color);
  58. @include border-radius(var(--#{$prefix}dropdown-border-radius));
  59. @include box-shadow(var(--#{$prefix}dropdown-box-shadow));
  60. &[data-bs-popper] {
  61. top: 100%;
  62. left: 0;
  63. margin-top: var(--#{$prefix}dropdown-spacer);
  64. }
  65. @if $dropdown-padding-y == 0 {
  66. > .dropdown-item:first-child,
  67. > li:first-child .dropdown-item {
  68. @include border-top-radius(var(--#{$prefix}dropdown-inner-border-radius));
  69. }
  70. > .dropdown-item:last-child,
  71. > li:last-child .dropdown-item {
  72. @include border-bottom-radius(var(--#{$prefix}dropdown-inner-border-radius));
  73. }
  74. }
  75. }
  76. // scss-docs-start responsive-breakpoints
  77. // We deliberately hardcode the `bs-` prefix because we check
  78. // this custom property in JS to determine Popper's positioning
  79. @each $breakpoint in map-keys($grid-breakpoints) {
  80. @include media-breakpoint-up($breakpoint) {
  81. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  82. .dropdown-menu#{$infix}-start {
  83. --bs-position: start;
  84. &[data-bs-popper] {
  85. right: auto;
  86. left: 0;
  87. }
  88. }
  89. .dropdown-menu#{$infix}-end {
  90. --bs-position: end;
  91. &[data-bs-popper] {
  92. right: 0;
  93. left: auto;
  94. }
  95. }
  96. }
  97. }
  98. // scss-docs-end responsive-breakpoints
  99. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  100. // Just add .dropup after the standard .dropdown class and you're set.
  101. .dropup {
  102. .dropdown-menu[data-bs-popper] {
  103. top: auto;
  104. bottom: 100%;
  105. margin-top: 0;
  106. margin-bottom: var(--#{$prefix}dropdown-spacer);
  107. }
  108. .dropdown-toggle {
  109. @include caret(up);
  110. }
  111. }
  112. .dropend {
  113. .dropdown-menu[data-bs-popper] {
  114. top: 0;
  115. right: auto;
  116. left: 100%;
  117. margin-top: 0;
  118. margin-left: var(--#{$prefix}dropdown-spacer);
  119. }
  120. .dropdown-toggle {
  121. @include caret(end);
  122. &::after {
  123. vertical-align: 0;
  124. }
  125. }
  126. }
  127. .dropstart {
  128. .dropdown-menu[data-bs-popper] {
  129. top: 0;
  130. right: 100%;
  131. left: auto;
  132. margin-top: 0;
  133. margin-right: var(--#{$prefix}dropdown-spacer);
  134. }
  135. .dropdown-toggle {
  136. @include caret(start);
  137. &::before {
  138. vertical-align: 0;
  139. }
  140. }
  141. }
  142. // Dividers (basically an `<hr>`) within the dropdown
  143. .dropdown-divider {
  144. height: 0;
  145. margin: var(--#{$prefix}dropdown-divider-margin-y) 0;
  146. overflow: hidden;
  147. border-top: 1px solid var(--#{$prefix}dropdown-divider-bg);
  148. opacity: 1; // Revisit in v6 to de-dupe styles that conflict with <hr> element
  149. }
  150. // Links, buttons, and more within the dropdown menu
  151. //
  152. // `<button>`-specific styles are denoted with `// For <button>s`
  153. .dropdown-item {
  154. display: block;
  155. width: 100%; // For `<button>`s
  156. padding: var(--#{$prefix}dropdown-item-padding-y) var(--#{$prefix}dropdown-item-padding-x);
  157. clear: both;
  158. font-weight: $font-weight-normal;
  159. color: var(--#{$prefix}dropdown-link-color);
  160. text-align: inherit; // For `<button>`s
  161. text-decoration: if($link-decoration == none, null, none);
  162. white-space: nowrap; // prevent links from randomly breaking onto new lines
  163. background-color: transparent; // For `<button>`s
  164. border: 0; // For `<button>`s
  165. @include border-radius(var(--#{$prefix}dropdown-item-border-radius, 0));
  166. &:hover,
  167. &:focus {
  168. color: var(--#{$prefix}dropdown-link-hover-color);
  169. text-decoration: if($link-hover-decoration == underline, none, null);
  170. @include gradient-bg(var(--#{$prefix}dropdown-link-hover-bg));
  171. }
  172. &.active,
  173. &:active {
  174. color: var(--#{$prefix}dropdown-link-active-color);
  175. text-decoration: none;
  176. @include gradient-bg(var(--#{$prefix}dropdown-link-active-bg));
  177. }
  178. &.disabled,
  179. &:disabled {
  180. color: var(--#{$prefix}dropdown-link-disabled-color);
  181. pointer-events: none;
  182. background-color: transparent;
  183. // Remove CSS gradients if they're enabled
  184. background-image: if($enable-gradients, none, null);
  185. }
  186. }
  187. .dropdown-menu.show {
  188. display: block;
  189. }
  190. // Dropdown section headers
  191. .dropdown-header {
  192. display: block;
  193. padding: var(--#{$prefix}dropdown-header-padding-y) var(--#{$prefix}dropdown-header-padding-x);
  194. margin-bottom: 0; // for use with heading elements
  195. @include font-size($font-size-sm);
  196. color: var(--#{$prefix}dropdown-header-color);
  197. white-space: nowrap; // as with > li > a
  198. }
  199. // Dropdown text
  200. .dropdown-item-text {
  201. display: block;
  202. padding: var(--#{$prefix}dropdown-item-padding-y) var(--#{$prefix}dropdown-item-padding-x);
  203. color: var(--#{$prefix}dropdown-link-color);
  204. }
  205. // Dark dropdowns
  206. .dropdown-menu-dark {
  207. // scss-docs-start dropdown-dark-css-vars
  208. --#{$prefix}dropdown-color: #{$dropdown-dark-color};
  209. --#{$prefix}dropdown-bg: #{$dropdown-dark-bg};
  210. --#{$prefix}dropdown-border-color: #{$dropdown-dark-border-color};
  211. --#{$prefix}dropdown-box-shadow: #{$dropdown-dark-box-shadow};
  212. --#{$prefix}dropdown-link-color: #{$dropdown-dark-link-color};
  213. --#{$prefix}dropdown-link-hover-color: #{$dropdown-dark-link-hover-color};
  214. --#{$prefix}dropdown-divider-bg: #{$dropdown-dark-divider-bg};
  215. --#{$prefix}dropdown-link-hover-bg: #{$dropdown-dark-link-hover-bg};
  216. --#{$prefix}dropdown-link-active-color: #{$dropdown-dark-link-active-color};
  217. --#{$prefix}dropdown-link-active-bg: #{$dropdown-dark-link-active-bg};
  218. --#{$prefix}dropdown-link-disabled-color: #{$dropdown-dark-link-disabled-color};
  219. --#{$prefix}dropdown-header-color: #{$dropdown-dark-header-color};
  220. // scss-docs-end dropdown-dark-css-vars
  221. }