Design
Dropdowns are used to declutter the interface, by holding contextually relevant but lesser-used actions or content. They are often used in the revealing content pattern.
Code
Example | Comment | Code |
---|---|---|
The recommended Dropdown trigger is a button. To link a button to its Dropown, add the data-ace-dropdown-trigger attribute with the ID of the Dropdown. No further code is required as the Javascript will initialise automatically.
|
|
|
Icon-only buttons can be used as Dropdown triggers. The menu icon is often used in this configuration. |
|
|
|
The Dropdown iteself is composed of the dropdown, optional content groups and dropdown menu(s). In its hidden state, the Dropdown should be rendered in the |
|
|
Right aligned annotations can be added to menu items. These should be very short (1-2 words) to add additional context. They should not contain text that is needed to make a selection. |
Track ACECLASSIC-44 for progress adding dropdown annotations to templates. |
|
To set an item's state to active, add the class ace-dropdown-menu-action-active. |
|
|
Dropdown content groups can have a heading. Add an H3 with the class |
|
|
Dropdown with disabled menu item. Note that disabled items should use a SPAN element, although A is supported in most cases it does not produce the desired result. |
|
Dropdowns can be used with content other than menus. Use a Dropdown Panel to ensure your content matches the width of menus; or leave it out for completely bespoke use cases. When a Button Group is placed after a Dropdown Panel, it will be right-aligned. For a self-closing Dropdown, use the 'trigger inside Dropdown' syntax documented below. |
|
|
|
Dropdowns can include top-label forms, inside a dropdown panel. Other form types are too wide and don't fit. All normal form functionality is possible, although be careful not to put too much into a Dropdown when a Dialog or full page view would be more appropriate. |
This feature was added to ACE after ACE Classic Templates went into maintenance mode (bugfixes only). By default new ACE features are not supported in Classic, but can be contributed if a specific need is identified. |
|
Single Dropdown with multiple triggers and dynamic content. |
By listening to the 'dropdown-open' event on the dropdown, you can change the content of the dropdown dynamically. The event object will have a 'relatedTarget' property which is the element that triggered the dropdown opening. Remember to keep in mind that a dropdown can be opened programmically, in which case it will use the last trigger that opened it as the relatedTarget, or null if it hasn't been opened before.
|
|
Most of the time the Dropdown goes in |
|
This content should stay within the boundaries of the parent (presuming it fits).
|
By default, Dropdowns will simply open wherever they fit within the overall viewport. However this can look strange in some cases:
By specifying an element as the Dropdown's bounding parent, you can keep the dropdown within the boundary of that element. Some ACE components like Dialogs are automatically set as boundary elements for dropdowns, so you don't have to manually specify them. To set an element as a Dropdown's boundary, add the |
If there is an existing element to use, pass through the attribute:
Alternatively just write out the markup:
|