Skip to Content
文档

骨架

用于在内容加载时渲染占位符。

SourceStorybookRecipe

用法

¥Usage

import { Skeleton, SkeletonCircle, SkeletonText } from "@chakra-ui/react"
<Stack gap="6" maxW="xs">
  <HStack width="full">
    <SkeletonCircle size="10" />
    <SkeletonText noOfLines={2} />
  </HStack>
  <Skeleton height="200px" />
</Stack>

示例

¥Examples

Feed

使用 Skeleton 组件创建动态框架。

¥Use the Skeleton component to create a feed skeleton.

文本

¥Text

使用 SkeletonText 组件创建文本框架。

¥Use the SkeletonText component to create a skeleton for text.

包含子元素

¥With Children

使用 loading 属性在内容加载时显示框架。

¥Use the loading prop to show the skeleton while the content is loading.

Select
Select

变量

¥Variants

使用 variant 属性更改骨架的视觉样式。

¥Use the variant prop to change the visual style of the Skeleton.

pulse

shine

内容加载中

¥Content Loading

loading 更改为 false 时,Skeleton 组件将淡入。

¥When loading is changed to false, the Skeleton component will fade in.

Chakra UI is cool

起始和结束颜色

¥Start and End Color

使用 --start-color--end-color CSS 变量更改骨架的起始和结束颜色。

¥Use the --start-color and --end-color CSS variables to change the start and end color of the skeleton.

属性

¥Props

PropDefaultType
colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'

The color palette of the component

loading true
'true' | 'false'

The loading of the component

variant 'pulse'
'pulse' | 'shine' | 'none'

The variant of the component

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Previous

进度

Next

旋转器