Bootstrap Dropdowns
More options, less clutter. Learn how to build interactive dropdown menus with Bootstrap, organize menu actions, and control where menus appear.
<button class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"> Explore </button>
Sign Out
What Is a Bootstrap Dropdown?
A dropdown is a small menu that opens when someone activates a button or link. Dropdowns help organize related options without taking up too much space.
You might see them in account menus, website navigation, settings panels, or action menus. Bootstrap gives you ready-made dropdown styling and JavaScript behavior.
Build Your First Dropdown
A basic Bootstrap dropdown needs three main pieces: a dropdown wrapper, a toggle button, and a menu containing clickable items.
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
My Menu
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#profile">
Profile
</a></li>
<li><a class="dropdown-item" href="#settings">
Settings
</a></li>
</ul>
</div>
dropdown
Provides the container for the dropdown component.
dropdown-toggle
Adds the familiar arrow indicator to the toggle.
data-bs-toggle="dropdown"
Connects the toggle to Bootstrap’s dropdown JavaScript.
dropdown-menu
Styles the menu that appears when the toggle opens.
Each dropdown-item styles an option inside
the menu. Use links for navigation and buttons for
actions that don’t navigate to another page.
Add Headers and Dividers
Larger menus can be easier to understand when related items are grouped together. Bootstrap includes headers and dividers for organizing the menu.
<ul class="dropdown-menu">
<li>
<h6 class="dropdown-header">Account</h6>
</li>
<li>
<a class="dropdown-item" href="#profile">Profile</a>
</li>
<li>
<a class="dropdown-item" href="#settings">Settings</a>
</li>
<li><hr class="dropdown-divider"></li>
<li>
<button class="dropdown-item" type="button">
Sign Out
</button>
</li>
</ul>
Customize Your Dropdown Button
The dropdown toggle is still a Bootstrap button,
so everything you learned in Lesson 01 applies here.
Change the button color using classes like
btn-success, btn-dark,
or btn-outline-primary.
<button
class="btn btn-success dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
Choose an Option
</button>
You can also use btn-sm or
btn-lg to change the toggle’s size.
The menu itself continues to use
dropdown-menu.
Control Where the Menu Opens
By default, dropdown menus align with the start edge of their toggle. Bootstrap lets you align the menu to the end edge instead.
<ul class="dropdown-menu dropdown-menu-end">
<li>
<a class="dropdown-item" href="#one">Option One</a>
</li>
</ul>
The dropdown-menu-end class is useful
for account menus near the right side of a header,
where a start-aligned menu might extend beyond
the screen.
dropdown-menu-lg-end.
Menu placement can also be adjusted by Popper
when necessary.
Drop Up, Start, or End
Not every menu needs to open downward. Bootstrap provides directional wrapper classes for different layouts.
dropdown
Opens the menu downward by default.
dropup
Opens the menu upward.
dropstart
Opens the menu toward the start side.
dropend
Opens the menu toward the end side.
<div class="dropup">
<button class="btn btn-secondary dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false">
Open Upward
</button>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#option">Option</a>
</li>
</ul>
</div>
For directional dropdowns, make sure there’s enough available space for the menu to appear comfortably.
Disabled Items and Keyboard Access
Sometimes a menu option isn’t available.
Bootstrap includes the disabled
class to style unavailable menu items.
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="#profile">Profile</a>
</li>
<li>
<span class="dropdown-item disabled"
aria-disabled="true">Coming Soon</span>
</li>
</ul>
Bootstrap dropdowns support keyboard interaction. Users can open the menu, move through items using arrow keys, and close it with Escape.
🚀 mC0de Challenge
Build a Project Actions Dropdown
Imagine you’re building a project management dashboard. Instead of displaying several buttons, you want one organized dropdown menu for project actions.
Your mission: Complete all five tasks in the Sandbox below.
Use the checklist to review your work. Load the sample solution when you’re ready to compare.
mC0de Bootstrap Sandbox
Edit your dropdown HTML, run the code, and click the menu to test it.
✓ What You've Learned
- Bootstrap dropdowns organize related links and actions inside expandable menus.
dropdownprovides the basic component wrapper.dropdown-toggleadds the arrow indicator.data-bs-toggle="dropdown"activates the Bootstrap dropdown behavior.dropdown-menuanddropdown-itemstyle the menu and its options.dropdown-headeranddropdown-dividerorganize menu content.dropdown-menu-endaligns the menu with the end edge.dropup,dropstart, anddropendchange the opening direction.- Bootstrap's JavaScript bundle provides dropdown interaction and keyboard support.
Up next: We'll explore Bootstrap Tooltips and learn how to display helpful messages when users hover over or focus on an element.
Nice Work! 🎉
You've learned how to create interactive Bootstrap dropdown menus, organize menu items, and customize alignment and appearance. Ready to record your progress?


