Skip to content

Skeleton

Provide placeholder graphics at locations where content is loading. Combines convenient layouts, advanced animations, and high flexibility from mainstream UI frameworks.

Basic Usage

The most basic plain text line skeleton.

Basic Usage

Common Layouts

Quickly build common list item layouts via avatar, title, and rows.

Common Layouts

Fine-grained Item Control (SkeletonItem)

When built-in layouts don't meet your needs, you can freely assemble using YhSkeletonItem. Supports various semantic variants like circle, rect, text, button, image, etc.

Item Control Demo

Creative: Advanced Cards

Easily implement complex card streaming skeletons using variant="image" and the repeat prop.

Card Skeleton

Custom Advanced Features

1. Smart Throttling (Throttle)

Set a delayed display time via the throttle prop. If async data loads within the set time, the skeleton will never appear. This effectively eliminates the "anxiety" caused by skeleton flickering when network conditions are good.

2. Viewport Detection (Lazy Animation)

When lazy is enabled, the skeleton shimmer animation only starts when the element enters the viewport. This significantly reduces GPU usage for invisible elements in long list pages, representing the ultimate performance optimization practice.

3. Polymorphic Rendering (Polymorphic)

The variant of SkeletonItem covers all atomic elements in mainstream interaction design mockups, ensuring high fidelity from design to code.

Use in Nuxt

YhSkeleton is fully optimized for Nuxt/SSR environments, automatically degrading to a safe rendering mode.

Use in Nuxt

API

Skeleton Props

PropDescriptionTypeDefault
loadingWhether to show loading renderingbooleantrue
animatedWhether to enable shimmer animationbooleantrue
rowsNumber of rows for default layoutnumber3
titleWhether to render title placeholderbooleanfalse
avatarWhether to render circular avatar placeholderbooleanfalse
throttleDelay in milliseconds before showing, prevents flickeringnumber0
lazyOnly start animation when in viewport (advanced feature)booleanfalse

SkeletonItem Props

PropDescriptionTypeDefault
variantVariant type (circle, rect, h1, h3, text, button, image)string'text'
widthWidthstring | number
heightHeightstring | number
animatedWhether to enable shimmer animationbooleantrue
roundWhether to have rounded cornersbooleanfalse
sharpWhen true, explicitly set to sharp cornersbooleanfalse
repeatNumber of times to render (practical feature)number1

Theme Variables

VariableDescriptionDefault
--yh-skeleton-bg-colorSkeleton base background colorvar(--yh-fill-color-dark)
--yh-skeleton-shimmer-colorAnimation shimmer colorvar(--yh-fill-color-light)

Released under the MIT License.