JGuang

Skeleton

Skeleton · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Skeleton

Provide a placeholder while you wait for content to load, or to visualize content that doesn't exist yet.

When To Use

  • When a resource needs long time to load.
  • When the component contains lots of information, such as List or Card.
  • Only works when loading data for the first time.
  • Could be replaced by Spin in any situation, but can provide a better user experience.

Examples

  • Basic · basic
  • Complex combination · complex
  • Active Animation · active
  • Button/Avatar/Input/Image/Node · element
  • Contains sub component · children
  • List · list
  • Custom semantic dom styling · style-class

API

Common props ref:Common props

Common API

<Antd component="Alert" title="The following APIs are shared by Skeleton, Avatar, Button, Input, Image, Node." type="info" banner="true"></Antd>

PropertyDescriptionTypeDefaultVersionGlobal Config
activeShow animation effectbooleanfalse-×
classNamesCustomize class for each semantic structure inside the Skeleton component. Supports object or function.Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-6.0.06.0.0
stylesCustomize inline style for each semantic structure inside the Skeleton component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-6.0.06.0.0

Skeleton

PropertyDescriptionTypeDefaultVersionGlobal Config
activeShow animation effectbooleanfalse×
avatarShow avatar placeholderboolean | SkeletonAvatarfalse×
loadingDisplay the skeleton when trueboolean-×
paragraphShow paragraph placeholderboolean | SkeletonParagraphPropstrue×
roundShow paragraph and title radius when truebooleanfalse×
titleShow title placeholderboolean | SkeletonTitlePropstrue×

SkeletonTitleProps

PropertyDescriptionTypeDefault
widthSet the width of titlenumber | string-

SkeletonParagraphProps

PropertyDescriptionTypeDefault
rowsSet the row count of paragraphnumber-
widthSet the width of paragraph. When width is an Array, it can set the width of each row. Otherwise only set the last row widthnumber | string | Array<number | string>-

Skeleton.Avatar

PropertyDescriptionTypeDefault
activeShow animation effect, only valid when used avatar independentlybooleanfalse
shapeSet the shape of avatarcircle | squarecircle
sizeSet the size of avatarnumber | large | medium | smallmedium

Skeleton.Button

PropertyDescriptionTypeDefaultVersion
activeShow animation effectbooleanfalse
blockOption to fit button width to its parent widthbooleanfalse4.17.0
shapeSet the shape of buttoncircle | round | square | default-
sizeSet the size of buttonlarge | medium | smallmedium

Skeleton.Input

PropertyDescriptionTypeDefault
activeShow animation effectbooleanfalse
sizeSet the size of inputlarge | medium | smallmedium

Semantic DOM

Skeleton

Semantic nodeNative descriptionVersion
rootRoot element with table display, width, animation effects, border radius and other skeleton container basic styles6.0.0
headerHeader element with table cell, padding, vertical alignment and other avatar placeholder area layout styles6.0.0
sectionSection element with skeleton content area layout styles6.0.0
avatarAvatar element with inline-block display, vertical alignment, background color, size, border radius and other avatar placeholder styles6.0.0
titleTitle element with width, height, background color, border radius and other title placeholder styles6.0.0
paragraphParagraph element with padding, list item styles, background color, border radius and other paragraph placeholder styles6.0.0

Semantic description source: vendor/components/skeleton/demo/_semantic.tsx

Skeleton.Element

Semantic nodeNative descriptionVersion
rootRoot element6.0.0
contentContent element6.0.0

Semantic description source: vendor/components/skeleton/demo/_semantic_element.tsx

Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

TokenTypeNative description
colorstringSee native declaration and inherited types
colorGradientEndstringSee native declaration and inherited types
gradientFromColorstringStart color of gradient
gradientToColorstringEnd color of gradient
titleHeightnumber | stringHeight of title skeleton
blockRadiusnumberBorder radius of skeleton
paragraphMarginTopnumberMargin top of paragraph skeleton
paragraphLiHeightnumberLine height of paragraph skeleton

Declaration source: vendor/components/skeleton/style/index.ts

import type { CSSObject } from '@ant-design/cssinjs';

import { Keyframes, unit } from '@ant-design/cssinjs';

import type { CSSUtil, FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

export interface ComponentToken {
  /** @deprecated use gradientFromColor instead. */
  color: string;
  /** @deprecated use gradientToColor instead. */
  colorGradientEnd: string;
  /**
   * @desc 渐变色起点颜色
   * @descEN Start color of gradient
   */
  gradientFromColor: string;
  /**
   * @desc 渐变色终点颜色
   * @descEN End color of gradient
   */
  gradientToColor: string;
  /**
   * @desc 标题骨架屏高度
   * @descEN Height of title skeleton
   */
  titleHeight: number | string;
  /**
   * @desc 骨架屏圆角
   * @descEN Border radius of skeleton
   */
  blockRadius: number;
  /**
   * @desc 段落骨架屏上间距
   * @descEN Margin top of paragraph skeleton
   */
  paragraphMarginTop: number;
  /**
   * @desc 段落骨架屏单行高度
   * @descEN Line height of paragraph skeleton
   */
  paragraphLiHeight: number;
}

interface SkeletonToken extends FullToken<'Skeleton'> {
  skeletonAvatarCls: string;
  skeletonTitleCls: string;
  skeletonParagraphCls: string;
  skeletonButtonCls: string;
  skeletonInputCls: string;
  skeletonNodeCls: string;
  skeletonImageCls: string;
  imageSizeBase: number | string;
  skeletonLoadingBackground: string;
  skeletonLoadingMotionDuration: string;
  borderRadius: number;
}

Shared native props

Tips: The following generic properties apply to most antd components; those not supported are described separately.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

Install and reproduce an example

npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

  • vendor/components/skeleton/Avatar.tsx
  • vendor/components/skeleton/Button.tsx
  • vendor/components/skeleton/Element.tsx
  • vendor/components/skeleton/Image.tsx
  • vendor/components/skeleton/Input.tsx
  • vendor/components/skeleton/Node.tsx
  • vendor/components/skeleton/Paragraph.tsx
  • vendor/components/skeleton/Skeleton.tsx
  • vendor/components/skeleton/Title.tsx
  • vendor/components/skeleton/style/index.ts

Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.