Skip to content

Skeleton ​

Introduction ​

Skeleton screens are used to display placeholder content while data is loading, improving user experience. mengyue-components has encapsulated this component and conducted vitest testing.
You can use <MYSkeleton></MYSkeleton> or <MYSkeleton /> and <MYSkeleton-item></MYSkeleton-item> or <MYSkeleton-item /> to implement a skeleton screen.

Basic Usage ​

Default Multi-line Text Skeleton ​

Code Demo
展开代码

Custom Row Count ​

Use the count prop to set the number of skeleton rows.

Code Demo
展开代码

Circular Skeleton ​

Use the variant prop to set different skeleton styles.

Code Demo
展开代码

Rectangular Skeleton ​

Use variant="rect" to create a rectangular skeleton.

Code Demo
展开代码

Random Width ​

Use the randomWidth prop to make skeleton widths vary randomly.

Code Demo
展开代码

Dynamic Loading ​

Use the loading prop to control the display state of the skeleton screen.

Code Demo
展开代码

Delayed Display ​

Use the throttle prop to set a delay time for displaying the skeleton screen.

Code Demo
展开代码

Theme Styles ​

Use the theme prop to set the skeleton screen theme.

Code Demo
展开代码

API Reference ​

Skeleton Props ​

ParameterDescriptionTypeOptionsDefault
loadingWhether to show skeleton screenboolean—true
countNumber of placeholder rowsnumber—3
randomWidthWhether placeholder width is randomboolean | string—false
throttleDisplay delay time (ms)number—0
themeTheme stylestring'light' | 'dark''light'

SkeletonItem Props ​

ParameterDescriptionTypeOptionsDefault
variantDisplay stylestringtext | circle | rect'text'
widthSpecify widthnumber | string—'100%'
heightSpecify heightnumber | string—16

Skeleton Slots ​

NameDescription
defaultActual content
templateCustom skeleton template

Type Definitions ​

typescript
interface SkeletonProps {
  loading?: boolean;
  animated?: boolean;
  count?: number;
  randomWidth?: boolean | string;
  throttle?: number;
  theme?: 'light' | 'dark';
}

interface SkeletonItemProps {
  variant?: 'text' | 'circle' | 'rect';
  width?: number | string;
  height?: number | string;
}

Released under the MIT License.