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

PropTypeDefaultDescription
<f7-actions> properties
openedbooleanfalseAllows to open/close Action Sheet and set its initial state
gridbooleanfalseEnables grid buttons layout
convertToPopoverbooleanWhen enabled, action sheet will be converted to Popover on large screens. By default inherits same app parameter value
forceToPopoverbooleanWhen enabled, action sheel will be always converted to Popover. By default inherits same app parameter value
targetHTMLElement
string
HTML element or string CSS selector of target element. Required when converstion to popover is in use
backdropbooleanEnables action sheet backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
backdropElstring
object
HTML element or string CSS selector of custom backdrop element
closeByBackdropClickbooleantrueWhen enabled, action sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClickbooleanfalseWhen enabled, action sheet will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscapebooleanWhen enabled, action sheet will be closed on ESC keyboard key press
<f7-actions-label> properties
boldbooleanfalseDefines whether the label text is bold or not
<f7-actions-button> properties
boldbooleanfalseDefines whether the button text is bold or not
closebooleantrueShould 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

EventDescription
<f7-actions> events
actions:openEvent will be triggered when Action Sheet starts its opening animation
actions:openedEvent will be triggered after Action Sheet completes its opening animation
actions:closeEvent will be triggered when Action Sheet starts its closing animation
actions:closedEvent 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>
  16. <f7-block-title>Action Sheet To Popover</f7-block-title>
  17. <f7-block strong>
  18. <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>
  19. </f7-block>
  20. <!-- One Group -->
  21. <f7-actions ref="actionsOneGroup">
  22. <f7-actions-group>
  23. <f7-actions-label>Do something</f7-actions-label>
  24. <f7-actions-button bold>Button 1</f7-actions-button>
  25. <f7-actions-button>Button 2</f7-actions-button>
  26. <f7-actions-button color="red">Cancel</f7-actions-button>
  27. </f7-actions-group>
  28. </f7-actions>
  29. <!-- Two Groups -->
  30. <f7-actions id="actions-two-groups">
  31. <f7-actions-group>
  32. <f7-actions-label>Do something</f7-actions-label>
  33. <f7-actions-button bold>Button 1</f7-actions-button>
  34. <f7-actions-button>Button 2</f7-actions-button>
  35. </f7-actions-group>
  36. <f7-actions-group>
  37. <f7-actions-button color="red">Cancel</f7-actions-button>
  38. </f7-actions-group>
  39. </f7-actions>
  40. <!-- Grid -->
  41. <f7-actions :grid="true" :opened="actionGridOpened" @actions:closed="actionGridOpened = false">
  42. <f7-actions-group>
  43. <f7-actions-button>
  44. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-1.jpg" width="48"/>
  45. <span>Button 1</span>
  46. </f7-actions-button>
  47. <f7-actions-button>
  48. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-2.jpg" width="48"/>
  49. <span>Button 2</span>
  50. </f7-actions-button>
  51. <f7-actions-button>
  52. <img slot="media" src="https://cdn.framework7.io/placeholder/people-96x96-3.jpg" width="48"/>
  53. <span>Button 3</span>
  54. </f7-actions-button>
  55. </f7-actions-group>
  56. <f7-actions-group>
  57. <f7-actions-button>
  58. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-4.jpg" width="48"/>
  59. <span>Button 4</span>
  60. </f7-actions-button>
  61. <f7-actions-button>
  62. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-5.jpg" width="48"/>
  63. <span>Button 5</span>
  64. </f7-actions-button>
  65. <f7-actions-button>
  66. <img slot="media" src="https://cdn.framework7.io/placeholder/fashion-96x96-6.jpg" width="48"/>
  67. <span>Button 6</span>
  68. </f7-actions-button>
  69. </f7-actions-group>
  70. </f7-actions>
  71. </f7-page>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. actionGridOpened: false,
  78. };
  79. },
  80. methods: {
  81. openActionsPopover() {
  82. const self = this;
  83. const app = self.$f7;
  84. if (!self.actionsToPopover) {
  85. self.actionsToPopover = app.actions.create({
  86. buttons: [
  87. {
  88. text: 'Do something',
  89. label: true,
  90. },
  91. {
  92. text: 'Button 1',
  93. bold: true,
  94. },
  95. {
  96. text: 'Button 2',
  97. },
  98. {
  99. text: 'Cancel',
  100. color: 'red',
  101. },
  102. ],
  103. // Need to specify popover target
  104. targetEl: self.$el.querySelector('.button-to-popover'),
  105. });
  106. }
  107. // Open
  108. self.actionsToPopover.open();
  109. },
  110. },
  111. };
  112. </script>

← Accordion

Appbar →