Action Sheet / Actions - 图1

Action Sheet Vue Component

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.

Action Sheet Vue component represents Action Sheet component.

Action Sheet Components

There are following components included:

  • **f7-actions** - action sheet element
  • **f7-actions-group** - action sheet buttons group
  • **f7-actions-button** - action sheet button
  • **f7-actions-label** - action sheet label

Action Sheet Properties

Prop Type Default Description
<f7-actions> properties
--- --- --- ---
opened boolean false Allows to open/close Action Sheet and set its initial state
grid boolean false Enables grid buttons layout
convertToPopover boolean When enabled, action sheet will be converted to Popover on large screens. By default inherits same app parameter value
forceToPopover boolean When enabled, action sheel will be always converted to Popover. By default inherits same app parameter value
target HTMLElement string HTML element or string CSS selector of target element. Required when converstion to popover is in use
backdrop boolean Enables action sheet backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
backdropEl string object HTML element or string CSS selector of custom backdrop element
closeByBackdropClick boolean true When enabled, action sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClick boolean false When enabled, action sheet will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscape boolean When enabled, action sheet will be closed on ESC keyboard key press
<f7-actions-label> properties
bold boolean false Defines whether the label text is bold or not
<f7-actions-button> properties
bold boolean false Defines whether the button text is bold or not
close boolean true Should Action Sheet be closed on button click or not

Action Sheet Methods

<f7-actions> methods
.open(animate) Open Action Sheet
.close(animate) Close Action Sheet

Action Sheet Events

Event Description
<f7-actions> events
--- ---
actions:open Event will be triggered when Action Sheet starts its opening animation
actions:opened Event will be triggered after Action Sheet completes its opening animation
actions:close Event will be triggered when Action Sheet starts its closing animation
actions:closed Event will be triggered after Action Sheet completes its closing animation

Open And Close Action Sheet

In addition to Action Sheet open()/close() methods, you can open and close it:

Access To Action Sheet Instance

You can access Action Sheet initialized instance by accessing **.f7Actions** component’s property.

Examples

1. <template>
2. <f7-page>
3. <f7-navbar title="Action Sheet"></f7-navbar>
4. <f7-block strong>
5. <p class="row">
6. <!-- One group, open by direct accessing instance .open() method -->
7. <f7-button class="col" raised @click="$refs.actionsOneGroup.open()">One group</f7-button>
8. <!-- Two groups, open by "actions-open" attribute -->
9. <f7-button class="col" raised actions-open="#actions-two-groups">Two groups</f7-button>
10. </p>
11. <p>
12. <!-- Actions Grid, open by changing actionGridOpened prop -->
13. <f7-button raised @click="actionGridOpened = true">Action Grid</f7-button>
14. </p>
15. </f7-block>

17. <f7-block-title>Action Sheet To Popover</f7-block-title>
18. <f7-block strong>
19. <p>Action Sheet can be automatically converted to Popover (for tablets). This button will open Popover on tablets and Action Sheet on phones: <f7-button style="display:inline-block" class="button-to-popover" @click="openActionsPopover">Actions</f7-button></p>
20. </f7-block>

22. <!-- One Group -->
23. <f7-actions ref="actionsOneGroup">
24. <f7-actions-group>
25. <f7-actions-label>Do something</f7-actions-label>
26. <f7-actions-button bold>Button 1</f7-actions-button>
27. <f7-actions-button>Button 2</f7-actions-button>
28. <f7-actions-button color="red">Cancel</f7-actions-button>
29. </f7-actions-group>
30. </f7-actions>

32. <!-- Two Groups -->
33. <f7-actions id="actions-two-groups">
34. <f7-actions-group>
35. <f7-actions-label>Do something</f7-actions-label>
36. <f7-actions-button bold>Button 1</f7-actions-button>
37. <f7-actions-button>Button 2</f7-actions-button>
38. </f7-actions-group>
39. <f7-actions-group>
40. <f7-actions-button color="red">Cancel</f7-actions-button>
41. </f7-actions-group>
42. </f7-actions>

44. <!-- Grid -->
45. <f7-actions :grid="true" :opened="actionGridOpened" @actions:closed="actionGridOpened = false">
46. <f7-actions-group>
47. <f7-actions-button>
48. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-1.jpg" width="48"/>
49. <span>Button 1</span>
50. </f7-actions-button>
51. <f7-actions-button>
52. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-2.jpg" width="48"/>
53. <span>Button 2</span>
54. </f7-actions-button>
55. <f7-actions-button>
56. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-3.jpg" width="48"/>
57. <span>Button 3</span>
58. </f7-actions-button>
59. </f7-actions-group>
60. <f7-actions-group>
61. <f7-actions-button>
62. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-4.jpg" width="48"/>
63. <span>Button 4</span>
64. </f7-actions-button>
65. <f7-actions-button>
66. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-5.jpg" width="48"/>
67. <span>Button 5</span>
68. </f7-actions-button>
69. <f7-actions-button>
70. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-6.jpg" width="48"/>
71. <span>Button 6</span>
72. </f7-actions-button>
73. </f7-actions-group>
74. </f7-actions>

76. </f7-page>
77. </template>
78. <script>
79. export default {
80. data() {
81. return {
82. actionGridOpened: false,
83. };
84. },
85. methods: {
86. openActionsPopover() {
87. const self = this;
88. const app = self.$f7;
89. if (!self.actionsToPopover) {
90. self.actionsToPopover = app.actions.create({
91. buttons: [
92. {
93. text: 'Do something',
94. label: true,
95. },
96. {
97. text: 'Button 1',
98. bold: true,
99. },
100. {
101. text: 'Button 2',
102. },
103. {
104. text: 'Cancel',
105. color: 'red',
106. },
107. ],
108. // Need to specify popover target
109. targetEl: self.$el.querySelector('.button-to-popover'),
110. });
111. }

113. // Open
114. self.actionsToPopover.open();
115. },
116. },
117. };
118. </script>