Unfold (Dropdown and others)
Toggle contextual overlays for displaying lists of links and more with the Front unfold plugin.
Overview
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown style classes.
Accessibility
The WAI ARIA standard defines an actual role="menu"
widget, but this is specific to application-like menus which trigger actions or functions. ARIA menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.
Front'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. For this reason, Front does not expect (nor automatically add) any of the role
and aria-
attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.
However, Front does NOT 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. To avoid duplication, we use the Bootstrap classes with Front dropdown (hs.unfold.js) JS.
How to use?
Wrap the unfold's toggle (your button or link) and the unfold menu within an element that declares position: relative;
. Unfolds can be triggered from <a>
or <button>
elements to better fit your potential needs.
Copy-paste the stylesheet <link>
into your <head>
to load the CSS.
<link rel="stylesheet" href="../../assets/vendor/animate.css/animate.min.css">
Copy-paste the following <script>
near the end of your pages under JS Front to enable it.
<script src="../../assets/js/components/hs.unfold.js"></script>
Copy-paste the init function under JS Plugins Init., before the closing </body>
tag, to enable it.
<script>
$(document).on('ready', function () {
// initialization of unfold component
$.HSCore.components.HSUnfold.init($('[data-unfold-target]'));
});
</script>
Basic examples
Basic example with on hover effect.
<div class="position-relative">
<a id="basicDropdownHoverInvoker" class="dropdown-nav-link dropdown-toggle" href="javascript:;" role="button"
aria-controls="basicDropdownHover"
aria-haspopup="true"
aria-expanded="false"
data-unfold-event="hover"
data-unfold-target="#basicDropdownHover"
data-unfold-type="css-animation"
data-unfold-duration="300"
data-unfold-delay="300"
data-unfold-hide-on-scroll="true"
data-unfold-animation-in="slideInUp"
data-unfold-animation-out="fadeOut">
Basic example
</a>
<div id="basicDropdownHover" class="dropdown-menu dropdown-unfold" aria-labelledby="basicDropdownHoverInvoker">
<a class="dropdown-item active" href="#">One</a>
<a class="dropdown-item" href="#">Two</a>
<a class="dropdown-item" href="#">Three</a>
</div>
</div>
Another example with on click effect.
<div class="position-relative">
<a id="basicDropdownClickInvoker" class="dropdown-nav-link dropdown-toggle" href="javascript:;" role="button"
aria-controls="basicDropdownClick"
aria-haspopup="true"
aria-expanded="false"
data-unfold-event="hover"
data-unfold-target="#basicDropdownClick"
data-unfold-type="css-animation"
data-unfold-duration="300"
data-unfold-delay="300"
data-unfold-hide-on-scroll="true"
data-unfold-animation-in="slideInUp"
data-unfold-animation-out="fadeOut">
Basic example
</a>
<div id="basicDropdownClick" class="dropdown-menu dropdown-unfold" aria-labelledby="basicDropdownClickInvoker">
<a class="dropdown-item active" href="#">One</a>
<a class="dropdown-item" href="#">Two</a>
<a class="dropdown-item" href="#">Three</a>
</div>
</div>
Slide-down search
<!-- Search Content -->
<div id="searchSlideDown" class="dropdown-unfold u-search-slide-down" aria-labelledby="searchSlideDownInvoker">
<form>
<!-- Input Group -->
<div class="input-group input-group-borderless u-search-slide-down__input rounded mb-2">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-search"></span>
</span>
</div>
<input type="search" class="form-control" placeholder="Search Front" aria-label="Search Front">
<div class="input-group-append">
<a class="input-group-text" href="javascript:;"
aria-label="close"
data-unfold-event="click"
data-unfold-hide-on-scroll="false"
data-unfold-target="#searchSlideDown"
data-unfold-type="css-animation"
data-unfold-animation-in="active"
data-unfold-animation-out="fadeOutUp"
data-unfold-delay="0"
data-unfold-duration="800"
data-unfold-overlay='{
"className": "u-search-slide-down-bg-overlay",
"background": "rgba(55, 125, 255, .1)",
"animationSpeed": 400
}'>
<span class="fas fa-times" aria-hidden="true"></span>
</a>
</div>
</div>
<!-- End Input Group -->
<!-- Suggestions Content -->
<div class="rounded bg-white u-search-slide-down__suggestions py-3 px-5">
<ul class="list-group list-group-flush list-group-borderless mb-0">
<li><a class="list-group-item list-group-item-action" href="../pages/about-agency.html">About Front</a></li>
<li><a class="list-group-item list-group-item-action" href="../../starter/index.html">Getting Started</a></li>
<li><a class="list-group-item list-group-item-action" href="../../documentation/index.html">Documentation</a></li>
</ul>
</div>
<!-- End Suggestions Content -->
</form>
</div>
<!-- End Search Content -->
<!-- Search -->
<div class="position-relative">
<a id="searchSlideDownInvoker" class="btn btn-xs btn-icon btn-text-secondary u-search-slide-down-trigger" href="javascript:;" role="button"
aria-haspopup="true"
aria-expanded="false"
aria-controls="searchSlideDown"
data-unfold-type="css-animation"
data-unfold-hide-on-scroll="false"
data-unfold-target="#searchSlideDown"
data-unfold-animation-in="active"
data-unfold-animation-out="fadeOutUp"
data-unfold-delay="0"
data-unfold-duration="800"
data-unfold-overlay='{
"className": "u-search-slide-down-bg-overlay",
"background": "rgba(55, 125, 255, .1)",
"animationSpeed": 400
}'>
<span class="fas fa-search btn-icon__inner u-search-slide-down-trigger__icon"></span>
</a>
</div>
<!-- End Search -->
Methods
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-unfold-type=""
.
Attributes | Description | Default value |
---|---|---|
|
Show/hide effect.
If data-unfold-type="" is set to jquery-slide , the jQuery slideDown effect will be applied to the opening and slideUp to the close.
If data-unfold-type="" is set to css-animation , then any effect from the library animate.css can be used.
|
|
|
Accepts the ID of the hidden element as a parameter. | |
|
Layer an RGBA transparent color to the body color when action is triggered.
Options:
|
|
|
Defines by what event the script will fire. Valid values are:
|
click |
|
Specifies the duration of the animation. | 300 |
|
Determines the smoothness of the animation, if data-unfold-type="" is set to jquery-slide
jquery.easing.min.js plugin is required to extend the plugin.
Additional values:
|
linear |
|
Specifies the animation delay. | 350 |
|
Revealing animation effect, if data-unfold-type="" is set to css-animation . To run the script, you must additionally link animate.css All available animation values, can be found here |
fadeIn |
|
Disappearing animation effect, if data-unfold-type="" is set to css-animation . To run the script, you must additionally link animate.css All available animation values, can be found here |
fadeOut |
|
If true , content closes on click to the child elements. |
true |
|
If true , enables hiding the content on scroll. |
true |
|
If true , enables hiding the content with blur effect. |
false |
|
Executes the code inside the body of the function each time it is opened. | |
|
Executes the code inside the body of the function each time it is closed. |