Sheet Modal - 图1

Sheet Modal Vue Component

Sheet Modal is a special overlay type which is similar to Picker/Calendar’s overlay. Such modal allows to create custom picker overlays with custom content.

Sheet Modal Vue component represents Sheet Modal component.

Sheet Modal Components

There are following components included:

  • f7-sheet - sheet modal element

Sheet Modal Properties

Prop Type Description
<f7-sheet> properties
--- --- ---
position string Sheet position, can be top or bottom. By default is bottom
top boolean Same as position=”top”
bottom boolean Same as position=”bottom”
backdrop boolean Enable to render additional sheet modal backdrop when required
backdropEl string object HTML element or string CSS selector of custom backdrop element
opened boolean Allows to open/close Sheet Modal and set its initial state
closeByBackdropClick boolean When enabled, sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClick boolean When enabled, sheet will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscape boolean When enabled, sheet will be closed on ESC keyboard key press
swipeToClose boolean Whether the Sheet can be closed with swipe gesture
swipeToStep boolean When enabled it will be possible to split opened sheet into two states: partially opened and fully opened that can be controlled with swipe
swipeHandler HTMLElement string If not passed, then whole Sheet can be swiped to close. You can pass here HTML element or string CSS selector of custom element that will be used as a swipe target. (swipeToClose or swipeToStep must be also enabled)
push boolean When enabled it will push view behind on open. Works only when top safe area is in place. It can also be enabled by adding sheet-modal-push class to Sheet element.

Sheet Modal Methods

<f7-sheet> methods
.open(animate) Open sheet modal
.close(animate) Close sheet modal

Sheet Modal Events

Event Description
<f7-sheet> events
--- ---
sheet:open Event will be triggered when Sheet Modal starts its opening animation
sheet:opened Event will be triggered after Sheet Modal completes its opening animation
sheet:close Event will be triggered when Sheet Modal starts its closing animation
sheet:closed Event will be triggered after Sheet Modal completes its closing animation
sheet:stepopen Event will be triggered on Sheet swipe step open/expand
sheet:stepclose Event will be triggered on Sheet swipe step close/collapse
sheet:stepprogress Event will be triggered on Sheet swipe step between step opened and closed state. As event.detail it receives step open progress number (from 0 to 1)

Open And Close Sheet Modal

You can control Sheet Modal state, open and closing it:

  • using its Sheet Modal API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant sheet-open property (to open it) and sheet-close property to close it

Access To Sheet Modal Instance

You can access Sheet Modal initialized instance by accessing .f7Sheet component’s property.

Examples

1. <template>
2. <f7-page @page:beforeremove="onPageBeforeRemove" @page:beforeout="onPageBeforeOut">
3. <f7-navbar title="Sheet Modal"></f7-navbar>
4. <f7-block>
5. <p>
6. <f7-button fill sheet-open=".demo-sheet">Open Sheet</f7-button>
7. </p>
8. <p>
9. <f7-button fill @click="createSheet">Create Dynamic Sheet</f7-button>
10. </p>
11. <p>
12. <f7-button fill @click="sheetOpened = true">Open Via Prop Change</f7-button>
13. </p>
14. <p>
15. <f7-button fill sheet-open=".demo-sheet-swipe-to-close">Swipe To Close</f7-button>
16. </p>
17. <p>
18. <f7-button fill sheet-open=".demo-sheet-swipe-to-step">Swipe To Step</f7-button>
19. </p>
20. <p>
21. <f7-button fill sheet-open=".demo-sheet-push">Sheet Push</f7-button>
22. </p>
23. </f7-block>

25. <f7-sheet class="demo-sheet" :opened="sheetOpened" @sheet:closed="sheetOpened = false">
26. <f7-toolbar>
27. <div class="left"></div>
28. <div class="right">
29. <f7-link sheet-close>Close</f7-link>
30. </div>
31. </f7-toolbar>
32. <!-- Scrollable sheet content -->
33. <f7-page-content>
34. <f7-block>
35. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae ducimus dolorum ipsa aliquid accusamus perferendis laboriosam delectus numquam minima animi, libero illo in tempora harum sequi corporis alias ex adipisci...</p>
36. <!-- ... -->
37. </f7-block>
38. </f7-page-content>
39. </f7-sheet>

41. <!-- Swipe to close demo sheet -->
42. <f7-sheet
43. class="demo-sheet-swipe-to-close"
44. style="height:auto; --f7-sheet-bg-color: #fff;"
45. swipe-to-close
46. backdrop
47. >
48. <f7-page-content>
49. <f7-block-title large>Hello!</f7-block-title>
50. <f7-block>
51. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab...</p>
52. </f7-block>
53. </f7-page-content>
54. </f7-sheet>

56. <!-- Swipe to step demo sheet -->
57. <f7-sheet
58. class="demo-sheet-swipe-to-step"
59. style="height:auto; --f7-sheet-bg-color: #fff;"
60. swipe-to-close
61. swipe-to-step
62. backdrop
63. >
64. <!-- Initial swipe step sheet content -->
65. <div class="sheet-modal-swipe-step">
66. <div class="display-flex padding justify-content-space-between align-items-center">
67. <div style="font-size: 18px"><b>Total:</b></div>
68. <div style="font-size: 22px"><b>$500</b></div>
69. </div>
70. <div class="padding-horizontal padding-bottom">
71. <f7-button large fill>Make Payment</f7-button>
72. <div class="margin-top text-align-center">Swipe up for more details</div>
73. </div>
74. </div>
75. <!-- Rest of the sheet content that will opened with swipe -->
76. <f7-block-title medium class="margin-top">Your order:</f7-block-title>
77. <f7-list no-hairlines>
78. <f7-list-item title="Item 1">
79. <b slot="after" class="text-color-black">$200</b>
80. </f7-list-item>
81. <f7-list-item title="Item 2">
82. <b slot="after" class="text-color-black">$180</b>
83. </f7-list-item>
84. <f7-list-item title="Delivery">
85. <b slot="after" class="text-color-black">$120</b>
86. </f7-list-item>
87. </f7-list>
88. </f7-sheet>

90. <!-- Sheet Push -->
91. <f7-sheet class="demo-sheet-push" push>
92. <f7-toolbar>
93. <div class="left"></div>
94. <div class="right">
95. <f7-link sheet-close>Close</f7-link>
96. </div>
97. </f7-toolbar>
98. <f7-page-content>
99. <f7-block>
100. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
101. </f7-block>
102. </f7-page-content>
103. </f7-sheet>
104. </f7-page>
105. </template>
1. <script>
2. export default {
3. data() {
4. return {
5. sheetOpened: false,
6. };
7. },
8. methods: {
9. createSheet() {
10. const self = this;
11. const $ = self.$$;
12. // Create sheet modal
13. if (!self.sheet) {
14. self.sheet = self.$f7.sheet.create({
15. content: `
16. <div class="sheet-modal">
17. <div class="toolbar">
18. <div class="toolbar-inner justify-content-flex-end">
19. <a href="#" class="link sheet-close">Close</a>
20. </div>
21. </div>
22. <div class="sheet-modal-inner">
23. <div class="page-content">
24. <div class="block">
25. <p>This sheet modal was created dynamically</p>
26. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim...</p>
27. </div>
28. </div>
29. </div>
30. </div>
31. `.trim(),
32. });
33. }
34. // Close inline sheet
35. if ($('.demo-sheet.modal-in').length > 0) self.$f7.sheet.close('.demo-sheet');
36. // Open it
37. self.sheet.open();
38. },
39. onPageBeforeOut() {
40. const self = this;
41. // Close opened sheets on page out
42. self.$f7.sheet.close();
43. },
44. onPageBeforeRemove() {
45. const self = this;
46. // Destroy sheet modal when page removed
47. if (self.sheet) self.sheet.destroy();
48. },
49. },
50. };
51. </script>

← Searchbar

Skeleton →