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

PropTypeDescription
<f7-sheet> properties
positionstringSheet position, can be `top` or `bottom`. By default is `bottom`
topbooleanSame as `position="top"`
bottombooleanSame as `position="bottom"`
backdropbooleanEnable to render additional sheet modal backdrop when required
backdropElstring
object
HTML element or string CSS selector of custom backdrop element
openedbooleanAllows to open/close Sheet Modal and set its initial state
closeByBackdropClickbooleanWhen enabled, sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClickbooleanWhen enabled, sheet will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscapebooleanWhen enabled, sheet will be closed on ESC keyboard key press

Sheet Modal Methods

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

Sheet Modal Events

EventDescription
<f7-sheet> events
sheet:openEvent will be triggered when Sheet Modal starts its opening animation
sheet:openedEvent will be triggered after Sheet Modal completes its opening animation
sheet:closeEvent will be triggered when Sheet Modal starts its closing animation
sheet:closedEvent will be triggered after Sheet Modal completes its closing animation

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

<template>
  <f7-page @page:beforeremove="onPageBeforeRemove" @page:beforeout="onPageBeforeOut">
    <f7-navbar title="Sheet Modal"></f7-navbar>
    <f7-block>
      <f7-row tag="p">
        <f7-button class="col" raised sheet-open=".demo-sheet">Open Sheet</f7-button>
        <f7-button class="col" raised @click="createSheet">Create Dynamic Sheet</f7-button>
      </f7-row>
      <p>
        <f7-button class="col" raised @click="sheetOpened = true">Open Via Prop Change</f7-button>
      </p>
    </f7-block>
    <f7-sheet class="demo-sheet" :opened="sheetOpened" @sheet:closed="sheetOpened = false">
      <f7-toolbar>
        <div class="left"></div>
        <div class="right">
          <f7-link sheet-close>Close</f7-link>
        </div>
      </f7-toolbar>
      <!-- Scrollable sheet content -->
      <f7-page-content>
        <f7-block>
          <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>
          <!-- ... -->
        </f7-block>
      </f7-page-content>
    </f7-sheet>
  </f7-page>
</template>
<script>
export default {
  data() {
    return {
      sheetOpened: false,
    };
  },
  methods: {
    createSheet() {
      const self = this;
      const $ = self.$$;
      // Create sheet modal
      if (!self.sheet) {
        self.sheet = self.$f7.sheet.create({
          content: `
            <div class="sheet-modal">
              <div class="toolbar">
                <div class="toolbar-inner justify-content-flex-end">
                  <a href="#" class="link sheet-close">Close</a>
                </div>
              </div>
              <div class="sheet-modal-inner">
                <div class="page-content">
                  <div class="block">
                    <p>This sheet modal was created dynamically</p>
                    <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>
                  </div>
                </div>
              </div>
            </div>
          `.trim(),
        });
      }
      // Close inline sheet
      if ($('.demo-sheet.modal-in').length > 0) self.$f7.sheet.close('.demo-sheet');
      // Open it
      self.sheet.open();
    },
    onPageBeforeOut() {
      const self = this;
      // Close opened sheets on page out
      self.$f7.sheet.close();
    },
    onPageBeforeRemove() {
      const self = this;
      // Destroy sheet modal when page removed
      if (self.sheet) self.sheet.destroy();
    },
  },
};
</script>