Preloader

    Framework7 has a nice preloader indicator. Preloader is made with SVG and animated with CSS so it can be easily resized.

    Preloader Layout

    Layout is pretty simple:

    <div class="preloader"></div>

    MD theme uses more complex preloader layout as it has more complex animation. Usually if it is inside of page or created withing some API methods F7 will add this additional inner layout automatically. But if you will add it manually using, lets say, direct DOM manipulation then you may need to add full layout which is required for MD theme:

    <!-- Full preloader layout for MD theme -->
    <div class="preloader">
      <span class="preloader-inner">
        <span class="preloader-inner-gap"></span>
        <span class="preloader-inner-left">
            <span class="preloader-inner-half-circle"></span>
        </span>
        <span class="preloader-inner-right">
            <span class="preloader-inner-half-circle"></span>
        </span>
      </span>
    </div>

    Preloader Colors

    Preloader supports all default colors. So to change its color just add color-[color] class to preloader element.

    MD theme also supports special color-multi color to make preloader multi-color.

    <!-- Red preloader -->
    <div class="preloader color-red"></div>
    
    <!-- Green preloader -->
    <div class="preloader color-green"></div>
    
    <!-- Multicolor preloader (MD theme only) -->
    <div class="preloader color-multi"></div>

    Preloader Overlay / Preloader API

    It is also possible to call special Preloader overlay which is useful if you need to block user actions until something is loaded. This kind of preloader will appear in front of app and block any user actions behind it.

    Let's look at related app methods to work with Preloader overlay

    app.preloader.show(color)- show Preloader overlay

    app.preloader.hide()- hide Preloader overlay

    For example:

    var app = new Framework7();
    
    // Show preloader before Ajax request
    app.preloader.show();
    
    // Perform Ajax request
    app.request.get('someurl.html', function (data) {
      // Hide preloader when Ajax request completed
      app.preloader.hide();
    });

    Opening Preloader overlay will also add with-modal-preloader class to <html> element.

    Examples

    <div class="block-title">Default</div>
    <div class="block block-strong align-items-stretch text-align-center">
      <div class="row text-align-center">
        <div class="col-25">
          <div class="preloader"></div>
        </div>
        <div class="col-25" style="background: #222">
          <div class="preloader color-white"></div>
        </div>
        <!-- Large preloaders -->
        <div class="col-25">
          <div class="preloader" style="width: 44px; height: 44px"></div>
        </div>
        <div class="col-25" style="background: #222">
          <div class="preloader color-white" style="width: 44px; height: 44px"></div>
        </div>
      </div>
    </div>
    <div class="block-title">Color Preloaders</div>
    <div class="block block-strong">
      <div class="row">
        <div class="col-25">
          <div class="preloader color-red"></div>
        </div>
        <div class="col-25">
          <div class="preloader color-green"></div>
        </div>
        <div class="col-25">
          <div class="preloader color-orange"></div>
        </div>
        <div class="col-25">
          <div class="preloader color-blue"></div>
        </div>
      </div>
    </div>
    <div class="block-title">Multi-color (MD-theme only)</div>
    <div class="block block-strong text-align-center">
      <div class="preloader color-multi"></div>
    </div>
    <div class="block-title">Preloader Modals</div>
    <div class="block block-strong">
      <p>With <b>app.preloader.show()</b> you can show small overlay with preloader indicator.</p>
      <p>
        <a class="button button-raised open-preloader-indicator">Open Small Indicator</a>
      </p>
    </div>
    var app = new Framework7();
    
    var $$ = Dom7;
    
    $$('.open-preloader-indicator').on('click', function () {
      app.preloader.show();
      setTimeout(function () {
        app.preloader.hide();
      }, 3000);
    });