Skeleton
A decorative loading placeholder. Each Skeleton is aria-hidden (a consumer aria-hidden overrides it); wrap the placeholders of a loading region in SkeletonGroup (Skeleton.Group), which marks it busy, gives it a visually hidden "Loading" label and sets the size, shape, animation and appearance of the placeholders inside it.
- size is a preset in pixels (Fluent's sizes, 8 to 128): the height of a rounded line, the width and height of a circular or square box. A placeholder with no height is 16px tall.
- animation="wave" sweeps a highlight across it instead of pulsing; both stop for reduced motion. appearance="translucent" lets what is behind it show.
- In forced-colors mode the placeholders are painted GrayText. In React Server Components use the flat export SkeletonGroup instead of Skeleton.Group.
Examples
Rectangle
export const Rectangle: Story = {
args: {
width: 200,
height: 120,
},
};Circle
export const Circle: Story = {
args: {
shape: 'circular',
width: 48,
height: 48,
},
};Square
export const Square: Story = {
args: {
shape: 'square',
width: 64,
height: 64,
},
};Sizes
export const Sizes: Story = {
render: (args) => (
<div className="flex flex-col gap-3">
<Skeleton width={200} height={12} {...args} />
<Skeleton width={160} height={12} {...args} />
<Skeleton width={180} height={12} {...args} />
<Skeleton width={300} height={80} {...args} />
<div className="flex gap-2">
<Skeleton shape="circular" width={32} height={32} />
<Skeleton shape="circular" width={48} height={48} />
<Skeleton shape="circular" width={64} height={64} />
</div>
</div>
),
};Group
export const Group: Story = {
render: (args) => (
<Skeleton.Group label="Loading profile" className="flex items-center gap-3">
<Skeleton shape="circular" width={40} height={40} />
<div className="flex flex-col gap-2">
<Skeleton width={160} height={12} {...args} />
<Skeleton width={120} height={12} {...args} />
</div>
</Skeleton.Group>
),
};Size Presets
export const SizePresets: Story = {
render: ({ size: _size, ...args }) => (
<div className="flex flex-col gap-3">
{([8, 12, 16, 20, 24, 32, 40] as const).map((size) => (
<Skeleton key={size} {...args} size={size} width={size * 8} />
))}
<div className="flex items-end gap-2">
{([16, 24, 32, 48, 64] as const).map((size) => (
<Skeleton key={size} {...args} shape="circular" size={size} />
))}
</div>
</div>
),
};Wave
export const Wave: Story = {
args: { animation: 'wave' },
render: ({ animation, ...args }) => (
<div className="flex w-72 flex-col gap-3">
<Skeleton {...args} animation={animation} width="100%" height={16} />
<Skeleton {...args} animation={animation} width="70%" height={16} />
<Skeleton {...args} animation={animation} width="100%" height={80} />
</div>
),
};Translucent
export const Translucent: Story = {
render: ({ appearance: _appearance, ...args }) => (
<div className="flex w-72 flex-col gap-3 rounded bg-wave-inverted p-4">
<Skeleton {...args} appearance="translucent" width="100%" />
<Skeleton {...args} appearance="translucent" width="60%" />
</div>
),
};Group Defaults
export const GroupDefaults: Story = {
render: () => (
<Skeleton.Group
label="Loading people"
animation="wave"
size={32}
className="flex flex-col gap-3"
>
{[0, 1, 2].map((row) => (
<div key={row} className="flex items-center gap-3">
<Skeleton shape="circular" />
<Skeleton width={160 - row * 20} />
<Skeleton shape="square" size={16} />
</div>
))}
</Skeleton.Group>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
width | string | number | No | Width of the skeleton placeholder. | |
height | string | number | No | Height of the skeleton placeholder. | |
size | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128 | No | the group's size, else 16 when it has no `height` | Preset size in pixels, as Fluent's |
shape | 'circular' | 'square' | 'rounded' | No | 'rounded', or the group's shape | Geometry of the placeholder: |
animation | 'pulse' | 'wave' | No | 'pulse', or the group's animation |
|
appearance | 'opaque' | 'translucent' | No | 'opaque', or the group's appearance |
|
ref | React.Ref<HTMLDivElement> | No |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
Skeleton.Group
Stable class names
| Part | Class |
|---|---|
root | wave-skeleton |