Action Sheet
Action Sheet is a slide-up pane for presenting the user with a set of alternatives for how to proceed with a given task.
You can also use action sheets to prompt the user to confirm a potentially dangerous action.
The action sheet contains an optional title and one or more buttons, each of which corresponds to an action to take.
Note that it is not recommended to use Action Sheet on large screens (iPad). On large screens you should use Popover instead.
Lets look at related App methods to work with the Action Sheet:
app.actions.create(parameters)- create Action Sheet instance
- parameters - object. Object with action sheet parameters
Method returns created Action Sheet’s instance
app.actions.destroy(el)- destroy Action Sheet instance
- el - HTMLElement or string (with CSS Selector) or object. Action element instance to destroy.
- el - HTMLElement or string (with CSS Selector). Action Sheet element.
Method returns Action Sheet’s instance
app.actions.open(el, animate)- opens Action Sheet
- el - HTMLElement or string (with CSS Selector). Action Sheet element to open.
- animate - boolean. Open Actions Sheet with animation.
Method returns Action Sheet’s instance
app.actions.close(el, animate)- closes Action Sheet
- animate - boolean. Close Actions Sheet with animation.
Method returns Action Sheet’s instance
Action Sheet Parameters
Now lets look at a list of available parameters we need to create the Action Sheet:
Note that all of the following parameters can be used in the global app parameters under the actions
property to set defaults for all action sheets. For example:
var app = new Framework7({
actions: {
convertToPopover: false,
grid: true,
}
});
Each Button in array must be presented as an object with button parameters:
After that we have its initialized instance (like actions
variable in example above) with useful methods and properties:
Control Action Sheet With Links
It is possible to open and close required action sheets (if you have them in DOM) using special classes and data attributes on links:
To open action sheet we need to add “actions-open“ class to any HTML element (prefered to link)
To close action sheet we need to add “actions-close“ class to any HTML element (prefered to link)
If you have more than one action sheet in DOM, you need to specify appropriate action sheet via additional data-actions=”.my-actions” attribute on this HTML element
According to above note:
<!-- In data-actions attribute we specify CSS selector of action sheet we need to open -->
<p><a href="#" data-actions=".my-actions" class="actions-open">Open Actions</a></p>
<div class="actions-modal my-actions">
...
</div>
Action sheet will fire the following DOM events on action sheet element and events on app and action sheet instance:
Action Sheet instance emits events on both self instance and app instance. App instance events has same names prefixed with actions
.
CSS Variables
Note that commented variables are not specified by default and their values is what they fallback to in this case.
<body>
<div class="page-content">
<div class="block">
<p><a class="ac-1" href="#">One group, three buttons</a></p>
<p><a class="ac-2" href="#">One group, title, three buttons</a></p>
<p><a class="ac-3" href="#">Two groups</a></p>
<p><a class="ac-4" href="#">Three groups</a></p>
<p><a class="ac-5" href="#">With callbacks on click</a></p>
<p><a class="ac-6" href="#">Actions grid</a></p>
</div>
</div>
</body>