Check-Menus.com

dropdown menu bootstrap

by Marina Kuhlman Published 2 years ago Updated 1 year ago
image

Basic Dropdown

A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:

Dropdown Divider

The .divider class is used to separate links inside the dropdown menu with a thin horizontal border:

Dropdown Header

The .dropdown-header class is used to add headers inside the dropdown menu:

Disable and Active items

Highlight a specific dropdown item with the .active class (adds a blue background color).

Dropdown Position

To right-align the dropdown, add the .dropdown-menu-right class to the element with .dropdown-menu:

Dropup

If you want the dropdown menu to expand upwards instead of downwards, change the <div> element with class="dropdown" to "dropup":

Dropdown Accessibility

To help improve accessibility for people using screen readers, you should include the following role and aria-* attributes, when creating a dropdown menu:

What is Bootstrap dropdown?

Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms.

When is the dropdown menu closed?

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.

How does the dropdown plugin work?

Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent .dropdown-menu. The data-bs-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.

How to align left dropdown menu?

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.

What does opening a dropdown do?

On touch-enabled devices, opening a dropdown adds empty mouseover handlers to the immediate children of the <body> element. This admittedly ugly hack is necessary to work around a quirk in iOS' event delegation, which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty mouseover handlers are removed.

How to pass options in JavaScript?

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-bs-, as in data-bs-offset="". Make sure to change the case type of the option name from camelCase to kebab-case when passing the options via data attributes. For example, instead of using data-bs-autoClose="false", use data-bs-auto-close="false".

Does Bootstrap support dropdown menus?

However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual .dropdown-item elements using the cursor keys and close the menu with the ESC key.

What is drop down menu?

A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:

How to open drop down menu in a.dropdown-toggle?

To open the dropdown menu, use a button or a link with a class of .dropdown-toggle and the data-to ggle="dropdown" attribute. Add the .dropdown-menu class to a <div> element to actually build the dropdown menu. Then add the .dropdown-item class to each element (links or buttons) inside the dropdown menu.

What is a dropdown divider?

The .dropdown-divider class is used to separate links inside the dropdown menu with a thin horizontal border:

How to align dropdown menu with breakpoint?

To align right the dropdown menu with the given breakpoint or larger, add .dropdown-menu {-sm|-md|-lg|-xl}-right.

How to align left dropdown menu?

To align left the dropdown menu with the given breakpoint or larger , add .dropdown-menu-right and .dropdown-menu {-sm|-md|-lg|-xl}-left.

How does the dropdown plugin work?

Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent list item. The data-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.

What are ARIA menus?

ARIA menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures.

What is a dropdown in JavaScript?

Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision.

Where are dropdown events fired?

All dropdown events are fired at the .dropdown-menu ’s parent element 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 Object for the click event.

Can you use elements in dropdown menu?

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.

How to align left dropdown menu?

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 .

How to remove fade animation on click?

To remove the fade animation on click, add data-mdb-dropdown-animation="off" attribute to the dropdown button.

Can you use elements in dropdown menu?

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.

How to disable dynamic positioning?

If you want to use responsive alignment, disable dynamic positioning by adding the data-mdb-display="static" attribute and use the responsive variation classes.

Can dropdowns be triggered?

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.

Do you need to add data-mdb-display="static" to dropdown buttons in navbar?

Note that you don’t need to add a data-mdb-display="static" attribute to dropdown buttons in navbars, since Popper isn’t used in navbars.

Can you make a dropdown text?

You can also create non-interactive dropdown items with .dropdown-item-text. Feel free to style further with custom CSS or text utilities.

What is drop down menu?

A dropdown menu is a toggleable menu that allows the user to choose one value from a predefined list:

What does a dropdown class mean?

The .dropdown class indicates a dropdown menu.

What is a dropdown divider?

The .dropdown-divider class is used to separate links inside the dropdown menu with a thin horizontal border:

How to add dropdown to bootstrap?

Add Bootstrap's .dropdown-toggle class and add data-toggle="dropdown" to the trigger element (i.e. the element that users click on to expand the dropdown). In the above example, the trigger is a <button> element.

How to disable menu item in Bootstrap?

Disable a menu item by applying Bootstrap's .disabled class to its <li> tag.

How to add header to dropdown menu?

Add a header to your dropdown menu by adding a applying Bootstrap's .dropdown-header class to a <li> element.

What does a small down triangle mean in Bootstrap?

In the above example we also add a small down triangle (caret) to indicate that it is a dropdown. We add this by using Bootstrap's .caret class applied to a <span> element.

Can you reverse dropdown menu?

You can reverse the dropdown so that it becomes a "dropup" menu:

Can you split dropdown menus?

You can also create split dropdown menus with button groups.

Does Bootstrap reverse carets?

You might have noticed that Bootstrap automatically reverses the caret when using a dropup, indicating to the user that the list will appear above the button.

image

Accessibility

  • The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIAmenus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. Bootstrap’s dropdo…
See more on getbootstrap.com

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.
See more on getbootstrap.com

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.
See more on getbootstrap.com

Menu 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-menuto right align the dropdown menu.
See more on getbootstrap.com

Menu Forms

  • Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilitiesto give it the negative space you require.
See more on getbootstrap.com

Usage

  • Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent list item. The data-toggle="dropdown"attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.
See more on getbootstrap.com

Overview

  • Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision. Dropdowns are built on a third party library, Popper.js, which provides dynamic positioning and v...
See more on getbootstrap.com

Accessibility

  • The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIAmenus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situation…
See more on getbootstrap.com

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.
See more on getbootstrap.com

Directions

  • Dropup
    Trigger dropdown menus above elements by adding .dropupto the parent element.
  • Dropright
    Trigger dropdown menus at the right of the elements by adding .droprightto the parent element.
See more on getbootstrap.com

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.
See more on getbootstrap.com

Menu 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-menuto right align the dropdown menu.
See more on getbootstrap.com

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.
See more on getbootstrap.com

Usage

  • Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent list item. The data-toggle="dropdown"attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.
See more on getbootstrap.com

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9