Dropdowns
Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin.
Examples
Wrap the dropdown’s toggle (your button or link) and the dropdown menu within .dropdown
, or another element that declares position: relative;
. Dropdowns can be triggered from <a>
or <button>
elements to better fit your potential needs. The examples shown here use semantic <ul>
elements where appropriate, but custom markup is supported.
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:
.collapse
hides content.collapsing
is applied during transitions.collapse.show
shows content
Generally, we recommend using a button with the data-bs-target
attribute. While not recommended from a semantic point of view, you can also use a link with the href
attribute (and a role="button"
). In both cases, the data-bs-toggle="collapse"
is required.
And with <a>
elements:
The best part is you can do this with any button variant, too:
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.
Sizing
Button dropdowns work with buttons of all sizes, including default and split dropdown buttons.
Dark dropdowns
Opt into darker dropdowns to match a dark navbar or custom style by adding .dropdown-menu-dark
onto an existing .dropdown-menu
. No changes are required to the dropdown items.
Directions
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
You can use <a>
or <button>
elements as dropdown items.
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
.
Menu content
Headers
Add a header to label sections of actions in any dropdown menu.
Dividers
Separate groups of related menu items with a divider.
Text
Place any freeform text within a dropdown menu with text and use spacing utilities. Note that you’ll likely need additional sizing styles to constrain the menu width.
Forms
Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilities to give it the negative space you require.
Dropdowns options
Use data-bs-offset
or data-bs-reference
to change the location of the dropdown.
Auto close behavior
By default, the dropdown menu is closed when clicking inside or outside the dropdown menu. You can use the autoClose
option to change this behavior of the dropdown.