'
+ ].join('')
+
+ const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
+ const dropdown = new Dropdown(btnDropdown)
+
+ expect(dropdown._getOffset()).toEqual([10, 20])
+ })
+
it('should allow to pass config to Popper with `popperConfig`', () => {
fixtureEl.innerHTML = [
'
',
diff --git a/scss/_dropdown.scss b/scss/_dropdown.scss
index 594c06399..6941c9e8d 100644
--- a/scss/_dropdown.scss
+++ b/scss/_dropdown.scss
@@ -22,7 +22,7 @@
display: none; // none by default, but block on "open" of the menu
min-width: $dropdown-min-width;
padding: $dropdown-padding-y $dropdown-padding-x;
- margin: $dropdown-spacer 0 0; // override default ul
+ margin: 0; // Let Popper handle the space by offset
@include font-size($dropdown-font-size);
color: $dropdown-color;
text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
@@ -174,6 +174,11 @@
.dropdown-menu.show {
display: block;
+
+ &:not([data-popper-placement]) {
+ margin: $dropdown-spacer 0 0; // override default ul for dropdown not using Popper
+ }
+
}
// Dropdown section headers
diff --git a/site/content/docs/5.0/components/dropdowns.md b/site/content/docs/5.0/components/dropdowns.md
index 50dcde2ba..0aee28b32 100644
--- a/site/content/docs/5.0/components/dropdowns.md
+++ b/site/content/docs/5.0/components/dropdowns.md
@@ -896,6 +896,16 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
'dynamic'
By default, we use Popper for dynamic positioning. Disable this with static.
+
+
offset
+
array | string | function
+
[0, 0]
+
+
Offset of the dropdown relative to its target.
+
When a function is used to determine the offset, it is called with an object containing the popper instance, the refecence Element and the placement as its first argument. The function must return an array with two numbers: [skidding, distance]. The triggering element DOM node is passed as the second argument.
+
For more information refer to Popper.js's offset docs.