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
Custom Row Count
Use the count prop to set the number of skeleton rows.
Circular Skeleton
Use the variant prop to set different skeleton styles.
Rectangular Skeleton
Use variant="rect" to create a rectangular skeleton.
Random Width
Use the randomWidth prop to make skeleton widths vary randomly.
Dynamic Loading
Use the loading prop to control the display state of the skeleton screen.
Delayed Display
Use the throttle prop to set a delay time for displaying the skeleton screen.
Theme Styles
Use the theme prop to set the skeleton screen theme.
API Reference
Skeleton Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| loading | Whether to show skeleton screen | boolean | — | true |
| count | Number of placeholder rows | number | — | 3 |
| randomWidth | Whether placeholder width is random | boolean | string | — | false |
| throttle | Display delay time (ms) | number | — | 0 |
| theme | Theme style | string | 'light' | 'dark' | 'light' |
SkeletonItem Props
| Parameter | Description | Type | Options | Default |
|---|---|---|---|---|
| variant | Display style | string | text | circle | rect | 'text' |
| width | Specify width | number | string | — | '100%' |
| height | Specify height | number | string | — | 16 |
Skeleton Slots
| Name | Description |
|---|---|
| default | Actual content |
| template | Custom skeleton template |
Type Definitions
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;
}