Skip to content

Skeleton - Vant 4

Skeleton

Intro

Used to display a set of placeholder graphics during the content loading process.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { Skeleton, SkeletonTitle, SkeletonImage, SkeletonAvatar, SkeletonParagraph, } from'vant'; const app = createApp(); app.use(Skeleton); app.use(SkeletonTitle); app.use(SkeletonImage); app.use(SkeletonAvatar); app.use(SkeletonParagraph);

Usage

Basic Usage

html

Show Avatar

html

Show Children

html
js
import { ref, onMounted } from'vue'; exportdefault { setup() { const loading = ref(true); onMounted(() => { loading.value = false; }); return { loading, }; }, };

Custom Content

Using template slots to custom skeleton content.

html

API

Skeleton Props

AttributeDescriptionTypeDefault
rowRow count*numberstring*
row-widthRow width, can be array*numberstring
titleWhether to show title placeholderbooleanfalse
avatarWhether to show avatar placeholderbooleanfalse
loadingWhether to show skeleton, pass false to show child componentbooleantrue
animateWhether to enable animationbooleantrue
roundWhether to show round title and paragraphbooleanfalse
title-widthTitle width*numberstring*
avatar-sizeSize of avatar placeholder*numberstring*
avatar-shapeShape of avatar placeholder, can be set to squarestringround

SkeletonParagraph Props

AttributeDescriptionTypeDefault
roundWhether to show round paragraphbooleanfalse
row-widthParagraph widthstring100%

SkeletonTitle Props

AttributeDescriptionTypeDefault
roundWhether to show round titlebooleanfalse
title-widthTitle width*numberstring*

SkeletonAvatar Props

AttributeDescriptionTypeDefault
avatar-sizeSize of avatar placeholder*numberstring*
avatar-shapeShape of avatar placeholder, can be set to squarestringround

SkeletonImage Props

AttributeDescriptionTypeDefault
image-sizeSize of image placeholder*numberstring*
image-shapeShape of image placeholder, can be set to squarestringround

Skeleton Slots

NameDescription
defaultDefault slot
templateCustom content

Types

The component exports the following type definitions:

ts
importtype { SkeletonProps, SkeletonImageProps, SkeletonTitleProps, SkeletonAvatarShape, SkeletonImageShape, SkeletonParagraphProps, } from'vant';

Theming

CSS Variables

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-skeleton-row-height16px-
--van-skeleton-row-backgroundvar(--van-active-color)-
--van-skeleton-row-margin-topvar(--van-padding-sm)-
--van-skeleton-title-width40%-
--van-skeleton-avatar-size32px-
--van-skeleton-avatar-backgroundvar(--van-active-color)-
--van-skeleton-duration1.2s-
--van-skeleton-image-size96px
--van-skeleton-image-radius24px-

Enterprise-level mobile solution based on Vant