Dropdown menus
Example
Toggleable, contextual menu for displaying lists of links. Made interactive with the dropdown JavaScript plugin.
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu"> <li><a tabindex="-1" href="#">Action</a></li> <li><a tabindex="-1" href="#">Another action</a></li> <li><a tabindex="-1" href="#">Something else here</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Separated link</a></li> </ul>
Markup
Looking at just the dropdown menu, here's the required HTML. You need to wrap the dropdown's trigger and the dropdown menu within .dropdown, or another element that declares position: relative;. Then just create the menu.
<div class="dropdown">
<!-- Link or button to toggle dropdown -->
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><a tabindex="-1" href="#">Action</a></li>
<li><a tabindex="-1" href="#">Another action</a></li>
<li><a tabindex="-1" href="#">Something else here</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
Options
Align menus to the right and add include additional levels of dropdowns.
Aligning the menus
Add .pull-right to a .dropdown-menu to right align the dropdown menu.
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dLabel"> ... </ul>
Disabled menu options
Add .disabled to a <li> in the dropdown to disable the link.
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu"> <li><a tabindex="-1" href="#">Regular link</a></li> <li class="disabled"><a tabindex="-1" href="#">Disabled link</a></li> <li><a tabindex="-1" href="#">Another link</a></li> </ul>
Sub menus on dropdowns
Add an extra level of dropdown menus, appearing on hover like those of OS X, with some simple markup additions. Add .dropdown-submenu to any li in an existing dropdown menu for automatic styling.
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
...
<li class="dropdown-submenu">
<a tabindex="-1" href="#">More options</a>
<ul class="dropdown-menu">
...
</ul>
</li>
</ul>
Button groups
Examples
Two basic options, along with two more specific variations.
Single button group
Wrap a series of buttons with .btn in .btn-group.
<div class="btn-group"> <button class="btn">Left</button> <button class="btn">Middle</button> <button class="btn">Right</button> </div>
Multiple button groups
Combine sets of <div class="btn-group"> into a <div class="btn-toolbar"> for more complex components.
<div class="btn-toolbar">
<div class="btn-group">
...
</div>
</div>
Vertical button groups
Make a set of buttons appear vertically stacked rather than horizontally.
<div class="btn-group btn-group-vertical"> ... </div>
Checkbox and radio flavors
Button groups can also function as radios, where only one button may be active, or checkboxes, where any number of buttons may be active. View the JavaScript docs for that.
Dropdowns in button groups
Heads up! Buttons with dropdowns must be individually wrapped in their own .btn-group within a .btn-toolbar for proper rendering.
Button dropdown menus
Overview and examples
Use any button to trigger a dropdown menu by placing it within a .btn-group and providing the proper menu markup.
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<!-- dropdown menu links -->
</ul>
</div>
Works with all button sizes
Button dropdowns work at any size: .btn-large, .btn-small, or .btn-mini.
Requires JavaScript
Button dropdowns require the Bootstrap dropdown plugin to function.
In some cases—like mobile—dropdown menus will extend outside the viewport. You need to resolve the alignment manually or with custom JavaScript.
Split button dropdowns
Building on the button group styles and markup, we can easily create a split button. Split buttons feature a standard action on the left and a dropdown toggle on the right with contextual links.
<div class="btn-group">
<button class="btn">Action</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!-- dropdown menu links -->
</ul>
</div>
Sizes
Utilize the extra button classes .btn-mini, .btn-small, or .btn-large for sizing.
<div class="btn-group">
<button class="btn btn-mini">Action</button>
<button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!-- dropdown menu links -->
</ul>
</div>
Dropup menus
Dropdown menus can also be toggled from the bottom up by adding a single class to the immediate parent of .dropdown-menu. It will flip the direction of the .caret and reposition the menu itself to move from the bottom up instead of top down.
<div class="btn-group dropup">
<button class="btn">Dropup</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<!-- dropdown menu links -->
</ul>
</div>


