Skip to content

Skeleton

Skeleton screens are used for placeholder display during content loading, supporting multiple theme types, custom rows and columns, animation effects, and slot content.

Component Types

Basic Usage

Set different skeleton themes through theme, commonly used for text, avatar, image, paragraph and other scenarios.

html
<wd-skeleton theme="avatar" />
<wd-skeleton theme="image" />
<wd-skeleton theme="text" />
<wd-skeleton theme="paragraph" />

Component Styles

Grid Skeleton Screen

Construct a grid skeleton screen by combining multi-row and multi-column placeholder structures through row-col.

html
<wd-skeleton :row-col="grid" />
ts
const grid = [
  [
    { width: '48px', height: '48px' },
    { width: '48px', height: '48px' },
    { width: '48px', height: '48px' },
    { width: '48px', height: '48px' },
    { width: '48px', height: '48px' }
  ],
  [
    { width: '48px', height: '16px' },
    { width: '48px', height: '16px' },
    { width: '48px', height: '16px' },
    { width: '48px', height: '16px' },
    { width: '48px', height: '16px' }
  ]
] as SkeletonRowCol[]

Cell Skeleton Screen

Can combine avatar, rectangle block and text lines to simulate common cell list layouts.

html
<view style="display: flex">
  <wd-skeleton :row-col="[{ size: '48px', type: 'circle' }]" />
  <wd-skeleton :custom-style="{ width: '100%', marginLeft: '12px' }" :row-col="[{ width: '50%' }, { width: '100%' }]" />
</view>
<view style="display: flex; margin-top: 20px">
  <wd-skeleton :row-col="[{ size: '48px', type: 'rect' }]" />
  <wd-skeleton :custom-style="{ width: '100%', marginLeft: '12px' }" :row-col="[{ width: '50%' }, { width: '100%' }]" />
</view>

Image Combination Skeleton Screen

Can combine row-col to customize image card and text-image mixed layout placeholder structures.

html
<wd-skeleton :row-col="[{ height: '171px' }, 1, { width: '107px' }, [{ width: '93px' }, { width: '32px', marginLeft: '41px' }]]" />
<wd-skeleton :custom-style="{ marginTop: '20px' }" :row-col="[{ height: '171px' }, 1, { width: '107px' }, [{ width: '93px' }, { width: '32px', marginLeft: '41px' }]]" />

Special Styles

Gradient Loading Animation

Set animation="gradient" to enable gradient loading animation.

html
<wd-skeleton animation="gradient" theme="paragraph" />

Flashing Loading Animation

Set animation="flashed" to enable flashing loading animation.

html
<view style="display: flex">
  <wd-skeleton :row-col="[{ size: '48px', type: 'circle' }]" />
  <wd-skeleton :custom-style="{ width: '100%', marginLeft: '12px' }" animation="flashed" theme="paragraph" />
</view>

Slot Content

Write actual content through the default slot. When loading is true, the skeleton screen is displayed; after switching to false, the slot content is displayed.

html
<wd-skeleton :row-col="grid" :loading="showContent">
  <wd-grid>
    <wd-grid-item icon-size="32px" icon="camera" text="Text" />
    <wd-grid-item icon-size="32px" icon="camera" text="Text" />
    <wd-grid-item icon-size="32px" icon="camera" text="Text" />
    <wd-grid-item icon-size="32px" icon="camera" text="Text" />
    <wd-grid-item icon-size="32px" icon="camera" text="Text" />
  </wd-grid>
</wd-skeleton>
ts
const showContent = ref(true)

Attributes

ParameterDescriptionTypeDefault Value
themeSkeleton screen theme, optional values are text, avatar, paragraph, imageSkeletonTheme'text'
row-colCustomize placeholder configuration for each row, used to set the number of rows and columns, width, height, spacing, rounded corners and placeholder type, etc.SkeletonRowCol[][]
loadingWhether to display the skeleton screenbooleantrue
animationAnimation type, optional values are gradient, flashedSkeletonAnimation''
custom-classCustom style class namestring | string[] | Record<string, boolean>''
custom-styleCustom inline styleCSSProperties{}

Slots

NameDescription
defaultActual content displayed after loading ends

Type Definitions

SkeletonTheme

Optional values: 'text' \| 'avatar' \| 'paragraph' \| 'image'

SkeletonAnimation

Optional values: 'gradient' \| 'flashed'

SkeletonRowCol Configuration Example

ts
// Three rows, displayed as one column, one column, two columns of placeholders
[1, 1, 2]

// Three rows, third row with custom width
[1, 1, { width: '100px' }]

// The third row contains two columns, set width and right margin respectively
[1, 1, [{ width: '50%' }, { width: '50%', marginRight: '10px' }]]

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-skeleton-row-margin-bottom$spacing-loose行间距
--wot-skeleton-col-bg$filled-strong占位块背景色
--wot-skeleton-text-height$n-16文本占位高度
--wot-skeleton-rect-height$n-16矩形占位高度
--wot-skeleton-circle-height$n-48圆形占位尺寸
--wot-skeleton-text-border-radius$radius-small文本占位圆角
--wot-skeleton-rect-border-radius$radius-main矩形占位圆角
--wot-skeleton-circle-border-radius$radius-full圆形占位圆角
--wot-skeleton-animation-gradient$filled-bottom渐变动画高亮色
--wot-skeleton-animation-flashed$filled-bottom闪烁动画高亮色
--wot-skeleton-animation-flashed-opacity$opacity-backdrop闪烁动画透明度

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.