Dropdowns reveal a menu of actions or links from a toggle button. Bootstrap 5 uses data-bs-toggle="dropdown" on the trigger and expects the bundle JavaScript—CSS alone cannot open the menu.
Markup essentials
- Wrap toggle + menu in
dropdown(ordropup,dropend) - Menu container:
dropdown-menuwithdropdown-itemlinks or buttons - Toggle:
btn dropdown-togglewithdata-bs-toggle="dropdown"andaria-expanded
Keyboard and split buttons
Menus support arrow keys when focused; dividers use dropdown-divider. Split buttons separate the primary action from the caret toggle—two buttons inside one btn-group.
Compare with fully CSS dropdowns in utility stacks—they often rely on :focus-within and lack the same ARIA behavior unless you add it manually.
Self-check
- Which
data-bs-*attribute opens a dropdown? - Why must the playground load
bootstrap.bundle.min.js? - What class styles individual menu entries?
Challenge
Menu from a button
- Wire
data-bs-toggle="dropdown"on a button. - Click to open; click outside to close.
Done when: dropdown opens and closes with Bootstrap JS.