Dropdown
Design
Dropdowns are used to provide access to lesser used, but related actions, to a context. Putting lesser used actions within a dropdown helps to de-clutter the interface.
Example | Name | Comments |
---|---|---|
Basic | The basic dropdown |
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. |
|
|
12Mb Acrobat PDF
|
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 |
|
|
To set an item's state to active, add the class ace-dropdown-menu-action-active. |
|
Reports |
Dropdown content groups can have a heading. Add an H3 with the class |
|
|
Dropdown with disabled content. |
|
|
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 |
|
(boundary element) | To set an element as a Dropdown's boundary, add the data-ace-dropdown-bounds attribute. Refer to the full boundary element demo below.
|
If there is an existing element to use, pass through the attribute:
Alternatively just write out the markup:
|
Dropdown inside boundary element
By default, Dropdowns will simply open where they fit within the overall viewport. By specifying an element as the Dropdown's bounding parent, you can keep the dropdown within the boundary of that element. This is useful when:
- A parent element has overflow, and will cause the dropdown to clip if placed in the wrong place.
- The design calls for a dropdown to fit within a certain area.
- A parent element has its own scrolling applied, which may mean that the dropdown opens in a hidden area.
Some ACE components like Dialogs are automatically set as boundary elements for dropdowns, so you don't have to manually specify them.
<div data-ace-dropdown-bounds="true" class="boundarydropdowndemo">
<div class="ace-dropdown">
<button type="button" class="ace-button" data-ace-dropdown-trigger="^"><span><span>Dropdown</span><span class="ace-icon ace-icon-control-arrowdown"></span></span></button>
<div class="ace-dropdown-content">
<div class="ace-dropdown-content-group">
<ul class="ace-dropdown-menu">
<li class="ace-dropdown-menu-action"><a href="#"><span class="ace-icon ace-icon-add-generic"></span> Add</a></li>
<li class="ace-dropdown-menu-action"><a href="#"><span class="ace-icon ace-icon-action-remove"></span> Remove</a></li>
<li class="ace-dropdown-menu-action"><a href="#"><span class="ace-icon ace-icon-action-edit"></span> Edit</a></li>
</ul>
</div>
<div class="ace-dropdown-content-group">This content should stay within the boundaries of the parent if possible
</div>
</div>
</div>
</div>