Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-loading-skeleton

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-loading-skeleton

Make beautiful loading skeleton that automatically adapt your vue app.

  • 1.1.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-7.55%
Maintainers
1
Weekly downloads
 
Created
Source

💅🏻 Vue-loading-skeleton

Make beautiful loading skeleton that automatically adapt your vue app.

💡Demos of storybook

📕中文文档

Base usage

Install by npm/yarn with vue-loading-skeleton

import { Skeleton } from 'vue-loading-skeleton';

// In jsx template
<Skeleton />
<Skeleton count={5} />

Or register for global component

import Vue from 'vue';
import Skeleton from 'vue-loading-skeleton';

Vue.use(Skeleton)

// In jsx template
<PuSkeleton />
<PuSkeleton count={5} />

🌈 Introduction

Adapts to the styles you have defined

The <Skeleton/> component is design to used directly in your vue component. It can replace the main content while page still in loading. So you don't need to prepare a skeleton screen meticulously to match the font-size, margin or another style your content takes on, wrap the content with the <Skeleton/> component, it will automatically fill the correct dimensions.

For example:

<div class="item">
  <div class="item__photo">
    <PuSkeleton circle height="50px">
      {{ props.data.img }}
    </PuSkeleton>
  </div>
  <div class="item__meta">
    <div class="item__title">
      <PuSkeleton>{{ props.data.title }}</PuSkeleton>
    </div>
    <div class="item__info">
      <PuSkeleton :count="2">{{ props.data.body }}</PuSkeleton>
    </div>
  </div>
</div>

⚠️ Notice

The skeleton component will check the tag and text in the first child node. If you find the component work is not in expect, you should use v-if or loading props, and report the issues to me.

📔Usage

Base usage

<div class="item">
  <Skeleton>
    {{ content }}
  </Skeleton>
</div>

Use v-if

<div class="item">
  <template v-if="content">{{ content }}</template>
  <Skeleton v-else />
</div>

List Skeleton

In many cases, you need a skeleton list to fulfill a listing page. You can set the list data default to the number. Such as:

<div class="item" v-for="(item, index) in data" :key="index">
  <Skeleton>
    {{ item.content }}
  </Skeleton>
</div>
export default {
  data() {
    return {
      data: 10
    }
  },
  async created() {
    // some data fetch action
    const { data } = await fetchData();
    this.data = data;
  }
}

Theming

Using the <SkeletonTheme /> component, you can change the color, duration of all skeleton components below it:

import { Skeleton, Skeleton } form 'vue-loading-skeleton';

<SkeletonTheme color="#e6f3fd" highlight="#eef6fd">
  <div class="item">
    <div class="item__photo">
      <PuSkeleton circle height="50px">
        {{ props.data.img }}
      </PuSkeleton>
    </div>
    <div class="item__meta">
      <div class="item__title">
        <PuSkeleton>{{ props.data.title }}</PuSkeleton>
      </div>
      <div class="item__info">
        <PuSkeleton :count="2">{{ props.data.body }}</PuSkeleton>
      </div>
    </div>
  </div>
</SkeletonTheme>

Skeleton props

propsdescriptiontypedefault
countrows count of componentnumber1
durationanimation duration time, 0 as closenumber1.5
widthcomponent widthstring
heightcomponent heightstring
circlemake the skeleton look like a circlebooleanfalse
loadingskeleton loading statusbooleanundefined

SkeletonTheme props

propsdescriptiontypedefault
colorskeleton background colorstring#eeeeee
highlightanimation highlight colorstring#f5f5f5
durationset duration of all skeletonnumber1.5
loadingcontrol loading status of all skeletonsbooleanundefined
tagtheme container tag namestringdiv

Keywords

FAQs

Package last updated on 11 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc