Performance: Dropdown directions (up, left, right)
This affects how dropdown menus render and how quickly they appear on user interaction.
<div class="dropup"> <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button> <ul class="dropdown-menu">...</ul> </div>
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button> <ul class="dropdown-menu" style="top: auto; bottom: 100%; left: auto; right: auto;">...</ul>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles for dropdown direction | Minimal | Multiple on toggle | High due to forced repaint | [X] Bad |
| Bootstrap directional classes (dropup, dropdown-menu-end) | Minimal | Single on initial render | Low, GPU accelerated | [OK] Good |
dropup for up, dropstart for left, and dropend for right.dropup is used to make the dropdown open upwards.dropstart to make dropdowns open to the left side.dropdown and dropstart classes. The button triggers the dropdown with data-bs-toggle="dropdown" and the menu is inside ul.dropdown-menu.<div class="dropdown dropend">
<button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Right Menu
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Item 1</a></li>
</ul>
</div>dropend makes the dropdown menu open to the right side of the button.dropdown dropend classes, so the menu will appear on the right side when triggered.dropup to change dropdown direction upwards.dropup to the dropdown container changes the menu to open upwards. Other options either break functionality or are invalid.dropstart control dropdown direction but are not responsive by default.dropstart for large screens and removing or overriding it on small screens with media queries allows the dropdown to open left on large and default down on small screens.Pass the test and this pattern moves unknown