Skip to content

Instantly share code, notes, and snippets.

@anwar0101
Forked from adamwathan/v-cloak.md
Last active June 3, 2018 07:01
Show Gist options
  • Select an option

  • Save anwar0101/27c5d9ca322f7e7f5a826c04ac451498 to your computer and use it in GitHub Desktop.

Select an option

Save anwar0101/27c5d9ca322f7e7f5a826c04ac451498 to your computer and use it in GitHub Desktop.
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div id="app">

  <div v-cloak>

   <div class="v-cloak--inline"> <!-- Parts that will be visible before compiled your HTML -->
      <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
      <span class="sr-only">Loading...</span>
   </div>

   <div class="v-cloak--hidden"> <!-- Parts that will be visible After compiled your HTML -->
      <!-- Rest of the contents -->
      @yield('content')
   </div>

  </div>

</div>

Includes variations for block, inline, and inline-block display attributes.

[v-cloak] .v-cloak--block {
  display: block;
}
[v-cloak] .v-cloak--inline {
  display: inline;
}
[v-cloak] .v-cloak--inlineBlock {
  display: inline-block;
}
[v-cloak] .v-cloak--hidden {
  display: none;
}
[v-cloak] .v-cloak--invisible {
  visibility: hidden;
}
.v-cloak--block,
.v-cloak--inline,
.v-cloak--inlineBlock {
  display: none;
}

Then Before compiling the HTML file, a spinner will render. After compiled, spinner will hide. You can use this in your master page. Thus in every time when you load a new page, that will see the effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment