Clay Dropdown Menus and Action Menus
You can add dropdown menus to your app via the clay:dropdown-menu
and clay:actions-menu
taglibs. The Clay taglibs provide several menu variations for you to choose. Both taglibs with several examples are shown below.
Dropdown Menus
Basic dropdown menu:
The dropdown menu’s items are defined in its Java class–dropdownDisplayContext
in this case. Menu items are NavigationItem
objects. You can disable menu items with the setDisabled(true)
method and make a menu item active with the setActive(true)
method. The href
attribute is set with the setHref()
method, and labels are defined with the setLabel()
method. Here’s an example implementation of the dropdownDisplayContext
class:
You can organize menu items into groups by setting the NavigationItem
’s type to TYPE_GROUP
and nesting the items in separate ArrayList
s. You can add a horizontal separator to separate the groups visually with the setSeparator(true)
method. Below is a code snippet from the dropdownsDisplayContext
class:
Corresponding taglib:
You can also add inputs to dropdown menus. To add an input to a dropdown menu, set the input’s type with the setType()
method (e.g. NavigationItem.TYPE_CHECKBOX
), its name with the setInputName()
method, and its value with the setInputValue()
method. Here’s an example implementation:
Corresponding taglib:
Menu items can also contain icons. To add an icon to a menu item, use the setIcon()
method. Below is an example:
Corresponding taglib:
Actions Menus
Basic actions menu:
An actions menu can also display help text to the user:
Clay taglibs make it easy to add dropdown menus and action menus to your apps.