Raft 设计系统

组件 · 反馈

Skeleton

A gray placeholder in the shape of the content that is loading, for lists, cards and panels whose layout is known.

稳定也叫 Placeholder
import { Skeleton } from "@botiverse/raft-ui";
本页尚未翻译
译文完成之前,这里显示英文原文。 阅读英文版

A skeleton holds the place of content that is still loading: square blocks where avatars and tiles will be, bars where text will be. Use it when a list, card or panel loads for the first time and its layout is known. Which loading indicator fits which wait is in Choosing a component.

skeleton/compositions/preview

When to use

SituationUse
The layout of what is loading is knownSkeleton
The wait has no layout to hold, or happens in a small areaSpinner
The percentage is knownProgress
Loading finished and there is nothingEmptyState
Loading failedAn error at its scope (Feedback)

Variants

VariantUse for
variant="line"A line of text
variant="block"A thumbnail, card or any other block; size it with className
variant="circle"An avatar or tile. Despite its name it is square, like the avatar it stands for
skeleton/compositions/basic

Accessibility

  • Skeleton is aria-hidden. Mark the region that is loading with aria-busy="true" until the content arrives, so assistive technology doesn't read an empty region as empty.

Rules

  • Give the skeleton the shape of the content it stands for: square for avatars and tiles, bars for text. The size rule and the rule against swapping placeholders are in Feedback.

API

Skeleton

Prop类型默认值
variant"circle" | "line" | "block""block"

Also takes the attributes of its element.

改动