Dropdown
Single button
Any single .btn
can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with either <button>
elements:
Split button
Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of .dropdown-toggle-split
for proper spacing around the dropdown caret.
We use this extra class to reduce the horizontal padding
on either side of the caret by 25% and remove the margin-left
that’s added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button.
Sizing
Button dropdowns work with buttons of all sizes, including default and split dropdown buttons.
Dropup
Trigger dropdown menus above elements by adding .dropup
to the parent element.
Dropright
Trigger dropdown menus at the right of the elements by adding .dropend
to the parent element.
Dropleft
Trigger dropdown menus at the left of the elements by adding .dropstart
to the parent element.
Menu items
Historically dropdown menu contents had to be links, but that’s no longer the case with v4. Now you can optionally use <button>
elements in your dropdowns instead of just <a>
s.
You can also create non-interactive dropdown items with .dropdown-item-text
. Feel free to style further with custom CSS or text utilities.
Active
Add .active
to items in the dropdown to style them as active. To convey the active state to assistive technologies, use the aria-current
attribute — using the page
value for the current page, or true
for the current item in a set.
Disabled
Add .disabled
to items in the dropdown to style them as disabled.
Menu alignment
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. You can change this with the directional .drop*
classes, but you can also control them with additional modifier classes.
Add .dropdown-menu-end
to a .dropdown-menu
to right align the dropdown menu. Directions are mirrored when using Bootstrap in RTL, meaning .dropdown-menu-end
will appear on the left side.
Responsive alignment
If you want to use responsive alignment, disable dynamic positioning by adding the data-bs-display="static"
attribute and use the responsive variation classes.
To align right the dropdown menu with the given breakpoint or larger, add .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-end
.
To align left the dropdown menu with the given breakpoint or larger, add .dropdown-menu-end
and .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-start
.
Alignment options
Taking most of the options shown above, here’s a small kitchen sink demo of various dropdown alignment options in one place.
Menu content header
Add a header to label sections of actions in any dropdown menu.
Dividers
Separate groups of related menu items with a divider.
Dropdown options
Use data-bs-offset
or data-bs-reference
to change the location of the dropdown.