Dropdowns

Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin.

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.


<div class="dropdown">
	<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropdown button
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>

Customizing dropdowns

Split button

Create a button that acts as a single action as well as a dropdown menu by splitting off the dropdown menu button into a seperate button, grouped in a .btn-group and with an additional .dropdown-toggle-split class.


<div class="btn-group">
	<button type="button" class="btn btn-danger">Action</button>
	<button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		<span class="sr-only">Toggle Dropdown</span>
	</button>
	<div class="dropdown-menu">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
		<div class="dropdown-divider"></div>
		<a class="dropdown-item" href="#">Separated link</a>
	</div>
</div>

Sizing

Button dropdowns work with buttons of all sizes, including default and split dropdown buttons. Use the .btn-sm and .btn-lg, just like with regular buttons.


<div class="dropdown">
	<button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Small dropdown button
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>
<div class="dropdown mt-1">
	<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Normal dropdown button
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>
<div class="dropdown mt-1">
	<button class="btn btn-lg btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Large dropdown button
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>

Directions

Place the menu to the left, above or to the right of the button by adding .dropleft, .dropup and .dropright respectively to the parent element.


<!-- Dropleft button -->
<div class="btn-group dropleft">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropleft
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>

<!-- Dropup button -->
<div class="btn-group dropup">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropup
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>

<!-- Dropright button -->
<div class="btn-group dropright">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropright
	</button>
	<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<a class="dropdown-item" href="#">Something else here</a>
	</div>
</div>

Alignment

By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add .dropdown-menu-right to a .dropdown-menu to right align the dropdown menu.


<!-- Default left-aligned menu -->
<div class="dropdown">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Default left-aligned menu
	</button>
	<div class="dropdown-menu">
		<button class="dropdown-item" type="button">Action</button>
		<button class="dropdown-item" type="button">Another action</button>
		<button class="dropdown-item" type="button">Something else here</button>
	</div>
</div>

<!-- Right-aligned menu -->
<div class="dropdown mt-1">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Right-aligned menu
	</button>
	<div class="dropdown-menu dropdown-menu-right">
		<button class="dropdown-item" type="button">Action</button>
		<button class="dropdown-item" type="button">Another action</button>
		<button class="dropdown-item" type="button">Something else here</button>
	</div>
</div>

Add a header to label sections of items in any dropdown menu by adding a <h*> with .dropdown-header. Create dividers by adding a <div> element with .dropdown-divider. Place text using regular <p> elements and position them using spacing utilities. You can even add forms to a dropdown menu, again using spacing utilities to keep it separated from the borders of the dropdown.


<!-- Dropdown with some content-->
<div class="dropdown">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropdown with some content
	</button>
	<div class="dropdown-menu" style="max-width:200px;">
		<h6 class="dropdown-header">Dropdown header</h6>
		<div class="dropdown-divider"></div>
		<a class="dropdown-item" href="#">Action</a>
		<a class="dropdown-item" href="#">Another action</a>
		<div class="dropdown-divider"></div>
		<p class="text-muted px-3">
			I'm text in a dropdown menu!
		</p>
	</div>
</div>

<!-- Dropdown with form-->
<div class="dropdown mt-1">
	<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
		Dropdown with form
	</button>
	<div class="dropdown-menu">
		<form class="px-4 py-3">
			<div class="form-group">
				<label for="exampleDropdownFormEmail1">Email address</label>
				<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
			</div>
			<div class="form-group">
				<label for="exampleDropdownFormPassword1">Password</label>
				<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
			</div>
			<div class="form-check">
				<input type="checkbox" class="form-check-input" id="dropdownCheck">
				<label class="form-check-label" for="dropdownCheck">
					Remember me
				</label>
			</div>
			<button type="submit" class="btn btn-primary">Sign in</button>
		</form>
		<div class="dropdown-divider"></div>
		<a class="dropdown-item" href="#">New around here? Sign up</a>
		<a class="dropdown-item" href="#">Forgot password?</a>
	</div>
</div>


JavaScript behavior

Call the dropdowns via JavaScript:


$('.dropdown-toggle').dropdown();

Data-toggle still required

Regardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown" is always required to be present on the dropdown’s trigger element.

Options

Name Type Default Description
offset number, string, function 0 Offset of the dropdown relative to its target. For more information refer to Popper.js’s offset docs.
flip boolean true Allow Dropdown to flip in case of an overlapping on the reference element. For more information refer to Popper.js’s flip docs.
boundary string, element ‘scrollParent’ Overflow constraint boundary of the dropdown menu. Accepts the values of ‘viewport’, ‘window’, ‘scrollParent’, or an HTMLElement reference (JavaScript only). For more information refer to Popper.js’s preventOverflow docs.
reference string, element ‘toggle’ Reference element of the dropdown menu. Accepts the values of ‘toggle’, ‘parent’, or an HTMLElement reference. For more information refer to Popper.js’s referenceObject docs.
display string ‘dynamic’ By default, we use Popper.js for dynamic positioning. Disable this with static.

Methods

Method Description
$().dropdown('toggle') Toggles the dropdown menu of a given navbar or tabbed navigation.
$().dropdown('update') Updates the position of an element’s dropdown.
$().dropdown('dispose') Destroys and element’s dropdown.

Events

All dropdown events are fired at the .dropdown-menu's parent elements and have a relatedTarget property, whose value is the toggling anchor element.
hide.bs.dropdown and hidden.bs.dropdown events have a clickEvent property (only when the original event type is click) that contains an Event Objet for the click event.

Event Description
show.bs.dropdown This event fires immediately when the show instance method is called.
shown.bs.dropdown This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete).
hide.bs.dropdown This event is fired immediately when the hide instance method has been called.
hidden.bs.dropdown This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete).

$('#myDropdown').on('show.bs.dropdown', function () {
  // Do something…
});