mc0de
mC0de / Bootstrap Elements / Lesson 03 of 07

Bootstrap Dropdowns

More options, less clutter. Learn how to build interactive dropdown menus with Bootstrap, organize menu actions, and control where menus appear.

Beginner Friendly Bootstrap 5.3 Interactive Menus Live Sandbox
dropdowns.html
<button class="btn btn-primary dropdown-toggle"
  data-bs-toggle="dropdown">
  Explore
</button>
Explore ▾
Dashboard My Projects Settings
Sign Out
01 / Getting Started

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.

My Account ▾
My Profile Settings
Sign Out
Remember: The example above is a visual illustration. You’ll build a real, clickable dropdown in the Sandbox below.
02 / The Foundation

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.

03 / Menu Organization

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>
Design tip: Group related choices, use short labels, and avoid overwhelming users with too many options in one menu.
04 / Colors and Variants

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.

05 / Menu Alignment

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.

Responsive tip: Bootstrap also supports breakpoint-specific alignment utilities, such as dropdown-menu-lg-end. Menu placement can also be adjusted by Popper when necessary.
06 / Opening Direction

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.

07 / States and Behavior

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.

Important: Bootstrap’s dropdown JavaScript bundle is required for interactive toggling. Styling alone will not make the dropdown open and close.
Your Turn / Practice Time

🚀 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.

Interactive Coding Workspace

mC0de Bootstrap Sandbox

Edit your dropdown HTML, run the code, and click the menu to test it.

HTML Input / dropdowns.html
Live Result / Bootstrap 5.3
Ready to code. Click the dropdown in the preview to test it.
Lesson Recap

✓ What You've Learned

  • Bootstrap dropdowns organize related links and actions inside expandable menus.
  • dropdown provides the basic component wrapper.
  • dropdown-toggle adds the arrow indicator.
  • data-bs-toggle="dropdown" activates the Bootstrap dropdown behavior.
  • dropdown-menu and dropdown-item style the menu and its options.
  • dropdown-header and dropdown-divider organize menu content.
  • dropdown-menu-end aligns the menu with the end edge.
  • dropup, dropstart, and dropend change 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.

Your Learning Journey
Bootstrap Elements Learning Path 0 of 7 completed
Lesson 03 / Dropdowns 0% Complete

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?

Lesson 03 of 07 · Bootstrap Elements