Skip to content
Mosaic
On this page

Skeleton

A placeholder for content that is still loading. Wraps the content it stands in for: text becomes a cap-height bar as wide as the text, and an element becomes a block its size, hidden underneath. aria-hidden.

Use for

  • a placeholder for content that is still loading
  • a loading skeleton for a section, row or table
  • keeping the space of a control while loading without drawing a bone

Practices

GuidancePractice
DoBuild a skeleton in its own <feature>.skeleton.tsx from the same components as the view. The rules are in the Skeletons guide (mosaic guides inspect skeletons).
DoWrite placeholder strings at a typical length, one line each. Bars do not wrap.
DoWrap row actions with visible={false} so the row keeps its height without a bone.
Don’tLeave a skeleton up when the fetch returns nothing. Render EmptyState instead.
Don’tAdd skeleton code to a component or view. Wrap content in Skeleton from the skeleton file.

API reference

Skeleton

Renders a span around its children and forwards its ref. Carries data-shape for element children, and data-text and data-visible.

Slot: cl-skeleton

PropTypeDescription
showbooleanWhen false, renders the children as they are.Default: true
visiblebooleanWhen false, keeps the space but draws no bone.Default: true
shapeSkeletonShaperounded for media and buttons, pill for avatars and round controls, square for image tiles. Ignored for text.Default: 'rounded'
widthnumber | stringFixed width, as px or a CSS length. For a skeleton with no children.
heightnumber | stringFixed height, as px or a CSS length. For a skeleton with no children.

Examples

A text bar

TSX
<Section.Label>
  <Skeleton>{device.name}</Skeleton>
</Section.Label>

Content that stays mounted

TSX
<Skeleton show={loading}>{title}</Skeleton>