@brayamvalero/vue3-skeleton

中文文档
2.0.0发布于 2025/06/25MITTypeScriptESM + CJS近 30 天下载 3436

An elegant skeleton library compatible with Vue 3

原始使用文档
文档目录9 节
  1. :rocket: Install
  2. :memo: Basic usage
  3. :sparkles: Features
  4. :warning: Avoid the creation of dedicated skeleton screens
  5. :art: Theming
  6. :page_facing_up: Props Declaration
  7. <Skeleton>
  8. <Skeleton> <SkeletonTheme>
  9. Troubleshooting

:skull: Vue3-Skeleton

Build and craft amazing loading experiences that automatically adapts to your Vue app.

This repository is inspired by react-loading-skeleton

:rocket: Install

Install the package via NPM

npm i @brayamvalero/vue3-skeleton

:memo: Basic usage

Install the plugin globally.

import { createApp } from 'vue'
import App from './App.vue'
// Import the component library & Stylesheet
import Skeleton from '@brayamvalero/vue3-skeleton'
import '@brayamvalero/vue3-skeleton/dist/style.css'

createApp(App)
    // Install the Skeleton Plugin
    .use(Skeleton)
    .mount('#app')

Or, install the plugin locally, whether be <script> or <script setup>

<script>
    import { Skeleton } from '@brayamvalero/vue3-skeleton'
    import '@brayamvalero/vue3-skeleton/dist/style.css'

    export default {
        components: { Skeleton },
    }
</script>
<script setup>
    import { Skeleton } from '@brayamvalero/vue3-skeleton'
    import '@brayamvalero/vue3-skeleton/dist/style.css'
</script>

Now, you're ready to go

<template>
    <div class="Home">
        <h1>
            <!--Skeleton will inherit <h1> height -->
            <Skeleton />
        </h1>
        <p>
            <!--Skeleton will inherit <p> height -->
            <Skeleton :rows="3" />
        </p>
    </div>
</template>

:sparkles: Features

Adapting to your defined styles seamlessly, The <Skeleton /> module seamlessly integrates into your components, filling the void during loading. Unlike other frameworks where crafting a skeleton screen is a meticulous task of matching font size, line height, and margins, our Skeleton component effortlessly adjusts to the correct dimensions.

Take, for instance:

<template>
    <div class="Home">
        <h1>
            <Skeleton>{{ data.title }}</Skeleton>
        </h1>
        <p>
            <Skeleton :rows="3">{{ data.description }}</Skeleton>
        </p>
    </div>
</template>

This code snippet ensures the generation of precisely proportioned skeletons for both the <h1> and <p> elements without needing any additional configuration. Moreover, it orchestrates a seamless transition, waiting until the content is fully loaded before concealing the Skeleton and unveiling the loaded content gracefully.

Manual Loading

Use the loading prop to manually control the loading state of the skeleton.

<template>
    <div class="Home">
        <h1>
            <Skeleton :loading="loading">{{ data.title }}</Skeleton>
        </h1>
        <p>
            <Skeleton :loading="loading" :rows="3">{{ data.description }}</Skeleton>
        </p>
    </div>
</template>

:warning: Avoid the creation of dedicated skeleton screens

Instead, craft components equipped with integrated skeleton states.

This methodology offers several advantages:

  • Harmonized Styles: Ensures consistency across styles.
  • Comprehensive Representation: Components should embody all conceivable states, including loading.
  • Enhanced Loading Flexibility: Enables more adaptable loading sequences.

:art: Theming

Customize individual skeletons with props, or render a SkeletonTheme to style all skeletons below it.

<script setup>
    import { Skeleton, SkeletonTheme } from '@brayamvalero/vue3-skeleton'
    import '@brayamvalero/vue3-skeleton/dist/style.css'
</script>

<template>
    <div class="Home">
        <!-- This applies Base Color and Highligh Color to all Skeletons -->
        <SkeletonTheme base-color="#303030" highlight-color="#606060">
            <h1>
                <Skeleton>{{ data.title }}</Skeleton>
            </h1>
            <p>
                <Skeleton :rows="3">{{ data.description }}</Skeleton>
            </p>
        </SkeletonTheme>
    </div>
</template>

Props declared inside <Skeleton /> will take priority over <SkeletonTheme /> props.

:page_facing_up: Props Declaration

Down bellow you can take a look at each prop available.

<Skeleton>

NameTypeDescriptionDefault
rowsnumberSet component amount of rows1
circlebooleanSet component border-radius to 50%, it replaces borderRadius propsfalse
containerClassstringSet component class to skeleton containernull
childClassstringSet component class to each skeleton childnull
loadingbooleanSet component loading stateundefined

<Skeleton> <SkeletonTheme>

NameTypeDescriptionDefault
widthstring numberSet component width, it can be either number px or string with its corresponding css value100%
heightstring numberSet component height, it can be either number px or string with its corresponding css valueinherit
borderRadiusstring numberSet component border-radius, it can be either number px or string with its corresponding css value0.25rem
baseColorstringSet component background-color#ebebeb
highlightColorstringSet component background-image highlight color animation#ebebeb
animationDurationnumberSet component animation-duration in seconds#f5f5f5
animationDirectionnormal reverseSet component animation direction normal (left to right) or reverse (right to left)normal
enableAnimationbooleanSet component animation status running or pausedtrue
inlinebooleanSet component inline behaviorfalse
customHighlightBackgroundstringOverride the background-image property of the highlight element, enabling you to fully customize the gradient.undefined

Custom Highlight Background

You may want to make the gradient used in the highlight element narrower or wider. To do this, you can set the customHighlightBackground prop. Here's an example of a narrow highlight:

<Skeleton custom-highlight-background="linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%)">
    Loading...
</Skeleton>

If you use this prop, the baseColor and highlightColor props are ignored, but you can still reference their corresponding CSS variables as shown in the above example.

Troubleshooting

The skeleton width is 0 when the parent has display: flex In the example below, the width of the skeleton will be 0:

<div :style="{ display: 'flex' }">
    <Skeleton :style="{ flex: 1 }" />
</div>

This happens because the skeleton has no intrinsic width. You can fix it by applying flex: 1 to the skeleton container, you can also set this style via the containerClass prop.

版本与发布记录

@brayamvalero/vue3-skeleton 共发布 35 个版本,首次发布于 2024/03/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2025/06/251.4 年前
1.0.12025/05/211.5 年前
1.0.02025/05/161.5 年前
0.0.322024/04/092 年前
0.0.312024/04/092 年前
0.0.302024/04/092 年前

关于 @brayamvalero/vue3-skeleton 的常见问题

@brayamvalero/vue3-skeleton 是什么?

An elegant skeleton library compatible with Vue 3

如何安装 @brayamvalero/vue3-skeleton?

在项目目录运行 npm install @brayamvalero/vue3-skeleton,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@brayamvalero/vue3-skeleton 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@brayamvalero/vue3-skeleton 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@brayamvalero/vue3-skeleton 可以商用吗?

@brayamvalero/vue3-skeleton 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@brayamvalero/vue3-skeleton 的下载量有多少?

根据 npm 官方下载统计,@brayamvalero/vue3-skeleton 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,436 次,日均约 115 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@brayamvalero/vue3-skeleton 还在维护吗?

最新版本 2.0.0 发布于 2025/06/25(1.4 年前);至今共发布 35 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/03/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。