Skeleton
Displays placeholders until content is ready; the default slot mounts when loading ends.
Import
Use <hui-skeleton> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<template>
<view>
<hui-space direction="vertical" fill>
<hui-button custom-class="hui-space__item" @click="loading = !loading"
>切换加载 / Toggle loading</hui-button
>
<hui-skeleton custom-class="hui-space__item" :loading="loading" avatar title image :rows="3"
><text>内容已就绪 / Content ready</text></hui-skeleton
>
<hui-skeleton
custom-class="hui-space__item"
:animated="false"
:row-width="['90%', '70%']"
:rows="2"
/>
<hui-skeleton custom-class="hui-space__item"
><template #template
><hui-skeleton-item variant="circle" /><hui-skeleton-item :width="160" /></template
></hui-skeleton>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const loading = ref(true)
</script>
Props
| Prop | Type | Default | Details |
|---|---|---|---|
loading | boolean | true | Displays a loading state instead of content. |
animated | boolean | true | Enables animation; browser reduced-motion preferences take priority. |
rows | number | 3 | Number of text rows. |
rowWidth | number | string | (number | string)[] | '100%' | Row width or an array of widths; default final row is shorter. |
title | boolean | false | Heading text, or the title-placeholder switch for Skeleton. |
titleWidth | number | string | '40%' | Title placeholder width. |
avatar | boolean | false | Shows an avatar placeholder. |
avatarSize | SkeletonAvatarSize | 'default' | Avatar size: large 48, default 40 or small 32 px, or an explicit number. |
avatarShape | 'circle' | 'square' | 'circle' | Avatar placeholder shape. |
image | boolean | false | Displays an image placeholder. |
imageRatio | number | 16 / 9 | Image placeholder width-to-height ratio. |
round | boolean | false | Enables rounded corners. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
None.
Slots
| Slot | Scope |
|---|---|
template | — |
default | — |
Methods
None.
Types
SkeletonAvatarSize、SkeletonProps、SkeletonEmits.
Platform notes
Skeleton and Image loading states share background variables and a shimmer mixin. Browser reduced-motion settings disable animation; mini-program and App follow animated. Blocks are aria-hidden while the parent exposes aria-busy and loading text.
Device smoke checklist.