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
| Guidance | Practice |
|---|---|
| Do | Build 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). |
| Do | Write placeholder strings at a typical length, one line each. Bars do not wrap. |
| Do | Wrap row actions with visible={false} so the row keeps its height without a bone. |
| Don’t | Leave a skeleton up when the fetch returns nothing. Render EmptyState instead. |
| Don’t | Add 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
| Prop | Type | Description |
|---|---|---|
show | boolean | When false, renders the children as they are.Default: true |
visible | boolean | When false, keeps the space but draws no bone.Default: true |
shape | SkeletonShape | rounded for media and buttons, pill for avatars and round controls, square for image tiles. Ignored for text.Default: 'rounded' |
width | number | string | Fixed width, as px or a CSS length. For a skeleton with no children. |
height | number | string | Fixed height, as px or a CSS length. For a skeleton with no children. |
Examples
A text bar
<Section.Label>
<Skeleton>{device.name}</Skeleton>
</Section.Label>Content that stays mounted
<Skeleton show={loading}>{title}</Skeleton>