DropDown Menu

View in Lexicon

A dropdown menu displays a list of options for the element that triggers it.

installyarn add @clayui/drop-down
versionNPM Version
useimport DropDown from '@clayui/drop-down';
This page uses Bootstrap’s dropdown plugin which requires JQuery. Liferay 7.4 no longer includes JQuery by default. We have included a standalone dropdown plugin in 7.4, just replace the attribute data-toggle=“dropdown” with data-toggle=“liferay-dropdown” on the dropdown-toggle.

Variations

Default

The default dropdown is a panel that does not support scrolling of the content inside it. Use this type when the number of options you want to offer is short or the panel is big enough to contain all the elements you want to use.

Snippet

Wide

Use .dropdown-wide with .dropdown to make the dropdown menu big. The default width is 500px.

Snippet

Full

Use .dropdown-full to create a dropdown menu as wide as its relative parent.

Snippet

This is a separate component from .dropdown-full, use one or the other.

The modifier class dropdown-menu-width-full on dropdown-menu makes the menu expand the full width of the page. This should be used with the Clay Drop Down plugin which renders the dropdown-menu as a direct child of the body element.

Snippet

This is a separate component from .dropdown-wide, use one or the other.

The modifier class dropdown-menu-width-sm on dropdown-menu makes the menu 500px wide. The dropdown-menu becomes 100% wide at screen sizes 767px and below. This should be used with the Clay Drop Down plugin which renders the dropdown-menu as a direct child of the body element.

Snippet

The modifier class dropdown-menu-width-shrink on dropdown-menu makes the menu only be as wide as the text inside and maxes out at 240px wide. This forces dropdown-item text to be on one line.

Snippet

The modifier class dropdown-menu-height-auto on dropdown-menu removes the max-height on the dropdown-menu.

Snippet

Content Types

Dividers

Snippet

Form Elements

Checkbox or Radio

Snippet

Snippet

Form Groups

Snippet

Indicators

Start

Snippet

End

Snippet

Start and End

Snippet

Autofit

Make content expand to fill remaining space in a dropdown-item or create equally spaced content with a nested .autofit-row, .autofit-col, .autofit-col-shrink, and .autofit-col-expand.

Snippet

Keyboard Shortcuts

Snippet

Scrolling Content

Nest <div className="inline-scroller"></div> inside a .dropdown-menu list item to create a scrollable dropdown. The maximum height is 200px on screen sizes 768px and above, on screen sizes 767px and below the overflow is handled by .dropdown-menu.

Snippet

Actions

A monospaced dropdown-toggle for a dropdown containing several actions, add dropdown-action to dropdown.

Anchors

Snippet

Buttons

Snippet

Alignment

Corners

Align a dropdown menu on the top or bottom side with classes dropdown-menu, dropdown-menu-right, dropdown-menu-top, or dropdown-menu-top-right.

Snippet

Sides

Add the dropdown-menu-right-side, dropdown-menu-left-side, dropdown-menu-right-side-bottom, or dropdown-menu-left-side-bottom class to a dropdown menu to align it with the right side, left side, bottom-right side, or bottom-left side of the dropdown menu trigger, respectively:

Snippet

Middle

You can also center the dropdown menu to its trigger with these four helper classes: dropdown-menu-center, dropdown-menu-top-center, dropdown-menu-left-side-middle, or dropdown-menu-right-side-middle.

Snippet

Center

To center the dropdown menu in browsers that don’t support CSS transforms, set a negative margin-left equal to the width of the dropdown-menu divided by two. To vertically align left-side and right-side dropdown-menus, set a negative margin-top equal to the height of the dropdown-menu divided by two.

Snippet

Edit this page on GitHub

Contributors

Matuzalém Teles

Last edited May 12, 2025 at 7:56:02 PM